@@ -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