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

I have used the website http://store.demoqa.com/ 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(By.id(“menu-item-33”));
action.moveToElement(mainMenu);
WebElement subMenu = driver.findElement(By.id(“menu-item-34”));
action.moveToElement(subMenu).click(subMenu).build().perform();
myWaitvar.until(ExpectedConditions.elementToBeClickable(By.xpath(“/html/body/div[2]/div/div/div/div/div[1]/article/div/div/div[3]/div[2]/h2/a”)));
//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 Answers

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

Virender

Professor Answered on February 8, 2016.
Add Comment

Your Answer

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