Skip to content

Commit 190f938

Browse files
authored
Avoid depending on labels, rather use the button name (#1754)
1 parent 854ae6c commit 190f938

2 files changed

Lines changed: 6 additions & 25 deletions

File tree

src/main/java/org/jenkinsci/test/acceptance/po/ConfigurablePageObject.java

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@
4545
* @author ogondza.
4646
*/
4747
public abstract class ConfigurablePageObject extends PageObject {
48+
49+
private static final By SAVE_BUTTON = By.xpath(
50+
"//div[contains(@class, 'bottom-sticker-inner')]//input[@type='submit'] | //div[contains(@class, 'bottom-sticker-inner')]//button[contains(@name, 'Submit')]");
51+
4852
protected ConfigurablePageObject(PageObject context, URL url) {
4953
super(context, url);
5054
}
@@ -109,21 +113,13 @@ public void configure() {
109113
visit(getConfigUrl());
110114
}
111115
waitFor(By.xpath("//form[contains(@name, '" + getFormName() + "')]"), 10);
112-
waitFor(
113-
By.xpath(
114-
"//div[contains(@class, 'bottom-sticker-inner')]//input[@type='submit'] | //div[contains(@class, 'bottom-sticker-inner')]//button[contains(text(), '"
115-
+ getSubmitButtonText() + "')]"),
116-
5);
116+
waitFor(SAVE_BUTTON, 5);
117117
}
118118

119119
public String getFormName() {
120120
return "config";
121121
}
122122

123-
public String getSubmitButtonText() {
124-
return "Save";
125-
}
126-
127123
/**
128124
* Makes sure that the browser is currently opening the configuration page.
129125
*/
@@ -135,7 +131,7 @@ public void ensureConfigPage() {
135131
public abstract URL getConfigUrl();
136132

137133
public void save() {
138-
WebElement e = find(by.button("Save"));
134+
WebElement e = find(SAVE_BUTTON);
139135
e.click();
140136
waitFor(e).until(CapybaraPortingLayerImpl::isStale);
141137
}

src/main/java/org/jenkinsci/test/acceptance/po/View.java

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
package org.jenkinsci.test.acceptance.po;
22

3-
import static org.hamcrest.MatcherAssert.assertThat;
4-
import static org.hamcrest.Matchers.not;
5-
import static org.jenkinsci.test.acceptance.Matchers.hasContent;
6-
73
import com.fasterxml.jackson.databind.JsonNode;
84
import com.google.inject.Injector;
95
import java.net.URL;
@@ -60,12 +56,6 @@ public void delete() {
6056
runThenHandleDialog(() -> clickLink("Delete View"));
6157
}
6258

63-
@Override
64-
public void save() {
65-
clickButton("OK");
66-
assertThat(driver, not(hasContent("This page expects a form submission")));
67-
}
68-
6959
public BuildHistory getBuildHistory() {
7060
return new BuildHistory(this);
7161
}
@@ -114,11 +104,6 @@ public String getFormName() {
114104
return "viewConfig";
115105
}
116106

117-
@Override
118-
public String getSubmitButtonText() {
119-
return "OK";
120-
}
121-
122107
public static Matcher<View> hasDescription(String description) {
123108
return new Matcher<>("Has description " + description) {
124109
@Override

0 commit comments

Comments
 (0)