我试图单击文本下的一行,但未单击它,也未显示错误。
网站名称voylla.com
package newpackage;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.Select;
import org.openqa.selenium.interactions.Actions;
public class seven {
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver", "E:\\h\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
String baseUrl = "http://www.voylla.com";
driver.get(baseUrl);
WebElement menu = driver.findElement(By.className("dropdown"));
//WebElement submenu = driver.findElement(By.cssSelector("#main-div > div.mdl-tabs.mdl-js-tabs.mdl-js-ripple-effect.mdl-js-ripple-effect--ignore-events.is-upgraded > div > div > div > div:nth-child(7)"));
WebElement sub = driver.findElement(By.xpath("//*[@id=\"main-div\"]/div[2]/div/div/div/div[7]/a"));
Hover(driver, menu);
HoverAndClick(driver, sub, sub);
}
public static void Hover(WebDriver driver, WebElement element) {
Actions action = new Actions(driver);
action.moveToElement(element).perform();
}
public static void HoverAndClick(WebDriver driver, WebElement elementToHover, WebElement elementToClick) {
Actions action = new Actions(driver);
action.moveToElement(elementToHover).click(elementToClick).build().perform();
}
}