Using the Ruby client ( @selenium- my object SeleniumDriver):
To check if any element is above another div:
@selenium.get_element_position_top("firstdiv") <
@selenium.get_element_position_top("seconddiv")
To check if any element remains to another div:
@selenium.get_element_position_left("firstdiv") <
@selenium.get_element_position_left("seconddiv")
If you also want to check that the elements do not overlap, compare the top of the element with the bottom of the other:
@selenium.get_element_position_top("firstdiv") +
@selenium.get_element_height("firstdiv") <
@selenium.get_element_position_top("seconddiv")
source
share