[英]Click() event not working over a button (XPATH)
I'm trying to get a Click() event on this button (called: Add PRODUCT) but it is not working, working on a JAVA automation.我正在尝试在此按钮(称为:添加产品)上获取Click()事件,但它不工作,正在处理 JAVA 自动化。
I'm getting this XPATH:我得到这个 XPATH:
//*[@id="order-items"]/div 1 /div/button 1 /span //*[@id="order-items"]/div 1 /div/button 1 /span
This is the FULL XPATH:这是完整的 XPATH:
/html/body/div 3 /main/div 2 /div/div/form/div[5]/div/div 1 /section 1 /div 1 /div/button 1 /span /html/body/div 3 /main/div 2 /div/div/form/div[5]/div/div 1 /section 1 /div 1 /div/button 1 /span
So, I'm trying to do something like this:所以,我正在尝试做这样的事情:
driver.findElement(By.xpath("//*[@id="order-items"]/div[1]/div/button[1]/span")).click();
What am i doing wrong?我究竟做错了什么?
EDIT#1:编辑#1:
If i click on "ADD PRODUCT" i got this XPATH:如果我点击“添加产品”,我会得到这个 XPATH:
//*[@id="add_products"]
EDIT #2编辑#2
I got this:我懂了:
xpath: //*[@id="order-items"]/div 1 /div/button 1 xpath: //*[@id="order-items"]/div 1 /div/button 1
I got this:我懂了:
xpath: //*[@id="add_products"] xpath: //*[@id="add_products"]
first, .click() will only work on html active tags.首先, .click()仅适用于 html 活动标签。 second, focus directly on the button.第二,直接关注按钮。
driver.findElement(By.xpath("*//button[@id='add_products']").click();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.