Hi, I'm trying to test a page that has a javascript prompt popup. I've read the topic
https://groups.google.com/forum/#!topic/behat/Cc6OcObVWnE and I'm utilising the code by benjamin lazarecki (
https://gist.github.com/2888851)
The scenario is as follows
features/behat/behat-test-window-alert.feature
Feature: For other tests to work, Behat must be able to type into a popup
@behat
Background:
Given I am logged in as the test user
@javascript
Scenario: Open and switch to a new window
When I go to "/utils/subwindowwithpassword"
When I press "Enter"
And I wait 5 seconds
Then I should see "Please enter your password" in popup
When I fill "1234" in popup
And I confirm the popup
Then I should see "You're in!"
The javascript is as follows:
var message = "no message";
function enter() {
var pass = prompt("Please enter your password","type here");
if ( pass == "1234") {
message = "You're in!";
} else {
message = "Go away!";
}
var elem = document.getElementById("message");
elem.innerHTML = message;
}
All the steps 'work' (show in green) except the last one. The popup flashes up and disappears, too quick to see if the "1234" goes in. Any attempt to $this->getSession()->wait(5000); will complain about a modal dialog ad fail straight away. If in the javascript I say if ( pass == "type here") then the last step passes.
Is anyone getting this sort of scenario to work?