I have a button (outside of a form) that redirects to another page using the onclick
attribute that calls window.location
to redirect the user to another page. This time I can't change the HTML. I am using Safari 4 for testing. How can I click a button that uses the onclick
attribute and window.location
to redirect using Safari 4 and Selenium RC PHPUnit Extension?
Here's my HTML:
<input type="button" onclick="window.location='/registrations/new'" value="Start a new registration" id="create">
Update: Alternatively, I'm thinking about doing something where I assert that a location is specified in the window.location=''
, store that location, and call the open()
command using that location. Not sure if this is an acceptable approach to testing this.
This should work, however you could also try firing the click event using the
fireEvent
command.We decided to extend the default
clickAndWait()
functionality to callopenAndWait()
if the button has anonclick="window.location='/something';"