UNPKG

2.98 kBMarkdownView Raw
1* ["\_\_\_" should appear in the "\_\_\_" drop down list]("\_\_\_"-should-appear-in-the-"\_\_\_"-drop-down-list)
2 * [regex](regex)
3 * [execution](execution)
4 * [with the "should" expectation](with-the-"should"-expectation)
5 * [with the "should not" expectation](with-the-"should-not"-expectation)
6 * [timing](timing)
7# "\_\_\_" should appear in the "\_\_\_" drop down list
8## regex
9 regex should match "...should appear..."
10
11```
12verifyStepMatch('"Mountain Time" should appear in the "Time Zone" drop down list');
13```
14
15
16 regex should match "...should not appear..."
17
18```
19verifyStepMatch('"Mountain Time" should not appear in the "Time Zone" drop down list');
20```
21
22
23 regex should capture the option text, expectation, element type, and drop down list name
24
25```
26verifyStepCaptures('"Mountain Time" should appear in the "Time Zone" drop down list', 'should', 'Mountain Time', 'Time Zone', ' drop down list');
27```
28
29
30 regex should capture the option text, expectation, drop down list name, and a blank string if no element type is provided
31
32```
33verifyStepCaptures('"Mountain Time" should appear in the "Time Zone Drop Down List"', 'should', 'Mountain Time', 'Time Zone Drop Down List', '');
34```
35
36
37## execution
38### with the "should" expectation
39 with the "should" expectation should succeed if the expected option is in the drop down list
40
41```
42return executeStep('"Mountain Standard" should appear in the "Time Zone" drop down list', function() {
43 expect(currentStepResult.status).to.equal(Cucumber.Status.PASSED);
44});
45```
46
47
48 with the "should" expectation should fail if the expected option is not in the drop down list
49
50```
51return executeStep('"Pacific Standard" should appear in the "Time Zone" drop down list', function() {
52 expect(currentStepResult.status).to.equal(Cucumber.Status.FAILED);
53});
54```
55
56
57### with the "should not" expectation
58 with the "should not" expectation should fail if the expected option is in the drop down list
59
60```
61return executeStep('"Mountain Standard" should not appear in the "Time Zone" drop down list', function() {
62 expect(currentStepResult.status).to.equal(Cucumber.Status.FAILED);
63});
64```
65
66
67 with the "should not" expectation should succeed if the expected option is not in the drop down list
68
69```
70return executeStep('"Pacific Standard" should not appear in the "Time Zone" drop down list', function() {
71 expect(currentStepResult.status).to.equal(Cucumber.Status.PASSED);
72});
73```
74
75
76## timing
77 timing should wait for the drop down list to be present before verifying
78
79```
80return browser.driver.executeScript("setTimeout( function() { $('div#test').append(' <select id=\"timezone\"> <option selected>Eastern Standard</option> <option>Mountain Standard</option> <option>Central Standard</option> </select>'); }, 200 )").then(() => {
81 return executeStep('"Mountain Standard" should appear in the "Time Zone" drop down list', function() {
82 expect(currentStepResult.status).to.equal(Cucumber.Status.PASSED);
83 });
84});
85```