我正在尝试在Cricinfo网站的菜单上执行鼠标悬停功能。
它没有抛出任何错误,也没有完成预期的操作。
任何人都可以建议我问题出在哪里,或者找到一种方法来调试它。
File file = new File(".\\Config\\Driver\\chromedriver.exe");
System.setProperty("webdriver.chrome.driver", file.getAbsolutePath());
driver = new ChromeDriver();
driver.get("http://www.espncricinfo.com/ci/engine/series/index.html?view=current");
driver.manage().window().maximize();
Thread.sleep(7000);
Actions action = new Actions(driver);
WebElement eleFirstLevel = driver.findElement(By.xpath("//a [@href='/ci/engine/match/index.html?view=live']"));
action.moveToElement(eleFirstLevel).perform();
action.moveToElement(driver.findElement(By.xpath("//ul//li[3]"))).click().build().perform();
Thread.sleep(5000);
driver.quit();
答案 0 :(得分:0)
请检查Xpath: -
action.moveToElement(driver.findElement(By.xpath("//ul//li[3]"))).click().build().perform();
检查此代码:
driver.get("http://www.espncricinfo.com/ci/engine/series/index.html?view=current");
driver.manage().window().maximize();
Thread.sleep(7000);
Actions action=new Actions(driver);
WebElement eleFirstLevel=driver.findElement(By.xpath("//a [@href='/ci/engine/match/index.html?view=live']"));
action.moveToElement(eleFirstLevel).perform();
action.moveToElement(driver.findElement(By.xpath(".//*[@id='nav_grp']/li[2]/div[2]/ul/li[3]"))).click().build().perform();
Thread.sleep(5000);
driver.close();