Which of the following options can be used to move to the main menu option and then sub option through action method in webdriver

0 votes
1)Action element =  builder.moveToElement(menu).moveToElement(menuoption).build()

2) Action element =  builder.moveToElement(menuoption).moveToElement(menuoption).build()

3)Action element =  builder.moveToElement(menu).moveToElement().build(menuoption)

4) Action element =  builder.moveToElement(menuoption).moveToElement(menu).build()
Jul 23, 2020 in Selenium by naresh
• 120 points
551 views

1 answer to this question.

0 votes

Hello @ naresh,

With the actions object you should first move the menu title, and then move to the submenu item and click it.

First, we need to create new action builder instance by passing the webdriver instance, then.

Below is the sample code to perform Mouse hover action

Actions actions = new Actions(driver);
WebElement mainMenu = driver.findElement(By.linkText("menulink"));
actions.moveToElement(mainMenu);

WebElement subMenu = driver.findElement(By.cssSelector("subLinklocator"));
actions.moveToElement(subMenu);
actions.click().build().perform();

Here 'build()' method is used to compile all the list of actions into a single step and ready to be performed.

So you can try option(1) 

Hope it helps!!

Thank You!!

answered Jul 23, 2020 by Niroj
• 82,760 points

Related Questions In Selenium

0 votes
1 answer

Which methods which can be used to handle pop-up and alerts in Python Selenium Webdriver?

Hey Kishor, Python Selenium webdriver provides following ...READ MORE

answered Jul 29, 2019 in Selenium by Abha
• 28,040 points
169 views
0 votes
1 answer
0 votes
1 answer

Which click command can be used to click on a specific part of webpage in Selenium?

Hi Apeksha, in Selenium IDE to click on ...READ MORE

answered Oct 17, 2019 in Selenium by Devesh
574 views
0 votes
2 answers

What are the wait methods which can be used to handle AJAX calls?

Hi , for Ajax call better to use Explicit ...READ MORE

answered Sep 2, 2020 in Selenium by Sri
• 3,050 points
249 views
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 26, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
1,134 views
0 votes
2 answers

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,520 points
5,335 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,050 points
6,016 views
+2 votes
1 answer

How to fetch the text of a web element where the text is split in 2 lines?

Hello, You want to use a non-breaking space ...READ MORE

answered May 28, 2020 in Selenium by Niroj
• 82,760 points
1,162 views
0 votes
1 answer