How to mouse hover using java through selenium-webdriver and Java

后端 未结 1 690
梦如初夏
梦如初夏 2021-01-15 01:17

While trying to automate the portal http://demo.nopcommerce.com/, am not able to select mouse hover over \"Electornics\" menu and select \"Camera & Photo\" sub menu. Use

相关标签:
1条回答
  • 2021-01-15 01:42

    To Mouse Hover over "Electornics" menu and select "Camera & Photo" you can use the following code block :

    driver.get("http://demo.nopcommerce.com/");
    Actions act = new Actions(driver);
    WebDriverWait wait = new WebDriverWait(driver, 10);
    WebElement electronics = wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//li/a[@href='/electronics']")));
    act.moveToElement(electronics).perform();
    WebElement camera_n_photo = driver.findElement(By.xpath("//li/a[@href='/electronics']//following::ul/li/a"));
    camera_n_photo.click();
    System.out.println("Camera & photo Clicked.");
    
    0 讨论(0)
提交回复
热议问题