From 1af10f46655f7f6317e3de47a8ff2e284e19d3e2 Mon Sep 17 00:00:00 2001 From: Jan Faracik <43062514+janfaracik@users.noreply.github.com> Date: Sun, 6 Oct 2024 21:36:41 +0100 Subject: [PATCH] Forward compatibility with jenkinsci/credentials-plugin#551 (#1756) --- .../plugins/ssh_slaves/SshSlaveLauncher.java | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/jenkinsci/test/acceptance/plugins/ssh_slaves/SshSlaveLauncher.java b/src/main/java/org/jenkinsci/test/acceptance/plugins/ssh_slaves/SshSlaveLauncher.java index 496f88624..a1dc5c6f2 100644 --- a/src/main/java/org/jenkinsci/test/acceptance/plugins/ssh_slaves/SshSlaveLauncher.java +++ b/src/main/java/org/jenkinsci/test/acceptance/plugins/ssh_slaves/SshSlaveLauncher.java @@ -12,6 +12,7 @@ import org.jenkinsci.test.acceptance.po.Describable; import org.jenkinsci.test.acceptance.po.PageObject; import org.jenkinsci.test.acceptance.selenium.UselessFileDetectorReplacement; +import org.openqa.selenium.By; /** * @author Kohsuke Kawaguchi @@ -33,14 +34,22 @@ public SshSlaveLauncher(PageObject context, String path) { } public SshCredentialDialog addCredential() { - find(by.button("Add")).click(); - String providerXpathExpr = "//div[contains(@class,'credentials-add-menu-items')]" - + "/div[@class='bd']/ul[@class='first-of-type']/li[contains(@class, 'yuimenuitem')]" - + "/span[contains(@class,'yuimenuitemlabel') and contains(@tooltip, 'Jenkins Credentials Provider')]"; + if (getElement(By.cssSelector(".credentials-add-menu-items")) != null) { + // This condition is for backwards compatability, can be removed in the future + String providerXpathExpr = "//div[contains(@class,'credentials-add-menu-items')]" + + "/div[@class='bd']/ul[@class='first-of-type']/li[contains(@class, 'yuimenuitem')]" + + "/span[contains(@class,'yuimenuitemlabel') and contains(@tooltip, 'Jenkins Credentials Provider')]"; + waitFor(by.xpath(providerXpathExpr)).click(); + } else { + // Can be changed to 'find(...)' when https://github.com/jenkinsci/jenkins/pull/9835 is merged + all(by.css(".jenkins-dropdown")) + .get(1) + .findElement(by.button("Jenkins Credentials Provider")) + .click(); + } - waitFor(by.xpath(providerXpathExpr)).click(); return new SshCredentialDialog(getPage(), "/credentials"); }