Can't click on items in drop down menu

2,074 views
Skip to first unread message

Dan Franko

unread,
Jun 1, 2011, 12:24:03 PM6/1/11
to seleniu...@googlegroups.com
Using the webDriver backed selenium aka Selenium 2.0 I can't seem to click on menu items like I used to be able to.  It's a common menu where you mouse over and other items appear.  Previous to this we would just click the item we wanted in the list without going through the whole exercise of mousing over and then selecting the now visible item, but that won't work now as we can't click on items that aren't visible.  Problem is I've tried mousing over and still haven't been able to click on this link.  The webpage is below it's the 'Our Services' tab I'm attempting to click on and to get a menu item below that.

https://www.pb.com/addressrightnow/

I've tried 

selenium.fireEvent(PublicHome.TAB_OURSERVICES, "onmouseover");
selenium.fireEvent(PublicHome.TAB_OURSERVICES, "onclick");
selenium.mouseOver(PublicHome.TAB_OURSERVICES);

Thanks in advance for your help!

Lutfi Dughman

unread,
Jun 1, 2011, 12:53:46 PM6/1/11
to seleniu...@googlegroups.com
remove the on from onmouseover and onclick


selenium.fireEvent(PublicHome.TAB_OURSERVICES, "mouseover");
selenium.fireEvent(PublicHome.TAB_OURSERVICES, "click");

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/WklfNlRtdVdVTllK.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/selenium-users?hl=en.

Dan Franko

unread,
Jun 1, 2011, 1:27:35 PM6/1/11
to seleniu...@googlegroups.com
Oh yeah.  Whoops!  However, that doesn't seem to have solved my issue.  Even with that correction nothing happens when those steps execute.  They appear to be executed, but nothing occurs on the application using firefox or ie.

Lutfi Dughman

unread,
Jun 1, 2011, 1:41:12 PM6/1/11
to seleniu...@googlegroups.com
can you try a simple click or clickAt  for the tab, i noticed that clicking the tab also shows the menu.

On Wed, Jun 1, 2011 at 1:27 PM, Dan Franko <dfr...@gmail.com> wrote:
Oh yeah.  Whoops!  However, that doesn't seem to have solved my issue.  Even with that correction nothing happens when those steps execute.  They appear to be executed, but nothing occurs on the application using firefox or ie.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.

Dan Franko

unread,
Jun 1, 2011, 1:58:47 PM6/1/11
to seleniu...@googlegroups.com
Clicking the tab actually brings you to a page.

Lutfi Dughman

unread,
Jun 1, 2011, 3:03:13 PM6/1/11
to seleniu...@googlegroups.com
yes, ur right.

umm, what about mouseMouse and mouseMoveAt, did you try these.

On Wed, Jun 1, 2011 at 1:58 PM, Dan Franko <dfr...@gmail.com> wrote:
Clicking the tab actually brings you to a page.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.

Dan Franko

unread,
Jun 1, 2011, 3:29:54 PM6/1/11
to seleniu...@googlegroups.com
Those don't work either.

Ryan Schroeder

unread,
Jun 1, 2011, 6:43:20 PM6/1/11
to seleniu...@googlegroups.com
My apologies if this spams the thread, I've tried posting three times now.

This was the only workaround I could get working.

WebDriver driverFF = new FirefoxDriver();
driverFF.manage().timeouts().implicitlyWait(3000, TimeUnit.MILLISECONDS);

//Get the element of the dropdown ('Our Services')         
RenderedRemoteWebElement r = (RenderedRemoteWebElement)driverFF.findElement(By.className("link2"));
Point p = r.getLocationOnScreenOnceScrolledIntoView();
Robot robot = new Robot();
robot.mouseMove(p.getX(), p.getY());  

//Get the element of the navigation bar        
WebElement dropdownElement = driverFF.findElement(By.className("mainNav"));

//Get the element that we wish to click on ('Overview')        
dropdownElement.findElement(By.id("a_cat_ourServices_overview")).click();

driverFF.quit();

Let me know if this helps.

Smita Sinha

unread,
Jun 3, 2011, 7:32:35 AM6/3/11
to seleniu...@googlegroups.com
Hi,
 
Use
selenium.select(locator,label)
selenium.click(value)
 
If you have duplicate label in the dropdown
You can use
selenium.select(locator,value)
selenium.click(value)
 
Regards

On Thu, Jun 2, 2011 at 12:59 AM, Dan Franko <dfr...@gmail.com> wrote:
Those don't work either.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.

Mark Collin

unread,
Jun 3, 2011, 8:49:55 AM6/3/11
to seleniu...@googlegroups.com

I would suggest that duplicate labels in drop down menu’s should be raised as bugs.  How is the end user supposed to know which label to use?


-- This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. If you are not the intended recipient you are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited. If you have received this email in error please notify postm...@ardescosolutions.com

Ryan Schroeder

unread,
Jun 1, 2011, 6:00:31 PM6/1/11
to Selenium Users
I tried several work arounds, this was the only one I could get
working.

WebDriver driverFF = new FirefoxDriver();
driverFF.manage().timeouts().implicitlyWait(3000,
TimeUnit.MILLISECONDS);
driverFF.get("https://www.pb.com/addressrightnow/");

//Finds the class of the dropdown we want to select
RenderedRemoteWebElement r =
(RenderedRemoteWebElement)driverFF.findElement(By.className("link2"));
Point p = r.getLocationOnScreenOnceScrolledIntoView();
Robot robot = new Robot();
robot.mouseMove(p.getX(), p.getY());

//Finds the class of the navigation panel
WebElement dropdownElement =
driverFF.findElement(By.className("mainNav"));

//Finds the ID of the link we want to click (in this case
'overview')

dropdownElement.findElement(By.id("a_cat_ourServices_overview")).click();

driverFF.quit();

Let me know if that helps.

Ryan Schroeder

unread,
Jun 1, 2011, 6:06:28 PM6/1/11
to Selenium Users
I tried several things and this was the only workaround that I could
get functioning.

WebDriver driverFF = new FirefoxDriver();
driverFF.manage().timeouts().implicitlyWait(3000,
TimeUnit.MILLISECONDS);
driverFF.get("https://www.pb.com/addressrightnow/");

//Get the tab we wish to mouse over
RenderedRemoteWebElement r =
(RenderedRemoteWebElement)driverFF.findElement(By.className("link2"));
Point p = r.getLocationOnScreenOnceScrolledIntoView();
Robot robot = new Robot();
robot.mouseMove(p.getX(), p.getY());

//Get the navigation toolbar element
WebElement dropdownElement =
driverFF.findElement(By.className("mainNav"));

//Get the element we wish to click in (in this case 'overview') from
the nav toolbar
dropdownElement.findElement(By.id("a_cat_ourServices_overview")).click();

driverFF.quit();


Let me know if this helps.
Reply all
Reply to author
Forward
0 new messages