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,
Does AutoTest provide something comparable?
Thank you
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"; }
Thank you
Comment