我正在使用Selenium Web Driver进行自动化,使用这个新应用程序,我无法通过常规方法找到元素。 我的代码如下:
driver.findElement(By.xpath("html/body/div[1]/md-sidenav/md-list[1]/md-list-item[2]/button")).click();
我想点击'视图'。需要一些帮助,我尝试了以下xpath方法:
//span[contains(@class, 'ng-binding ng-scope') and normalize-space()='Data']
//div[1]/md-sidenav/descendant::span[text()='Data']/button ---- no success
当我使用时:
driver.findElement(By.xpath("html/body/div[1]/md-sidenav/md-list[1]/md-list-item[2]/button")).click();
以上代码有效,但我不想使用item [x],因为它们会经常更改。
请帮忙! 谢谢!