New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Any way to press a <button> instead of <input type=submit> #96
Comments
Could try popping an ID onto the button and using the $this->click('#buttonID') |
Seems like this is a duplicate of #85 @joedawson |
@alfredbez that's not correct, as per the docs - I've also been using it this week :)
|
@joedawson
Or like you already said:
This is not a link or an anchor tag: <button type="submit">Submit This</button> and from here:
From the docs
Please take also a look at the |
Looks like the I tried it, but I see the following error:
Selenium Error:
PHP-Code: $this->visit('/siteWithButton')->click('#buttonId'); It works as expected when I swap the lines 91 and 93 or when I use the following code in my test: $this->visit('/siteWithButton')->findByNameOrId('#buttonId')->click(); |
I came up with the following solution: I created an abstract Test Class which extends the Selenium Extension Class. It looks like this: <?php
use Laracasts\Integrated\Extensions\Selenium as IntegrationTest;
abstract class AbstractSeleniumTest extends IntegrationTest {
protected function findByCssSelector($selector)
{
try {
return $this->session->element('css selector', $selector);
} catch (NoSuchElement $e) {
throw new InvalidArgumentException(
"Couldn't find an element, matching the follwing css selector: '{$seletor}'."
);
}
}
public function clickCss($selector)
{
$this->findByCssSelector($selector)->click();
return $this;
}
} It gives me a more flexible way to click on elements, e.g. $this->clickCss("#someElement + button"); <div id="someElement">an Element</div>
<button>I have no ID and name!</button> |
Any way to "press" a button , doesn't seem to work.
Html
Error:
The text was updated successfully, but these errors were encountered: