Action class click().build.perform(); does not load a new page

I have used the website to practice automation using Selenium Webdriver – Java.

I am automating the following scenario

1. Hover on Product category menu
2. Click on Accessories sub menu – The Accessories Page is loaded
3. Check if the title of the Accescories page matches with the expected title

I used Action class and was able to go upto clicking of the Accessories sub menu.
However,when running the test .I can see the clicking being done by the driver but it  does not load the Accessories Page at all and hence the test fails due to TimeOut Exception.
I have tried using click(), clickAndHold() as well as doubleclick() but none works.

Code is given below
WebDriverWait myWaitvar = new WebDriverWait (driver, 10);
Actions action = new Actions (driver);
WebElement mainMenu = driver.findElement(“menu-item-33″));
WebElement subMenu = driver.findElement(“menu-item-34″));
//This is to wait till this element is visible on the page
What is the issue with the code above and how can the click load the Accessories page?

cs1911 Default Asked on February 8, 2016 in Selenium WebDriver.
Add Comment
3 Answer(s)

where is action.moveToElement(mainMenu).build().perform()?


Virender Singh Professor Answered on February 8, 2016.
Add Comment


Try with this code,hope it works fine.. i just wrote the code ,haven’t executed.

public static void main(string[] args){
webDriver driver;
driver=new firefoxDriver();
WebElement x= driver.findelement(By.xpath(“//a[@href=’’]”));

WebElement y= driver.findelement(By.xpath(“//a[@href=’’]”));

Actions a=new Action();
String act_title=Accessories|ONLINE STORE;
String exp_title=driver.getCurrentTitle();
System.out.println(“Success,the actual and the expected titles matched”);

mukesh007 Train Answered on February 11, 2016.
Add Comment

Yes I tried having both the webelements on the same line and its working perfectly fine. Also I realised that the xpath that I was using was of a div and not the link,hence replaced with linkText. Now its working

Thank you so much for your responses!

cs1911 Default Answered on February 27, 2016.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.