0

I'm trying to verify that an element exists on a page next to another element. I'm using Selenium WebDriver with Python bindings, but can't figure out how to do this.

2
  • 1
    Can you post the HTML please?
    – FDM
    Commented Jul 6, 2015 at 8:04
  • 2
    For clarification, do you really want to know whether they are next to each other on the rendered page, or just whether they are adjacent in the DOM?
    – user246
    Commented Jul 6, 2015 at 12:02

2 Answers 2

2

Try out Galen; it's designed for testing responsive web design across different platforms and different sized viewports, so its all about how web elements are laid out on screen:

Layout testing seemed always a complex task. Galen Framework offers a simple solution: test location of objects relatively to each other on page. Using a special syntax and comprehensive rules you can describe any layout you can imagine.

0

Every WebElement has a getLocation() method. You can get X and Y of the first element, then get X and Y of another element. After that just compare them to check which element is going first, and which is going next.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.