Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Selenium - Best practice to access an already opened menu ?

    In a Selenium test, we open a menu like this:
    Code:
            final By by = ByScLocator.scLocator(locatorValue);
        
            driver.waitForElementClickable(by);
            final WebElement webElement = driver.findElement(by);
            actions.click(webElement).perform();
    This works fine the 1st time.

    If we duplicate those lines, the 2nd call to waitForElementClickable() will hang because the menu is already opened and is not considered clickable.

    Is waitForElementClickable() the appropriate API call for menu availability (be it open or closed) ?

    Do we need to explicitly close the menu when we're done with it ? If so, what is the best practice ? (I'd not want to have to force a click action on a bogus element just to have the menu closed)

    Thanks !

    #2
    It seems like what you may mean is that a MenuButton is not clickable (because a Menu is up). Is that what you meant? Or perhaps a MenuBar?

    And are you sure that the Menu is not *occluding* the MenuButton or MenuBar? Because in that case, it's correctly not clickable - and this might happen if your Selenium is running in a browser that's sized too small (this is one reason the best practices recommend maximizing the browser).

    Comment


      #3
      Your reply made me realize that I was not specific enough in my previous post; sorry about that. Let me start over.

      In our app, we have a HLayout that contains MenuButton members. We do not use a MenuBar object.

      Here is what it looks like:


      The menu does not seem occluded.

      The browser is maximized.

      Do you need something more from my end ?

      Thanks !

      Attached Files

      Comment


        #4
        What's happening here is that the Menu has a "clickmask" up that allows it to be notified of clicks anywhere outside the Menu, so the Menu can dismiss itself. The presence of this mask is currently making other elements not clickable, when arguably they should be, since an end user could click them. We'll either change this behavior or introduce a setting you can use to ignore this kind of clickmask for clickability purposes.

        Either way, for this somewhat odd test (reopening an open menu isn't really something end users do...) you could get around this by just firing a click anywhere on the page, which will dismiss the menu.

        Comment


          #5
          I ended up forcing a click on a logo that is always there.

          Please keep me posted when you make the change or introduce a setting.

          Thanks !

          Comment


            #6
            We've made a change to address this issue. However, there is currently a problem with the build system, but we're working on it.

            Regards
            Isomorphic Software

            Comment

            Working...
            X