0

I am having two issues in clicking two buttons during my automation

First : A View button which have the following Details

<button class="veiw-btn" data-toggle="collapse" data-target=".toggle-content1" aria-expanded="false" aria-controls="toggle-content1" ng-click="gotoAnchor(flightResult.FlightId)">VIEW</button>

There are several VIEW buttons on the page but they are differentiated with the toggle-content (they have numbers 1,2,3,4) I just need to select the first one and click on it

Second :

After clicking the View i want to also click the Continue Button with the following code

<div class="text-center">
    <button class="flight-book-btn" type="button" ng-click="select(false, flightResult);">
     <span>Continue</span>
     </button>
</div>

My Major issue is the First Code but if i can get help with both i will be glad . I have not been able to click on the First VIEW Button

i have tried some samples online but they have not worked for me

I expect to be able to click the VIEW and Continue Buttons

CODE:

driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);     
log.debug("Fastest Sort Available "); 
log.debug("Now about to click VIEW Airline Details "); 
// driver.findElement(By.xpath("//button[text()='VIEW' and @data-target='.toggle-content1' and @aria-controls='toggle-content1']")).click();; 
driver.findElement(By.cssSelector("button[class=\"veiw-btn\"][data-target='.toggle-content1'']")).click();
Valga
  • 459
  • 2
  • 7
  • Please provide the code and/or errors, if you can. – suketup May 15 '19 at 14:51
  • driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS); log.debug("Fastest Sort Available "); log.debug("Now about to click VIEW Airline Details "); // driver.findElement(By.xpath("//button[text()='VIEW' and @data-target='.toggle-content1' and @aria-controls='toggle-content1']")).click();; driver.findElement(By.cssSelector("button[class=\"veiw-btn\"][data-target='.toggle-content1'']")).click(); – Adeyinka Alayo May 15 '19 at 16:11
  • use Action: [https://stackoverflow.com/questions/52811266/webdriverexception-element-is-not-clickable-in-selenium](https://stackoverflow.com/questions/52811266/webdriverexception-element-is-not-clickable-in-selenium) – nexoma May 15 '19 at 20:00

3 Answers3

0

Try using the css selector or Xpath

CSS:

driver.FindElement(By.CssSelector("button[class="veiw-btn"][data-target='.toggle-content1']").Click();

xpath:

driver.FindElement(By.XPath("//button[@class='veiw-btn'][@data-target='.toggle-content1']").Click();
Deepak
  • 13
  • 1
  • 4
  • I'm getting this error for the codes. Same error that its not clickable org.openqa.selenium.ElementClickInterceptedException: element click intercepted: Element is not clickable – Adeyinka Alayo May 15 '19 at 16:00
  • @Adeyinka Alayo give us the whole HTML page so we can figure out what is intercepting the click, or at least the whole section where the button is located – Valga May 15 '19 at 17:37
0

You can use this xpath to click on VIEW button :

//button[text()='VIEW' and @data-target='.toggle-content1' and @aria-controls='toggle-content1']

For clicking on Continue button you can try with this xpath :

//span[text()='Continue']/parent::button[@class='flight-book-btn']
cruisepandey
  • 28,520
  • 6
  • 20
  • 38
  • 'm getting this error for the codes. Same error that its not clickable org.openqa.selenium.ElementClickInterceptedException: element click intercepted: Element is not clickable – – Adeyinka Alayo May 15 '19 at 16:01
  • @AdeyinkaAlayo : Can you share your code, what did you try ? – cruisepandey May 15 '19 at 16:02
  • I have tried all the options stated for now and the error is that the View Button is not clickable whereas it is a try { driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS); log.debug("Fastest Sort Available "); log.debug("Now about to click VIEW Airline Details "); // driver.findElement(By.xpath("//button[text()='VIEW' and @data-target='.toggle-content1' and @aria-controls='toggle-content1']")).click();; driver.findElement(By.cssSelector("button[class=\"veiw-btn\"][data-target='.toggle-content1'']")).click(); – Adeyinka Alayo May 15 '19 at 16:10
-1

I have fixed this by using this

WebElement element= driver.findElement(By.xpath("//button[text()='VIEW' and @data-target='.toggle-content1' and @aria-controls='toggle-content1']"));
JavascriptExecutor executor = (JavascriptExecutor) driver; executor.executeScript("arguments[0].click();", element);