Skip to content

Commit 30c9eae

Browse files
authored
Updated Design Patterns And Development Strategies' Example Scripts (#1949)[deploy site]
* updated Design Patterns And Strategies for new Github Issues Page * missing semicolons * missing semicolons * missing semicolons * missing semicolons * missing semicolons * refactored to focus pageBody object on new issue site
1 parent 203fe5a commit 30c9eae

File tree

4 files changed

+370
-105
lines changed

4 files changed

+370
-105
lines changed

website_and_docs/content/documentation/test_practices/design_strategies.en.md

+93-26
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ There is currently an implementation in Java that ships as part of Selenium 2, b
3434
### Simple Usage
3535

3636
As an example of a UI that we'd like to model, take a look at
37-
the [new issue](https://github.com/SeleniumHQ/selenium/issues/new) page. From the point of view of a test author,
37+
the [new 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+) page. From the point of view of a test author,
3838
this offers the service of being able to file a new issue. A basic Page Object would look like:
3939

4040
```java
@@ -52,18 +52,53 @@ public class EditIssue {
5252
this.driver = driver;
5353
}
5454

55-
public void setSummary(String summary) {
56-
WebElement field = driver.findElement(By.name("summary"));
57-
clearAndType(field, summary);
55+
public void setTitle(String title) {
56+
WebElement field = driver.findElement(By.id("issue_title")));
57+
clearAndType(field, title);
5858
}
5959

60-
public void enterDescription(String description) {
61-
WebElement field = driver.findElement(By.name("comment"));
62-
clearAndType(field, description);
60+
public void setBody(String body) {
61+
WebElement field = driver.findElement(By.id("issue_body"));
62+
clearAndType(field, body);
63+
}
64+
65+
public void setHowToReproduce(String howToReproduce) {
66+
WebElement field = driver.findElement(By.id("issue_form_repro-command"));
67+
clearAndType(field, howToReproduce);
68+
}
69+
70+
public void setLogOutput(String logOutput) {
71+
WebElement field = driver.findElement(By.id("issue_form_logs"));
72+
clearAndType(field, logOutput);
73+
}
74+
75+
public void setOperatingSystem(String operatingSystem) {
76+
WebElement field = driver.findElement(By.id("issue_form_operating-system"));
77+
clearAndType(field, operatingSystem);
78+
}
79+
80+
public void setSeleniumVersion(String seleniumVersion) {
81+
WebElement field = driver.findElement(By.id("issue_form_selenium-version"));
82+
clearAndType(field, logOutput);
83+
}
84+
85+
public void setBrowserVersion(String browserVersion) {
86+
WebElement field = driver.findElement(By.id("issue_form_browser-versions"));
87+
clearAndType(field, browserVersion);
88+
}
89+
90+
public void setDriverVersion(String driverVersion) {
91+
WebElement field = driver.findElement(By.id("issue_form_browser-driver-versions"));
92+
clearAndType(field, driverVersion);
93+
}
94+
95+
public void setUsingGrid(String usingGrid) {
96+
WebElement field = driver.findElement(By.id("issue_form_selenium-grid-version"));
97+
clearAndType(field, usingGrid);
6398
}
6499

65100
public IssueList submit() {
66-
driver.findElement(By.id("submit")).click();
101+
driver.findElement(By.cssSelector("button[type='submit']")).click();
67102
return new IssueList(driver);
68103
}
69104

@@ -90,7 +125,7 @@ By extending this base class, we need to implement two new methods:
90125
```java
91126
@Override
92127
protected void load() {
93-
driver.get("https://github.com/SeleniumHQ/selenium/issues/new");
128+
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+");
94129
}
95130

96131
@Override
@@ -123,16 +158,13 @@ public class EditIssue extends LoadableComponent<EditIssue> {
123158
private final WebDriver driver;
124159

125160
// By default the PageFactory will locate elements with the same name or id
126-
// as the field. Since the summary element has a name attribute of "summary"
161+
// as the field. Since the issue_title element has an id attribute of "issue_title"
127162
// we don't need any additional annotations.
128-
private WebElement summary;
163+
private WebElement issue_title;
129164

130-
// Same with the submit element, which has the ID "submit"
131-
private WebElement submit;
132-
133-
// But we'd prefer a different name in our code than "comment", so we use the
165+
// But we'd prefer a different name in our code than "issue_body", so we use the
134166
// FindBy annotation to tell the PageFactory how to locate the element.
135-
@FindBy(name = "comment") private WebElement description;
167+
@FindBy(id = "issue_body") private WebElement body;
136168

137169
public EditIssue(WebDriver driver) {
138170
this.driver = driver;
@@ -143,25 +175,52 @@ public class EditIssue extends LoadableComponent<EditIssue> {
143175

144176
@Override
145177
protected void load() {
146-
driver.get("https://github.com/SeleniumHQ/selenium/issues/new");
178+
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+");
147179
}
148180

149181
@Override
150182
protected void isLoaded() throws Error {
151183
String url = driver.getCurrentUrl();
152184
assertTrue("Not on the issue entry page: " + url, url.endsWith("/new"));
153185
}
154-
155-
public void setSummary(String issueSummary) {
156-
clearAndType(summary, issueSummary);
186+
187+
public void setHowToReproduce(String howToReproduce) {
188+
WebElement field = driver.findElement(By.id("issue_form_repro-command"));
189+
clearAndType(field, howToReproduce);
190+
}
191+
192+
public void setLogOutput(String logOutput) {
193+
WebElement field = driver.findElement(By.id("issue_form_logs"));
194+
clearAndType(field, logOutput);
195+
}
196+
197+
public void setOperatingSystem(String operatingSystem) {
198+
WebElement field = driver.findElement(By.id("issue_form_operating-system"));
199+
clearAndType(field, operatingSystem);
157200
}
158201

159-
public void enterDescription(String issueDescription) {
160-
clearAndType(description, issueDescription);
202+
public void setSeleniumVersion(String seleniumVersion) {
203+
WebElement field = driver.findElement(By.id("issue_form_selenium-version"));
204+
clearAndType(field, logOutput);
205+
}
206+
207+
public void setBrowserVersion(String browserVersion) {
208+
WebElement field = driver.findElement(By.id("issue_form_browser-versions"));
209+
clearAndType(field, browserVersion);
210+
}
211+
212+
public void setDriverVersion(String driverVersion) {
213+
WebElement field = driver.findElement(By.id("issue_form_browser-driver-versions"));
214+
clearAndType(field, driverVersion);
215+
}
216+
217+
public void setUsingGrid(String usingGrid) {
218+
WebElement field = driver.findElement(By.id("issue_form_selenium-grid-version"));
219+
clearAndType(field, usingGrid);
161220
}
162221

163222
public IssueList submit() {
164-
submit.click();
223+
driver.findElement(By.cssSelector("button[type='submit']")).click();
165224
return new IssueList(driver);
166225
}
167226

@@ -298,7 +357,7 @@ The "load" method in EditIssue now looks like:
298357
protected void load() {
299358
securedPage.get();
300359

301-
driver.get("https://github.com/SeleniumHQ/selenium/issues/new");
360+
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+");
302361
}
303362
```
304363

@@ -323,9 +382,17 @@ public class FooTest {
323382
public void demonstrateNestedLoadableComponents() {
324383
editIssue.get();
325384

326-
editIssue.setSummary("Summary");
327-
editIssue.enterDescription("This is an example");
385+
editIssue.title.sendKeys('Title');
386+
editIssue.body.sendKeys('What Happened');
387+
editIssue.setHowToReproduce('How to Reproduce');
388+
editIssue.setLogOutput('Log Output');
389+
editIssue.setOperatingSystem('Operating System');
390+
editIssue.setSeleniumVersion('Selenium Version');
391+
editIssue.setBrowserVersion('Browser Version');
392+
editIssue.setDriverVersion('Driver Version');
393+
editIssue.setUsingGrid('I Am Using Grid');
328394
}
395+
329396
}
330397
```
331398

website_and_docs/content/documentation/test_practices/design_strategies.ja.md

+93-27
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ LoadableComponentは、PageObjectsの作成の負担を軽減することを目
3030

3131
### 簡単な使用方法
3232

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+)のページをご覧ください。
3434
テスト作成者の観点から、これは新しい問題を提出できるサービスを提供します。
3535
基本的なページオブジェクトは次のようになります。
3636

@@ -49,18 +49,53 @@ public class EditIssue {
4949
this.driver = driver;
5050
}
5151

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);
5555
}
5656

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);
6095
}
6196

6297
public IssueList submit() {
63-
driver.findElement(By.id("submit")).click();
98+
driver.findElement(By.cssSelector("button[type='submit']")).click();
6499
return new IssueList(driver);
65100
}
66101

@@ -86,7 +121,7 @@ public class EditIssue extends LoadableComponent<EditIssue> {
86121
```java
87122
@Override
88123
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+");
90125
}
91126

92127
@Override
@@ -118,16 +153,13 @@ public class EditIssue extends LoadableComponent<EditIssue> {
118153
private final WebDriver driver;
119154

120155
// 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"
122157
// we don't need any additional annotations.
123-
private WebElement summary;
158+
private WebElement issue_title;
124159

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
129161
// 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;
131163

132164
public EditIssue(WebDriver driver) {
133165
this.driver = driver;
@@ -138,25 +170,52 @@ public class EditIssue extends LoadableComponent<EditIssue> {
138170

139171
@Override
140172
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+");
142174
}
143175

144176
@Override
145177
protected void isLoaded() throws Error {
146178
String url = driver.getCurrentUrl();
147179
assertTrue("Not on the issue entry page: " + url, url.endsWith("/new"));
148180
}
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);
152210
}
153211

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);
156215
}
157216

158217
public IssueList submit() {
159-
submit.click();
218+
driver.findElement(By.cssSelector("button[type='submit']")).click();
160219
return new IssueList(driver);
161220
}
162221

@@ -294,7 +353,7 @@ EditIssueの "load" メソッドは次のようになります。
294353
protected void load() {
295354
securedPage.get();
296355

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+");
298357
}
299358
```
300359

@@ -319,8 +378,15 @@ public class FooTest {
319378
public void demonstrateNestedLoadableComponents() {
320379
editIssue.get();
321380

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');
324390
}
325391
}
326392
```
@@ -367,4 +433,4 @@ public class ActionBot {
367433
}
368434
```
369435

370-
これらの抽象化が構築され、テストでの重複が特定されると、ボットの上にPageObjectsを階層化することができます。
436+
これらの抽象化が構築され、テストでの重複が特定されると、ボットの上にPageObjectsを階層化することができます。

0 commit comments

Comments
 (0)