I wish to click on ok button on alert in modal, but unable to click on it.
// Capturing alert message.
String alertMessage= driver.findElement(By.className("modal-header"))
.getText();
System.out.println(alertMessage);
String okButton= driver.findElement(By.xpath("//h4[contains(text(),'Woo Hoo! You have successfully registered! Look ou')]"))
.getText();
System.out.println(okButton);
driver.findElement(By.xpath("//button[contains(text(),'OK')]"))
.click();
Tried this code but it's not working.This is what I am getting in console
: unknown error: Element
<button type="button" class="close" ng-click="goTOLogin()">...</button>
is not clickable at point (897, 161). Other element would receive the click:<div class="loader" style="display: block; opacity: 0.681626;"></div>
This is the html code:
<div id="registration" class="modal fade ng-scope in" role="dialog" style="display: block;">
<div class="modal-dialog modal-md add-brand">
<!-- Modal content-->
<div class="modal-content flat-modal">
<div class="modal-header">
<button type="button" class="close" ng-click="goTOLogin()">X</button>
<h4 class="modal-title common-title" style="" xpath="1">successfully registered</h4>
</div>
<div class="modal-body flat-body">
<div class="clearfix"></div>
<h4>Woo Hoo! You have successfully registered! Look out for the activation link in your email.</h4>
<div class="modal-footer text-left">
<button type="button" class="close" ng-click="goTOLogin()" style="">OK</button>
</div>
</div>
</div>
</div>
</div>
You can press enter for accepting alerts.
Robot robot=new Robot();
robot.keyPress(KeyEvent.VK_ENTER);
robot.keyRelease(KeyEvent.VK_ENTER);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.