Wrong Submenu Selected

11 views
Skip to first unread message

flyflo...@gmail.com

unread,
Feb 1, 2018, 12:10:35 PM2/1/18
to Selenium Users

The web app I'm testing has a two-level left-side panel menu. I'm trying to select a sub-menu item. I had the code working:


CHIA_LIB_Selenium_Wait.UntilElementDisplayed(DriverObj, By.LinkText(m_MenuItems(0)))

LinkObj = DriverObj.FindElement(By.LinkText(m_MenuItems(0)))

DriverObj.Manage().Timeouts().ImplicitWait = New TimeSpan(0, 0, 60)

BuilderObj.MoveToElement(LinkObj).Build.Perform()

If m_MenuItems.Count = 2 Then
    If m_MenuItems(1) IsNot Nothing Then
        CHIA_LIB_Selenium_Wait.UntilElementDisplayed(DriverObj, By.LinkText(m_MenuItems(1)))
        LinkObj = DriverObj.FindElement(By.LinkText(m_MenuItems(1)))
        BuilderObj.MoveToElement(LinkObj, 5, 5).Click().Build.Perform()
    End If
End If
 

Now this code is finding and selecting another sub-menu item that is in the same position as the sub-menu item I want to select.

It's too hard to describe in words what's happening. Let's try a diagram. Suppose I want to select Sub1C. I find and move over Main1. The browser displays the Sub1A, Sub1B, and Sub1C menu items:


Main1 - Sub1A
Main2   Sub1B
Main3   Sub1C
 

The code finds and tries to click on Sub1C.

But what actually happens is the code moves the mouse to Main3 and selects and clicks on Sub3A menu item.


Main1
Main2
Main3 - Sub3A


If you overlap the two menus I showed above you'll see that Sub3A is positioned in the same location as the Sub1A menu item.

My environment:

Windows 7 64-bit

InternetExplorerDriver 3.8.0

Edge



Reply all
Reply to author
Forward
0 new messages