dropdown functionality not working in selenium webdriver

Answered

I asked a similar question the other day, but have now got stuck at a later stage…..

I have an issue when attempting to click on an element from a drop-down menu, when running a test in Selenium. So, as per the below screenshot, I am hovering over ‘Reports’, then ‘Asset Management’, then ‘Terminated Report: Pending’. Clicking on the ‘Terminated Report: Pending’ option should take me to the appropriate page (screenshot below)
dropdown functionality not working in selenium webdriver

I’ve written the following code in WebDriver to do this:
dropdown functionality not working in selenium webdriver

I didn’t see any issues with this, given that I had used similar code in order to access the ‘Terminated Report: Pending’ page. However, for some reason when I run the test, whilst the browser initially focuses on the element I want, it then loses focus and drops down to the ‘Collections’ drop down and selects a page with a completely different href to the one I selected in the code. Can anyone help as to what the reason might be? Many thanks

tilston1001 Train Asked on November 27, 2014 in Selenium WebDriver.

Hi
Might Possible That Collections ‘s Href Contains the same Keyword  as  it is Clicking Some Other Element

on November 27, 2014.

Hi ANkit, thanks for the response. I thought the same but even when I change the xpath to ‘GetTerminatedPending’ instead of ‘GetTerminatedPendingReport’, it still jumps to the ‘GetBreachPendingReport’ page

on November 27, 2014.
Add Comment
2 Answer(s)
Best answer

Hi Andrew,

Please try this with another browser as well and see if the behaviour is same or not. And I hope that you are using build().perform() on Assesr Management List.

Regards,
Lakshay Sharma

xLov3rDns Professor Answered on November 27, 2014.

Hi Laksh, yep I am using build().perform() on the Asset Management list

on November 27, 2014.

Andy,

Try one more thing, first mouse hover on Asset Management, then mouse hover on Terminate Report : Pending and then click on Terminate Report Pending. I am assuming that when Selenium goes to click on Terminate Report, it loses it focus, as the moment you move your mouse away from Asset Management the list goes off.

Regards,
Lakshay Sharma

on November 28, 2014.

Thanks for the response Laksh. NO joy, I’m afraid. It still loses focus and goes to another drop-down option from the list.

on December 1, 2014.

Hi Laksh, I’ve managed to fix the issue! I’ve put the code in above entitled ‘Fix – 1/12/14′. Is ‘sendKeys’ OK to use in this scenario, are there any pitfalls you can see?   public static void terminatedReportPendingFocus(InternetExplorerDriver driver) { driver.findElement(By.xpath(“//a[contains(text(),’Terminated Report: Completed’)]”)).sendKeys(Keys.ENTER); }

on December 1, 2014.

Perfect Andy, no these are just the few limitations of the Selenium that for few complexly designed applications it behaves wierdly. But that is how we over the situation, please close your answer as well.

Cheers,
Lakshay Sharma

on December 2, 2014.

Cheers Laksh, I’ll close the answer off

on December 2, 2014.
Add Comment

See answer above for details as to how this was resolved

tilston1001 Train Answered on December 2, 2014.

Your Answer

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