在自動(dòng)化過(guò)程中,有些導(dǎo)航按鈕只有當(dāng)鼠標(biāo)懸浮在登錄信息上時(shí),它才能出現(xiàn)。這時(shí)候如果想要點(diǎn)擊導(dǎo)航按鈕直接用selenium的webDriver是無(wú)法定位的元素的,因?yàn)檫@些元素是隱藏的,只有鼠標(biāo)懸浮時(shí)才出現(xiàn),所以要記錄一下,給大家一個(gè)參考
	Actions action = new Actions(driver);
	WebElement nav=driver.findElement(By.xpath("/html/body/div[1]/div/div[1]/div[2]/div/ul/li/a/span"));
	//if found the link, then hover over the link to display the menu.
	if(nav.isDisplayed()){
	System.out.println("found=================");
	action.moveToElement(nav).build().perform();
	}
	//        action.moveToElement(nav).moveByOffset(3, 3).build().perform();
	//click the displayed menu
	//        driver.findElement(By.xpath("/html/body/div[1]/div/div[1]/div[2]/div/ul/li/ul/li[2]/a")).click();
	//click the logout menu via js
	JavascriptExecutor js = (JavascriptExecutor) driver;
	WebElement logout=driver.findElement(By.xpath("//a[contains(@href, '/GlobalDataTaxonomy/user/signout')]"));
	//        String myjs="$('//a[contains(@href, '/GlobalDataTaxonomy/user/signout')]').click();";
	js.executeScript("arguments[0].click();",logout);
	driver.close();