Skip to content

Commit 3cdfe72

Browse files
committed
verify that only one radio is selected scenario
1 parent f957e58 commit 3cdfe72

File tree

3 files changed

+57
-0
lines changed

3 files changed

+57
-0
lines changed

wdio-test/features/radio-features/radio.feature

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,20 @@ Feature: Letcode Radio Page
88
And I select one of the first radio options
99
Then I confirm that the first radio button is selected
1010

11+
Examples:
12+
| |
13+
| |
14+
15+
@regression @radio
16+
Scenario Outline: As a user, I can verify that only one radio option can be selected
17+
18+
Given I am on letcode workspace page
19+
When I click radio page
20+
And I select the first radio of the second radio automation challenge
21+
And I confirm that the second radio is not selected
22+
And I select the second radio of the second radio automation challenge
23+
And I confirm that the first radio is not selected
24+
1125
Examples:
1226
| |
1327
| |

wdio-test/page-objects/radio-pages/radio.page.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import Page from '../page.js';
33
class RadioPage extends Page {
44

55
get firstRadioOption(){ return $(`//input[@id='yes']`) };
6+
get radioOneOption(){ return $(`//input[@id='one']`) };
7+
get radioTwoOption(){ return $(`//input[@id='two']`) };
68

79
//1. select one radio option
810
async selectFirstRadio(){
@@ -14,7 +16,31 @@ class RadioPage extends Page {
1416
const elmFirstRadioOption = await this.firstRadioOption;
1517
const radioStatus = await elmFirstRadioOption.isSelected();
1618
console.log('First Radio Status: ' + radioStatus);
19+
}
20+
21+
//2. verify that only one radio is selected
22+
async selectRadioOne(){
23+
const elmRadioOneOption = await this.radioOneOption;
24+
await this.click(elmRadioOneOption);
25+
}
26+
27+
async verifyRadioOne(){
28+
const elmRadioOneOption = await this.radioOneOption;
29+
const elmRadioTwoOption = await this.radioTwoOption;
30+
await expect(elmRadioOneOption).toBeSelected();
31+
await expect(elmRadioTwoOption).not.toBeSelected();
32+
}
33+
34+
async selectRadioTwo(){
35+
const elmRadioTwoOption = await this.radioTwoOption;
36+
await this.click(elmRadioTwoOption);
37+
}
1738

39+
async verifyRadioTwo(){
40+
const elmRadioOneOption = await this.radioOneOption;
41+
const elmRadioTwoOption = await this.radioTwoOption;
42+
await expect(elmRadioTwoOption).toBeSelected();
43+
await expect(elmRadioOneOption).not.toBeSelected();
1844
}
1945

2046
}

wdio-test/step-definitions/radio-steps/radio.step.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,20 @@ When(/^I select one of the first radio options$/, async () => {
99
Then(/^I confirm that the first radio button is selected$/, async () => {
1010
await RadioPage.verifySelectedFirstRadio();
1111
});
12+
13+
//2. verify that only one radio is selected
14+
When(/^I select the first radio of the second radio automation challenge$/, async () => {
15+
await RadioPage.selectRadioOne();
16+
});
17+
18+
When(/^I confirm that the second radio is not selected$/, async () => {
19+
await RadioPage.verifyRadioOne();
20+
});
21+
22+
When(/^I select the second radio of the second radio automation challenge$/, async () => {
23+
await RadioPage.selectRadioTwo();
24+
});
25+
26+
When(/^I confirm that the first radio is not selected$/, async () => {
27+
await RadioPage.verifyRadioTwo();
28+
});

0 commit comments

Comments
 (0)