@@ -30,7 +30,7 @@ LoadableComponentは、PageObjectsの作成の負担を軽減することを目
30
30
31
31
### 簡単な使用方法
32
32
33
- モデル化するUIの例として、[ 新しいissue] ( https://github.com/SeleniumHQ/selenium/issues/new ) のページをご覧ください。
33
+ モデル化するUIの例として、[ 新しいissue] ( https://github.com/SeleniumHQ/selenium/issues/new?assignees=&labels=I-defect%2Cneeds-triaging&projects=&template=bug-report.yml&title=%5B%F0%9F%90%9B+Bug%5D%3A+ ) のページをご覧ください。
34
34
テスト作成者の観点から、これは新しい問題を提出できるサービスを提供します。
35
35
基本的なページオブジェクトは次のようになります。
36
36
@@ -49,18 +49,53 @@ public class EditIssue {
49
49
this . driver = driver;
50
50
}
51
51
52
- public void setSummary (String summary ) {
53
- WebElement field = driver. findElement(By . name( " summary " ));
54
- clearAndType(field, summary );
52
+ public void setTitle (String title ) {
53
+ WebElement field = driver. findElement(By . id( " issue_title " ) ));
54
+ clearAndType(field, title );
55
55
}
56
56
57
- public void enterDescription (String description ) {
58
- WebElement field = driver. findElement(By . name(" comment" ));
59
- clearAndType(field, description);
57
+ public void setBody (String body ) {
58
+ WebElement field = driver. findElement(By . id(" issue_body" ));
59
+ clearAndType(field, body);
60
+ }
61
+
62
+ public void setHowToReproduce (String howToReproduce ) {
63
+ WebElement field = driver. findElement(By . id(" issue_form_repro-command" ));
64
+ clearAndType(field, howToReproduce);
65
+ }
66
+
67
+ public void setLogOutput (String logOutput ) {
68
+ WebElement field = driver. findElement(By . id(" issue_form_logs" ));
69
+ clearAndType(field, logOutput);
70
+ }
71
+
72
+ public void setOperatingSystem (String operatingSystem ) {
73
+ WebElement field = driver. findElement(By . id(" issue_form_operating-system" ));
74
+ clearAndType(field, operatingSystem);
75
+ }
76
+
77
+ public void setSeleniumVersion (String seleniumVersion ) {
78
+ WebElement field = driver. findElement(By . id(" issue_form_selenium-version" ));
79
+ clearAndType(field, logOutput);
80
+ }
81
+
82
+ public void setBrowserVersion (String browserVersion ) {
83
+ WebElement field = driver. findElement(By . id(" issue_form_browser-versions" ));
84
+ clearAndType(field, browserVersion);
85
+ }
86
+
87
+ public void setDriverVersion (String driverVersion ) {
88
+ WebElement field = driver. findElement(By . id(" issue_form_browser-driver-versions" ));
89
+ clearAndType(field, driverVersion);
90
+ }
91
+
92
+ public void setUsingGrid (String usingGrid ) {
93
+ WebElement field = driver. findElement(By . id(" issue_form_selenium-grid-version" ));
94
+ clearAndType(field, usingGrid);
60
95
}
61
96
62
97
public IssueList submit () {
63
- driver. findElement(By . id( " submit" )). click();
98
+ driver. findElement(By . cssSelector( " button[type=' submit'] " )). click();
64
99
return new IssueList (driver);
65
100
}
66
101
@@ -86,7 +121,7 @@ public class EditIssue extends LoadableComponent<EditIssue> {
86
121
``` java
87
122
@Override
88
123
protected void load() {
89
- driver. get(" https://github.com/SeleniumHQ/selenium/issues/new" );
124
+ driver. get(" https://github.com/SeleniumHQ/selenium/issues/new?assignees=&labels=I-defect%2Cneeds-triaging&projects=&template=bug-report.yml&title=%5B%F0%9F%90%9B+Bug%5D%3A+ " );
90
125
}
91
126
92
127
@Override
@@ -118,16 +153,13 @@ public class EditIssue extends LoadableComponent<EditIssue> {
118
153
private final WebDriver driver;
119
154
120
155
// By default the PageFactory will locate elements with the same name or id
121
- // as the field. Since the summary element has a name attribute of "summary "
156
+ // as the field. Since the issue_title element has an id attribute of "issue_title "
122
157
// we don't need any additional annotations.
123
- private WebElement summary ;
158
+ private WebElement issue_title ;
124
159
125
- // Same with the submit element, which has the ID "submit"
126
- private WebElement submit;
127
-
128
- // But we'd prefer a different name in our code than "comment", so we use the
160
+ // But we'd prefer a different name in our code than "issue_body", so we use the
129
161
// FindBy annotation to tell the PageFactory how to locate the element.
130
- @FindBy (name = " comment " ) private WebElement description ;
162
+ @FindBy (id = " issue_body " ) private WebElement body ;
131
163
132
164
public EditIssue (WebDriver driver ) {
133
165
this . driver = driver;
@@ -138,25 +170,52 @@ public class EditIssue extends LoadableComponent<EditIssue> {
138
170
139
171
@Override
140
172
protected void load () {
141
- driver. get(" https://github.com/SeleniumHQ/selenium/issues/new" );
173
+ driver. get(" https://github.com/SeleniumHQ/selenium/issues/new?assignees=&labels=I-defect%2Cneeds-triaging&projects=&template=bug-report.yml&title=%5B%F0%9F%90%9B+Bug%5D%3A+ " );
142
174
}
143
175
144
176
@Override
145
177
protected void isLoaded () throws Error {
146
178
String url = driver. getCurrentUrl();
147
179
assertTrue(" Not on the issue entry page: " + url, url. endsWith(" /new" ));
148
180
}
149
-
150
- public void setSummary (String issueSummary ) {
151
- clearAndType(summary, issueSummary);
181
+
182
+ public void setHowToReproduce (String howToReproduce ) {
183
+ WebElement field = driver. findElement(By . id(" issue_form_repro-command" ));
184
+ clearAndType(field, howToReproduce);
185
+ }
186
+
187
+ public void setLogOutput (String logOutput ) {
188
+ WebElement field = driver. findElement(By . id(" issue_form_logs" ));
189
+ clearAndType(field, logOutput);
190
+ }
191
+
192
+ public void setOperatingSystem (String operatingSystem ) {
193
+ WebElement field = driver. findElement(By . id(" issue_form_operating-system" ));
194
+ clearAndType(field, operatingSystem);
195
+ }
196
+
197
+ public void setSeleniumVersion (String seleniumVersion ) {
198
+ WebElement field = driver. findElement(By . id(" issue_form_selenium-version" ));
199
+ clearAndType(field, logOutput);
200
+ }
201
+
202
+ public void setBrowserVersion (String browserVersion ) {
203
+ WebElement field = driver. findElement(By . id(" issue_form_browser-versions" ));
204
+ clearAndType(field, browserVersion);
205
+ }
206
+
207
+ public void setDriverVersion (String driverVersion ) {
208
+ WebElement field = driver. findElement(By . id(" issue_form_browser-driver-versions" ));
209
+ clearAndType(field, driverVersion);
152
210
}
153
211
154
- public void enterDescription (String issueDescription ) {
155
- clearAndType(description, issueDescription);
212
+ public void setUsingGrid (String usingGrid ) {
213
+ WebElement field = driver. findElement(By . id(" issue_form_selenium-grid-version" ));
214
+ clearAndType(field, usingGrid);
156
215
}
157
216
158
217
public IssueList submit () {
159
- submit. click();
218
+ driver . findElement( By . cssSelector( " button[type=' submit'] " )) . click();
160
219
return new IssueList (driver);
161
220
}
162
221
@@ -294,7 +353,7 @@ EditIssueの "load" メソッドは次のようになります。
294
353
protected void load() {
295
354
securedPage. get();
296
355
297
- driver. get(" https://github.com/SeleniumHQ/selenium/issues/new" );
356
+ driver. get(" https://github.com/SeleniumHQ/selenium/issues/new?assignees=&labels=I-defect%2Cneeds-triaging&projects=&template=bug-report.yml&title=%5B%F0%9F%90%9B+Bug%5D%3A+ " );
298
357
}
299
358
```
300
359
@@ -319,8 +378,15 @@ public class FooTest {
319
378
public void demonstrateNestedLoadableComponents () {
320
379
editIssue. get();
321
380
322
- editIssue. setSummary(" Summary" );
323
- editIssue. enterDescription(" This is an example" );
381
+ editIssue. title. sendKeys(' Title' );
382
+ editIssue. body. sendKeys(' What Happened' );
383
+ editIssue. setHowToReproduce(' How to Reproduce' );
384
+ editIssue. setLogOutput(' Log Output' );
385
+ editIssue. setOperatingSystem(' Operating System' );
386
+ editIssue. setSeleniumVersion(' Selenium Version' );
387
+ editIssue. setBrowserVersion(' Browser Version' );
388
+ editIssue. setDriverVersion(' Driver Version' );
389
+ editIssue. setUsingGrid(' I Am Using Grid' );
324
390
}
325
391
}
326
392
```
@@ -367,4 +433,4 @@ public class ActionBot {
367
433
}
368
434
```
369
435
370
- これらの抽象化が構築され、テストでの重複が特定されると、ボットの上にPageObjectsを階層化することができます。
436
+ これらの抽象化が構築され、テストでの重複が特定されると、ボットの上にPageObjectsを階層化することができます。
0 commit comments