How to click the SUBMENU in MAINMENU

438 views
Skip to first unread message

Amritesh

unread,
Mar 5, 2014, 8:45:55 AM3/5/14
to seleniu...@googlegroups.com
Hi All,

I am trying to click in the SUBMENU options in the MAIN MENU.
The SUBMENU displayed on the MOUSEHOVER on MAIN MENU. (expected)
But not able to do it on using the Action. Its unable to locate the element.
With Below script I tried to execute: 

                Actions builder = new Actions(driver);
WebElement srchjob = driver.findElement(By.id("dropmenu1"));
                WebElement advsrch = driver.findElement(By.xpath("a[href='http://jobsearch.monsterindia.com/search.html']"));
                builder.moveToElement(srchjob).build().perform();
System.out.println("Submenu displayed? " + advsrch.isDisplayed());
advsrch.click();


md ashfaq

unread,
Mar 5, 2014, 12:50:36 PM3/5/14
to seleniu...@googlegroups.com
Hi Amritesh, 

try this:

 Actions builder = new Actions(driver);
 WebElement srchjob = driver.findElement(By.id("dropmenu1"));
 WebElement advsrch = driver.findElement(By.xpath("a[href='http://jobsearch.monsterindia.com/search.html']"));
 builder.moveToElement(srchjob).perform();
 System.out.println("Submenu displayed? " + advsrch.isDisplayed());
 builder.moveToElement(advsrch).click().perform();

Regards,
Ashfaq

Madan Singh

unread,
Mar 5, 2014, 11:40:46 PM3/5/14
to seleniu...@googlegroups.com
Hi may you try this,

                Actions builder = new Actions(driver);
WebElement srchjob = driver.findElement(By.id("dropmenu1"));
                builder.moveToElement(srchjob).build().perform();
//put some sleep here like 2 secs
                WebElement advsrch = driver.findElement(By.xpath("a[href='http://jobsearch.monsterindia.com/search.html']"));
                System.out.println("Submenu displayed? " + advsrch.isDisplayed());
advsrch.click();

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/84d1154f-3715-4224-b796-d092688b7e1f%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
M P Singh
9971360313

Ravindra

unread,
Mar 5, 2014, 11:53:45 PM3/5/14
to seleniu...@googlegroups.com
Yeah, Madan is correct.
you are trying to hit submenu before hover over using action class. So first you have to apply moveToElement method on Main menu then only the submenu will get visible to webdriver.

Regards,
~Ravindra

amritesh kumar

unread,
Mar 6, 2014, 12:50:09 AM3/6/14
to seleniu...@googlegroups.com
hi madan,

I also put the Thread.sleep(Time) and also put Explicit wait for that condition, But unable to locate the  WebElement.
And get the following error:

Exception in thread "main" org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"xpath","selector":"a[href='http://jobsearch.monsterindia.com/search.html']"}
Command duration or timeout: 15 milliseconds

After using the following code:

Actions builder = new Actions(driver);
  WebElement srchjob = driver.findElement(By.id("dropmenu1"));
  builder.moveToElement(srchjob).build().perform();
  WebElement advsrch = driver.findElement(By.xpath("a[href='http://jobsearch.monsterindia.com/search.html']"));
  System.out.println("Submenu displayed? " + advsrch.isDisplayed());
  advsrch.click();
  WebDriverWait wait1 = new WebDriverWait(driver,20);
  wait1.until(ExpectedConditions.titleContains("Monsterindia.com - More jobs for Indians."));

Plz solve it...

Thanks

--
You received this message because you are subscribed to a topic in the Google Groups "Selenium Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/selenium-users/QgIVscAEpTg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to selenium-user...@googlegroups.com.

To post to this group, send email to seleniu...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.



--
Thanks & Warm Regards,
Amritesh Kumar

Madan Singh

unread,
Mar 6, 2014, 1:14:26 AM3/6/14
to seleniu...@googlegroups.com
Hi, are you sure you have correct element identification for both means Id and XPath, if yes then do this,

Actions builder = new Actions(driver);
  WebElement srchjob = driver.findElement(By.id("dropmenu1"));
  builder.moveToElement(srchjob).build().perform();
//Just wait here to get loaded the dropdown properly
 WebDriverWait wait1 = new WebDriverWait(driver,20);
//Then verify that you have below xpath location and click on same

For more options, visit https://groups.google.com/groups/opt_out.

NANI.THRINATH

unread,
Apr 6, 2014, 5:51:21 AM4/6/14
to seleniu...@googlegroups.com
Try follows, it works for me!

 Actions action = new Actions(driver);
 action.moveToElement(driver.findElement(By.linkText("Search Jobs"))).build().perform();
 WebDriverWait wait = new WebDriverWait(driver, 5);
 wait.until(ExpectedConditions.elementToBeClickable(By.linkText("Advanced Job Search"))).click();


Regards,
Chava Chowdary


--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.



--
Regards,
Thirnath
Reply all
Reply to author
Forward
0 new messages