Skip to content

Commit 099cc7d

Browse files
Harmit07timja
andauthored
Make ByFactory.button use exact text match (jenkinsci#2621)
Co-authored-by: Tim Jacomb <21194782+timja@users.noreply.github.com>
1 parent fab1355 commit 099cc7d

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

src/main/java/org/jenkinsci/test/acceptance/ByFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ private static String fieldXPath(String base, String locator) {
173173
*/
174174
public By button(String locator) {
175175
return xpath(
176-
".//input[./@type = 'submit' or ./@type = 'reset' or ./@type = 'image' or ./@type = 'button'][((./@id = '%1$s' or ./@name = '%1$s' or contains(./@value, '%1$s')) or contains(./@title, '%1$s'))] | .//input[./@type = 'image'][contains(./@alt, '%1$s')] | .//button[(((./@id = '%1$s' or contains(./@value, '%1$s')) or contains(normalize-space(.), '%1$s')) or contains(./@title, '%1$s'))] | .//input[./@type = 'image'][contains(./@alt, '%1$s')]",
176+
".//input[./@type = 'submit' or ./@type = 'reset' or ./@type = 'image' or ./@type = 'button'][./@id = '%1$s' or ./@name = '%1$s' or ./@value = '%1$s' or ./@title = '%1$s'] | .//input[./@type = 'image'][./@alt = '%1$s'] | .//button[./@id = '%1$s' or ./@value = '%1$s' or normalize-space(.) = '%1$s' or ./@title = '%1$s'] | .//input[./@type = 'image'][./@alt = '%1$s']",
177177
locator);
178178
}
179179

src/main/java/org/jenkinsci/test/acceptance/plugins/ssh_slaves/SshSlaveLauncher.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ public SshSlaveLauncher(PageObject context, String path) {
3737
public <T extends Credential> T addCredential(Class<T> type) {
3838
find(by.button("Add")).click();
3939

40-
find(by.css(".jenkins-dropdown")).findElement(by.button("Global")).click();
40+
find(by.css(".jenkins-dropdown"))
41+
.findElement(by.button("GlobalCredentials that should be available everywhere."))
42+
.click();
4143

4244
// Selenium will execute the next step before the options have loaded if we don't wait for them
4345
waitFor(by.css(".jenkins-choice-list__item__label"));

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ public String runScript(String script, int timeoutSeconds, Object... args) {
8282
visit("script");
8383
CodeMirror cm = new CodeMirror(this, "/script");
8484
cm.set(String.format(script, args));
85-
find(by.css("button[value='Run']")).click();
85+
86+
clickButton("Run");
8687

8788
waitFor(by.xpath("//h2[contains(text(), 'Result')]"), timeoutSeconds);
8889

0 commit comments

Comments
 (0)