I am trying to click a "Save" button in a pop window using Java Selenium Webdriver, however it throws an exception
Message:Element is not currently visible and so may not be interacted with Command duration
I am able to see the "Save" button active in my pop window. I could not figure out the reason why it throws an exception.
HTML CODE for the Save button that I am trying to click,
</div>
<br>
<br>
<br>
<hr>
<button class="btn btn-primary" style="margin-left: 10px" ng-click="saveData()" data-dismiss="modal" type="button">Save</button>
<button id="buttonmodalcancel" class="btn btn-default" ng-click="cancel()" type="button">Cancel</button>
</div>
firepath: html/body/div[6]/div/div/div[2]/div/div/button[1].
I did not use the XPath as the contents after html/body/div, keeps changing.
Java code that I used:
driver().manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver().findElementByXPath("//*[contains(text(), 'Save')]").click();