Skip to content

Commit c30a5a8

Browse files
committed
Use querySelector to click the correct HTML element
#140 (comment) notes that the same change was used in core so that the HTMLUnit code does not care about the type of the element being clicked.
1 parent d2808e3 commit c30a5a8

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

src/test/java/org/jenkinsci/plugins/docker/commons/credentials/DockerServerCredentialsTest.java

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
import org.htmlunit.html.HtmlForm;
3636
import hudson.security.ACL;
3737
import hudson.util.Secret;
38-
import hudson.util.VersionNumber;
3938
import org.junit.Rule;
4039
import org.junit.Test;
4140
import org.jvnet.hudson.test.JenkinsRule;
@@ -95,17 +94,9 @@ public void configRoundTripUpdateCertificates() throws Exception {
9594
store.addDomain(domain, credentials);
9695

9796
HtmlForm form = getUpdateForm(domain, credentials);
98-
for (HtmlElement button : form.getElementsByAttribute("input", "class", "secret-update-btn")) {
99-
button.click();
100-
}
97+
((HtmlElement) form.querySelector(".secret-update-btn")).click();
10198

102-
if (j.jenkins.getVersion().isOlderThan(new VersionNumber("2.413"))) {
103-
/* Jenkins 2.412 and earlier use a text area for the client key */
104-
form.getTextAreaByName("_.clientKeySecret").setText("new key");
105-
} else {
106-
/* Jenkins 2.413 and newer use an input field for the client key */
107-
form.getInputByName("_.clientKeySecret").setValue("new key");
108-
}
99+
form.getTextAreaByName("_.clientKeySecret").setText("new key");
109100
form.getTextAreaByName("_.clientCertificate").setText("new cert");
110101
form.getTextAreaByName("_.serverCaCertificate").setText("new ca cert");
111102
j.submit(form);

0 commit comments

Comments
 (0)