Unable to click option in a mouse over drop-down menu

1,773 views
Skip to first unread message

Kiran S

unread,
Sep 23, 2011, 5:34:06 PM9/23/11
to seleniu...@googlegroups.com
Hi,

I have a drop-down menu which opens on mouse over. I need to click on 'Add Placement' option in that menu. I have tried most of the possibilities using css and xpath in selenium but unable to click on it. Ex: css=//div:contains("Add Placement"). Would you guide me to click on this?  I have attached the snapshot of the drop-down along with html representation. Please let me know if you need any other info.

Thanks,
Kiran
Dropdown.png

Hien Ngo

unread,
Sep 23, 2011, 6:24:24 PM9/23/11
to seleniu...@googlegroups.com
It may be something like this: //div[contains(text(),'Placement')]

--
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/-/OoFaXi6s9G0J.
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.

Kiran S

unread,
Sep 23, 2011, 6:45:22 PM9/23/11
to seleniu...@googlegroups.com
Hi Lerry,

Thanks for the quick response. I tried your code and unfortunately it didn't work for me. Sorry!

Kiran

vinod kumar

unread,
Sep 24, 2011, 12:42:16 AM9/24/11
to seleniu...@googlegroups.com
what error you get, after clicking + icon, did you place wait code before clicking on Add Placement


Kiran

--
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/-/iyfDJMB4W6cJ.

Kiran S

unread,
Sep 24, 2011, 7:29:46 AM9/24/11
to seleniu...@googlegroups.com
Hi Vinod - I am unable to click on + icon, if you could provide any code(based on the snapshot) I could try that and let you know the results Thanks.

Kiran S

unread,
Sep 24, 2011, 9:14:55 AM9/24/11
to seleniu...@googlegroups.com
vinod kumar ve....@gmail.com
sender-timeSent at 13:10 (GMT+05:30). Current time there: 6:42 PM. 
toksh...@gmail.com
dateSat, Sep 24, 2011 at 13:10
subjectRe: [selenium-users] Unable to click option in a mouse over drop-down menu
mailed-bygmail.com
signed-bygmail.com
Important mainly because of your interaction with messages in the conversation.
hide details 13:10 (1 hour ago)
To click on + icon...
try this

the code is my suggestion and hope it can work or it won't ....

# first focus on + icon
selenium.focus(+ icon)

# Now click on + icon
selenium.click("//div[@class='GKB2HVIDDH']/img") // + icon is image

2nd Solution

// Mouse over to + icon and click

Please let me know after trying this

Kiran S

unread,
Sep 24, 2011, 9:23:48 AM9/24/11
to seleniu...@googlegroups.com
Vinod - Thanks for the code. I tried your code but it didn't work. It is throwing - [error] locator not found: //div[@class='GKB2HVIDDH']/img

Kiran S

unread,
Sep 25, 2011, 7:52:03 AM9/25/11
to seleniu...@googlegroups.com
Could anyone please help me in resolving this issue? Thanks.

rdtx2005

unread,
Sep 25, 2011, 2:28:05 PM9/25/11
to Selenium Users
I would also like to know as well.

My issue is with a Menu that is built from JQuery and i'm using C#

Jim Arasim

unread,
Sep 25, 2011, 3:17:53 PM9/25/11
to Selenium Users
The problem is the menu item needs to be visible before being clicked.
Having JQUERY available is beneficial because the only solution I
found (Selenium IDE mouseover didn't translate to C#) involves
triggering the menu's top element .mouseover event with JQUERY (the
"+" sign in your case), then clicking the desired menu item ("Add
Placement").

1. Use Selenium's driver.FindElement(By.Id("idofplussign")) to assure
the top menu item is loaded and visible.
2. Use Selenium's driver.ExecuteScript("$
('#idofplussign').mouseover();") to hover over the top menu item
("+").
3. Here I needed to Thread.Sleep like 3 seconds to allow the menu to
appear...it all depends on how long it takes yours to appear; i.e. you
may not need to at all.
4. Now use Selenium's driver.FindElement(...).Click to click the menu
item.

Hope this helps.

-Jim

Kiran S

unread,
Sep 25, 2011, 4:55:46 PM9/25/11
to seleniu...@googlegroups.com
Great explanation, Jim! I did see the solution in your explanation if I move my scripts to selenium 2.0. Currently I am using selenium 1.0 to develop the scripts. If you could guide me in using the sele 1.0 commands in resolving the issue that would really great!

Kiran

Kiran S

unread,
Sep 28, 2011, 8:04:33 AM9/28/11
to seleniu...@googlegroups.com
Hi, 

Finally after several attempts I was able to hover on the menu and click the required option using mouseOver and click commands. Thanks to those who helped me!

cheers! 

rdtx2005

unread,
Sep 28, 2011, 10:52:45 AM9/28/11
to Selenium Users
could you paste the code snippet so that others in the future can
reference it?

thanks

eching

unread,
Sep 28, 2011, 11:07:33 AM9/28/11
to Selenium Users
Not to confuse the thread, but I was having the same issue interacting
with a dojo drop down menu and found using advanced interactions/key
presses worked great for me:

//displays the menu
driver.findElement(By.id("menu")).click();

Actions builder = new Actions(driver);
//select the second menu item (first is selected when menu appears)
Action action =
builder.sendKeys(Keys.ARROW_DOWN).sendKeys(Keys.ENTER);
action.perform();

Hope that helps someone....

Kiran S

unread,
Sep 28, 2011, 12:31:38 PM9/28/11
to seleniu...@googlegroups.com
Sure, Here is the code:

//Hover the menu first 
selenium.mouseOver("xpath=//div/div/img[@class='gwt-Image']");

//and click the option
selenium.click("xpath=//div[contains(text(),'Add Placement')]);

Refer snapshot for the div's

Reply all
Reply to author
Forward
0 new messages