我正在尝试在此按钮上获取 click()事件(称为:添加产品),但它无法正常工作,可以从事Java自动化。
我得到了这个XPath:
//*[@ID =“ order-items”]/div 1 / div/button 1 /span
这是完整的xpath:
/html/body/div 3 /main/main/div 2 /div/div/div/div/form/div [5]/div/div/div/div /div 1 /div/div/div/div/div/button 1 /span
driver.findElement(By.xpath("//*[@id="order-items"]/div[1]/div/button[1]/span")).click();
编辑#1:
如果我单击“添加产品”,我得到了此XPath:
//*[@id="add_products"]
edit#2
我得到了这个:
xpath://*[@id =“ order-items”]/div 1 /div/button 1
我得到了这个:
xpath://*[@id =“ add_products”]
I'm trying to get a Click() event on this button (called: Add PRODUCT) but it is not working, working on a JAVA automation.

I'm getting this XPATH:
//*[@id="order-items"]/div1/div/button1/span
This is the FULL XPATH:
/html/body/div3/main/div2/div/div/form/div[5]/div/div1/section1/div1/div/button1/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:
If i click on "ADD PRODUCT" i got this XPATH:
//*[@id="add_products"]
EDIT #2

I got this:
xpath: //*[@id="order-items"]/div1/div/button1

I got this:
xpath: //*[@id="add_products"]
发布评论
评论(1)
首先, Click()仅在HTML活动标签上工作。其次,直接关注按钮。
first, .click() will only work on html active tags. second, focus directly on the button.