0

I have to verify if a button is adjacent to a textarea using java , selenium IDE.

The textarea and the button are seperated by a spacing ( this is also included in the xpath). As far as what i have done is to just check if the text is present.

Boolean element_button = driver.findElements(By.Xpath("//...").size()!=0;

Similar for text area.But how is it possible to verify if they are adjacent.

Krish Krishna
  • 317
  • 3
  • 15
  • 2
    Show relevant part of the HTML (includes the button and the textarea) – har07 Aug 14 '15 at 10:51
  • get the [parent element[(http://stackoverflow.com/questions/9021074/how-to-find-all-parent-elements-using-selenium-c-sharp-webdriver) of each and compare – lloyd Aug 14 '15 at 10:57

1 Answers1

1

You can try something like this:

  1. Compare the Parent element of both the elements.
  2. You can compare the y co-ordinate using webElement1.getLocation().y for both the button and textarea , this should be same for both.
  3. Then you can compare the difference between the x co-ordinate using webElement2.getLocation().x for both elements and compare it with the width of first webelement and little space if it's there .
prab2112
  • 1,024
  • 10
  • 36