Select item from sub-menu of a menu using mouse over action in selenium

0 votes
May 21 in Selenium by Ashu
65 views

1 answer to this question.

0 votes
import java.util.concurrent.TimeUnit;

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.interactions.Actions;

public class SelectCourseMouseOver {

 static WebDriver driver;
static WebElement categories, subMenu, course;
public static String driverPath = "C:\\\\Users\\\\Anvi_R\\\\Downloads\\\\ExtractedFiles\\\\chromedriver_win32\\\\chromedriver.exe";

 public static void main(String[] args) throws InterruptedException {
  System.setProperty("webdriver.chrome.driver", driverPath);
  driver = new ChromeDriver();
  driver.manage().window().maximize();
  driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);

  driver.get("https://edureka.co");

  categories = driver.findElement(By.xpath("//a[@class='cat_btn hidden-xs giTrackElementHeader']"));
  subMenu = driver.findElement(By.xpath("//li[@class='course_category_name_menu']//a[@id='software-testing-certification-courses']"));
  course = driver.findElement(By.id("c535"));

  Actions action = new Actions(driver);
  action.moveToElement(categories).perform();
  action.moveToElement(subMenu).perform();
  action.moveToElement(course).click().perform();
//  Thread.sleep(3000);

//  driver.close();
}

}

This automation script is an example of selecting an item from sub-menu using Mouse Hover action in Selenium.

answered May 21 by Anvi
• 11,690 points

Related Questions In Selenium

0 votes
1 answer

Select an item from a dropdown list using Selenium WebDriver

Use this then it will work - new ...READ MORE

answered Apr 9, 2018 in Selenium by Vardy
• 2,250 points
1,724 views
0 votes
1 answer

Select a drop down value of angular js application using selenium using text

To select drop down use following, driver.findElements(By.className("Your dropdown ...READ MORE

answered Jun 18, 2018 in Selenium by Samarpit
• 5,130 points
1,665 views
0 votes
5 answers
0 votes
1 answer

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,050 points
403 views
0 votes
1 answer
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,130 points
760 views
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,130 points
400 views
0 votes
1 answer