Working with automated testing, I have come across the following issue quite a lot of time: I want to find an element on the page, but the element has to be at a specific region of the page.
Take the following as an example: I have a searchfield with type-ahead on the site. In my sidebar, I have the element I am seraching for (lets call it "Selenium"), but that is not the element I am interested in, I want to see if my type-ahead search is delivering the expected result when searching for "Selenium".
<body>
<header>
<searchfield>
<searchresults>
<a .... >Selenium</a>
<searchresults>
</searchfield>
</header>
<aside>
...
<a .... >Selenium</a>
...
</aside>
</body>
If I in selenium webdriver search for the linktext "Selenium" it will find both entries, the one in the sidebar aswell as the one in the searchfield.
Furthermore am I not able to wait for the searchresult with the WaitForVisible
command on the linkText as Selenium will find the element in the sidebar and conclude that the element is preset.
So my question is: "With selenium webdriver, how do I search for an element within a specific region?"