Pop up handling through PhantomJs in Java

2019-09-11 14:58发布

问题:

Hi, I have a html page as below and i need to handle pop up generated in it in phantomjs using java code.Please provide the solution code.

<html> 
<body> 

Card Number: 
<br> 
<input type="text" name="Card Number" value=""> 
<br> 
Card Holder Name: 
<br> 
<input type="text" name="Card Holder Name" value=""> 
<br><br> 
CVV: 
<br> 
<input type="text" name="CVV" value=""> 
<br> 
<br> 
<input type="button" value="proceed" onclick="myFunction()"> 

<script> 
function myFunction() { 
var x; 
if (confirm("Would you like to proceed payment!") == true) { 
x = "You pressed OK!"; 
} else { 
x = "You pressed Cancel!"; 
} 
document.getElementById("demo").innerHTML = x; 
} 
</script> 



</body> 
</html>

I tried with Unable to handle alert using phantomJS in Java and Github https://github.com/detro/ghostdriver/issues/500 but it is not fruitful.