Skip to content

Commit 5d2dae9

Browse files
NaktibaldaDavertMik
authored andcommitted
[InnerBrowser] clickButton throws exception if button is outside form or link (#5478)
Fixes #5425
1 parent 390b7fb commit 5d2dae9

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed
Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
<html>
22
<body>
3+
34
<div>
4-
<button>The Button</button>
5+
<form action="/form/button" method="POST" id="form-id">
6+
<input type="hidden" name="text" value="val" />
7+
<button type="submit" name="btn0">Submit</button>
8+
</form>
9+
</div>
10+
11+
<div>
12+
<input type="submit" form="form-id" value="Submit 2" />
513
</div>
614
</body>
715
</html>

tests/unit/Codeception/Module/PhpBrowserTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22

3+
use Codeception\Exception\TestRuntimeException;
34
use Codeception\Util\Stub;
45

56
require_once 'tests/data/app/data.php';
@@ -604,9 +605,10 @@ public function testClickSelectsClickableElementFromMatchesUsingCssLocator()
604605

605606
public function testClickingOnButtonOutsideFormDoesNotCauseFatalError()
606607
{
607-
$this->expectException(AssertionFailedError::class);
608+
$this->expectException(TestRuntimeException::class);
609+
$this->expectExceptionMessage('Button is not inside a link or a form');
608610
$this->module->amOnPage('/form/button-not-in-form');
609-
$this->module->click('The Button');
611+
$this->module->click(['xpath' => '//input[@type="submit"][@form="form-id"]']);
610612
}
611613

612614
public function testSubmitFormWithoutEmptyOptionsInSelect()

0 commit comments

Comments
 (0)