My application is Angular JS and we are using Highcharts. I am trying to click close button on popup and I have the correct xpath, both relative and absolute which finds the correct element.
When I check it manually, but when I run from Selenium with Java and it does not click it. It does not throw any error as well. I also tried with Javascript and it is not clicking, but again when I execute JavaScript manually from console it works.
Selenium Version : 3.141.59
Button:
Console:
HTML Snippet :
<button type="button" style="float:right" class="btn btnclose " data-dismiss="modal" aria-hidden="true">
<i class="fa fa-2x fa-times-circle">
</i></button>
Code:
document.getElementsByClassName('btn btnclose ')[1].click()
public static void clickByJS(WebDriver driver){
JavascriptExecutor js = (JavascriptExecutor)driver;
driver.switchTo().activeElement();
js.executeScript("document.getElementsByClassName('btn btnclose ')[1].click()");
}
Note : I checked with other elements of the pop-up as well and I can verify the xpath works and finds the element when I tried in browser manually, but with Selenium does not click. It is not page load issue as I have tried with multiple explicit waits and not much luck. For some reason the element is not visible/intractable.