Being new to PhantomJSDriver for Selenium, how does it handle JS alerts?
I've found the JSPhantom onAlert documentation, but what would the equivalent PhantomJSDriver code for
Driver.SwitchTo().Alert().Accept();
be?
At the moment, I've returning early with a guard clause for PhantomJSDriver
, to stop exceptions, but how should js alerts in PhantomJS be interacted with?
I don't think PhantomJS currently supports alert handling.
To simply accept alerts, (in Python/Splinter) try this for every reloaded page that would have an alert later.
See more reference here.
I had similar problems with PhantomJS Web Driver handling alerts. The below code seems to resolve the issue. This is a C# implementation but should work with Java too..
And later in the code where you expect Alerts to occur
For PhantomJS, we are setting the default response to Alerts as accept.