views:

70

answers:

1

I want to check the layout of the page. Something pretty simple - that a certain div is displayed above/below/left/right of another div

Is it possible to do this kind of stuff?

+1  A: 

Using the Ruby client (@selenium is my SeleniumDriver object):

To check if a certain element is above another div:

@selenium.get_element_position_top("firstdiv") <
  @selenium.get_element_position_top("seconddiv")

To check if a certain element is left to another div:

@selenium.get_element_position_left("firstdiv") <
  @selenium.get_element_position_left("seconddiv")

If you also want to check that the elements don't overlap, compare the top of the element to the bottom of the other:

@selenium.get_element_position_top("firstdiv") + 
  @selenium.get_element_height("firstdiv") <
  @selenium.get_element_position_top("seconddiv")
Scharrels
does this work across browsers (by which I really mean 'Does this work in IE6')?
Rodreegez