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.
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.
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.