Announcement

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

    Is there a way to check if element is behind another element with AutoTest

    Hi Isomorphic,

    We are trying to find a smart/efficient way to check if the element we want to click is not behind another element, say for example a button on a form is covered up because a com.smartgwt.client.widgets.Window is opened (or moved) over top of the button.

    Currently, we are using is_displayed() method (https://selenium-python.readthedocs....t.is_displayed) from the selenium web driver. This method checks whether the element is visible to the user. It checks; element is visible by CSS, width and height are bigger than 0, style is not hidden, opacity is greater than 0 and the element is in viewport. It doesn’t check if the element is behind another element. We also use isElementClickable() function from AutoTest, but it also does not check if the element is visible or not.

    To really be sure that we can click on an element, there is a function called document.elementFromPoint (https://developer.mozilla.org/en-US/...ementFromPoint) to return the element, with highest zIndex at a given position. If the element we want to click is different from the element returned from elementFromPoint, then it means that there is another element in front of the requested element.

    For example,

    Code:
    m1 = isc.AutoTest.getElement('scLocator=.....');
    m1.scrollIntoView();
    rec = m1.getBoundingClientRect();
    top_element = document.elementFromPoint(rec.left + 0.5 * rec.width, rec.top + 0.5 * rec.height);
    if (m1 == top_element || m1.contains(top_element)) {
        "You can click";
    } else {
       "You can NOT click";
    }
    Does AutoTest provide something comparable?

    Thank you

    #2
    Can you explain why you need this? If you're repositioning widgets by probing for occlusion, perhaps a better approach would be to manage their position directly.

    Comment


      #3
      Hi Isomorphic,

      We have an application console that can display a message and fade-out automatically. The location and fade-out are both configurable by the end user.

      We already worked around this in our automation suite, however, we wanted to reach out and confirm if we missed something in AutoTest that might have accounted for this.

      Based on the follow-up, I assume that is not the case.

      Thank you

      Comment


        #4
        Our test suite actually takes the approach that if you try to click on a partially occluded element we find a place where it's not occluded, to make scripts more robust over time.

        We're not really clear how another behavior would be more useful - are you trying to figure out whether something like a notification has been occluded by another element, so isn't visible?

        Comment


          #5
          For example, a form is opened with a button that is clickable, but might be temporarily occluded by the console in a particular use case, and we would like to wait until the button is no longer occluded. We've handled this, however, we wondered if there was an API like isElementClickable that didn't return true while the button was occluded.

          Comment


            #6
            For some context, occluded elements were considered clickable and in fact could be clicked in Selenium 2.x, hence the behavior of the API.

            Still don't quite get the use case, as presumably if the button were occluded the next thing to do in the script would be take some action with the dialog, or if the dialog were auto-dismissing, there would be something else to wait for. But yes, if you are somehow cornered and need to specifically do an occlusion check, you'd want to combine isElementClickable() with some kind of strict occlusion check along the lines of what you showed.

            Comment


              #7
              Thank you

              Comment

              Working...
              X