【发布时间】:2019-10-16 19:24:31
【问题描述】:
我正在尝试在以下网站上选择第三级子菜单项。代码在此处执行时没有任何错误,但未在最终子菜单项上执行单击操作。
菜单项:Shop By Category -> Personal Care -> Ayurvedic
我在 chrome 浏览器上运行这个脚本。我试图选择二级菜单项,但是没有选择三级菜单项。顺便说一句,在 java 脚本执行器的帮助下,我能够成功地执行相同的操作。
Actions builder= new Actions(driver);
Action act=builder.moveToElement(driver.findElement(By.xpath(".//*[@id='navbar']/ul/li[1]/a")))
.moveToElement(driver.findElement(By.xpath("//a[@href='/cl/personal-care/?nc=nb']")))
.moveToElement(driver.findElement(By.xpath("//a[@href='/pc/personal-care/ayurvedic-non-food/?nc=nb']")))
.click()
.build();
//perform() method when executing the Action object we designed above
act.perform();
【问题讨论】: