0

I am trying automation test on following website - http://www.arzoo.com when we search flight, I am unable to click select on particular flight. I used Xpath but it doesn't get the element if it's at bottom or middle of the page so then I need to use:

JavascriptExecutor jsx2 = (JavascriptExecutor)driver;
jsx2.executeScript("window.scrollBy(0,750)", "");

driver.findElements(By.xpath("//a[text()='Select']")).get(15).click();

but I don't want to use scroll to position. different screens will need different sizes.

I planned to use css sector but still no success.

Rick
  • 1,177
  • 1
  • 19
  • 27
man_13oct
  • 1
  • 1

2 Answers2

0

Wrap the below code inside executeScript()

let allSelectButtons = document.querySelectorAll(".booking-item-flight-details .booking-item-arrival a");

for(i=0;i<allSelectButtons.length;i++) {
   allSelectButtons[i].click();
 }
Rajkumar Somasundaram
  • 1,225
  • 2
  • 10
  • 20
0

Try the following xpath:

driver.findElement(By.xpath("//a[contains(@class, 'btn-primary')]")).click();

if not, try

driver.findElement(By.xpath("//li[contains(@id, 'result_0')]/div/div/div/div[2]/a")).click();

See the following for reference:

Danny
  • 287
  • 2
  • 15