我正在练习硒鼠标悬停和使用网站 - http://www.flipkart.com,我从“电子”菜单中选择“三星”。下面是我的代码,但即使xpaths正确,它也不起作用。Selenium:无法找到元素
@CacheLookup
@FindBy(xpath="//a[@data-tracking-id='electronics']") WebElement Electronics_Menu;
@CacheLookup
@FindBy(xpath=".//*[@id='menu-electronics-tab-0-content']//a[text()='Samsung']") WebElement Samsung_Mobile_Click;
Actions act = new Actions(driver);
act.moveToElement(Electronics_Menu).perform();
act.click(Samsung_Mobile_Click).build().perform();
这是我的错误,当我运行代码:
org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"xpath","selector":".//*[@id='menu-electronics-tab-0-content']//a[text()='Samsung']"}
Command duration or timeout: 27.04 seconds
试试这个'XPath':'// a [@ title =“Samsung”]' – Andersson
Thanks !!它的工作:) – Bimlesh