Skip to content
This repository was archived by the owner on Mar 4, 2020. It is now read-only.

Commit e8accbd

Browse files
committed
Extend testcases to cover also form without id
1 parent 87f9d0f commit e8accbd

File tree

3 files changed

+32
-2
lines changed

3 files changed

+32
-2
lines changed

tests/functional/WebDriverCheckboxesTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,15 @@ public function testShouldGetFirstSelectedOptionConsideringOnlyElementsAssociate
6868
$this->assertEquals('j5b', $checkboxes->getFirstSelectedOption()->getAttribute('value'));
6969
}
7070

71+
public function testShouldGetFirstSelectedOptionConsideringOnlyElementsAssociatedWithCurrentFormWithoutId()
72+
{
73+
$checkboxes = new WebDriverCheckboxes(
74+
$this->driver->findElement(WebDriverBy::xpath('//input[@id="j5d"]'))
75+
);
76+
77+
$this->assertEquals('j5c', $checkboxes->getFirstSelectedOption()->getAttribute('value'));
78+
}
79+
7180
public function testSelectByValue()
7281
{
7382
$selectedOptions = ['j2b', 'j2c'];

tests/functional/WebDriverRadiosTest.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,18 @@ public function testGetFirstSelectedOption()
6060

6161
public function testShouldGetFirstSelectedOptionConsideringOnlyElementsAssociatedWithCurrentForm()
6262
{
63-
$radio = new WebDriverRadios($this->driver->findElement(WebDriverBy::xpath('//input[@id="j4b"]')));
63+
$radios = new WebDriverRadios($this->driver->findElement(WebDriverBy::xpath('//input[@id="j4b"]')));
6464

65-
$this->assertEquals('j4b', $radio->getFirstSelectedOption()->getAttribute('value'));
65+
$this->assertEquals('j4b', $radios->getFirstSelectedOption()->getAttribute('value'));
66+
}
67+
68+
public function testShouldGetFirstSelectedOptionConsideringOnlyElementsAssociatedWithCurrentFormWithoutId()
69+
{
70+
$radios = new WebDriverRadios(
71+
$this->driver->findElement(WebDriverBy::xpath('//input[@id="j4c"]'))
72+
);
73+
74+
$this->assertEquals('j4c', $radios->getFirstSelectedOption()->getAttribute('value'));
6675
}
6776

6877
public function testSelectByValue()

tests/functional/web/form_checkbox_radio.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,17 @@
5353
<form id="another-form">
5454
<input type="checkbox" name="single-cb">
5555
</form>
56+
57+
<!-- Form without id -->
58+
<form>
59+
<label for="j5c">J5C</label>
60+
<input type="checkbox" name="j5" value="j5c" id="j5c" checked/>
61+
<label for="j5d">J5D</label>
62+
<input type="checkbox" name="j5" value="j5d" id="j5d" checked/>
63+
64+
<label for="j4c">J4C</label>
65+
<input type="radio" name="j4" value="j4c" id="j4c" checked>
66+
</form>
67+
5668
</body>
5769
</html>

0 commit comments

Comments
 (0)