我正在使用selenium-webdriver学习自动化并尝试实现。所以我是这个话题的新手。我有2个测试用例的问题 1.当我将鼠标悬停在页脚文本上时,它会显示下划线。例如转到https://www.yahoo.com/news/并将鼠标悬停在“我们”或“新闻首页”上,它会显示下划线。我该如何检查? 2.当我将房子悬停在Facebook图标上时,它会显示不同的颜色,而悬停该如何检查测试。 我为脚本编写了以下代码。但它不起作用 我关于stackoverflow的话题很少,但仍然无法正常工作。 公共类UnderLine {
public static void main(String[] args) throws Exception {
final String URL = "https://www.yahoo.com/news/";
WebDriver driver = new FirefoxDriver();
driver.manage().timeouts().setScriptTimeout(10000,TimeUnit.SECONDS);
driver.get(URL);
WebElement news1 = driver.findElement(By.xpath("//a[contains(@title,'Politics')]")); // For headline menu xpath
WebElement followUs = driver.findElement(By.xpath("//div[4]/div[@class='Pos(r) D(ib) Cur(d) Va(t)' and 1]/div[@class='D(ib)' and 1]")); //Facebook xpath
System.out.println("Before text decoration "+news1.getCssValue("border-bottom"));
System.out.println(news1.getText());
Actions nowHover = new Actions(driver);
nowHover.moveToElement(news1).perform();
Thread.sleep(10000);
Actions nowHover1 = new Actions(driver);
nowHover1.moveToElement(followUs).perform();
Thread.sleep(10000);
System.out.println(followUs.getCssValue("background-color"));
}
}