Selenium: How to click an HTML button element?
Posted
by Andrew
on Stack Overflow
See other posts from Stack Overflow
or by Andrew
Published on 2010-05-12T20:37:13Z
Indexed on
2010/05/12
21:04 UTC
Read the original article
Hit count: 229
I have button on the page that being used as a link to another page. So when the user clicks the button they are redirected to the right page.
I am using the Selenium extension for PHPUnit and I would like to test that the button is correctly redirecting the user. Here is the HTML that I am trying to test:
<button onclick="window.location='/sponsor';" value="Continue" type="button" id="sponsorContinue" name="sponsorContinue">Continue</button>
I have tried a lot of different approaches to click the button, but I can't seem to get any of them to work:
$this->click("//button[@id='sponsorContinue']");
This command executes and does not throw any errors, but the page isn't redirected. It works fine when I manually click the button. What should I do?
© Stack Overflow or respective owner