Skip to content
Draft
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,10 @@ and
</systemPropertyVariables>
<!-- SUREFIRE-1588 workaround; too late for systemProperties: -->
<argLine>-Djdk.net.URLClassPath.disableClassPathURLCheck=true</argLine>
<environmentVariables>
<!-- Use local version of the plugin over the released one ATH would otherwise use -->
<LOCAL_JARS>target/credentials.hpi</LOCAL_JARS>
</environmentVariables>
</configuration>
</plugin>
<plugin>
Expand Down Expand Up @@ -765,6 +769,12 @@ and
<version>${jenkins.version}</version>
<type>war</type>
</artifactItem>
<artifactItem>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>credentials</artifactId>
<version>1560.v4fe9e4e90c65</version>
<type>hpi</type>
</artifactItem>
</artifactItems>
<outputDirectory>${project.build.directory}</outputDirectory>
<stripVersion>true</stripVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ private void navigateToCreateCredentials() {
tryCredentialsClick();
waitFor(by.href("/user/" + CREATED_USER + "/credentials/store/user")).click();
waitFor(by.href("domain/_")).click();
waitFor(by.href("newCredentials")).click();
waitFor(by.button("Add Credentials")).click();
waitFor(by.name("_.id"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public void add() {
we.click();
// wait for the form to be removed from the UI
waitFor(driver).until(ExpectedConditions.invisibilityOf(dialog));
// the notification bar can place itslef over other elements
// the notification bar can place itself over other elements
// so wait for it to be added and then disappear
waitFor(waitFor(By.id("notification-bar"))).until(bar -> !bar.isDisplayed());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
import org.jenkinsci.test.acceptance.po.Control;
import org.jenkinsci.test.acceptance.po.Folder;
import org.jenkinsci.test.acceptance.po.Jenkins;
import org.jenkinsci.test.acceptance.selenium.Scroller;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;

public class CredentialsPage extends ConfigurablePageObject {
public final Control addButton = control(by.xpath("//select[contains(@class, 'setting-input dropdownList')] | "
Expand All @@ -22,26 +24,41 @@ public class CredentialsPage extends ConfigurablePageObject {
* Create a new Credential
*/
public CredentialsPage(Jenkins j, String domainName) {
super(j, j.url("credentials/store/system/domain/" + domainName + "/newCredentials"));
super(j, j.url("credentials/store/system/domain/" + domainName));
}

/**
* Create a new Credential scoped to a Folder
*/
public CredentialsPage(Folder f, String domainName) {
super(f, f.url("credentials/store/folder/domain/" + domainName + "/newCredentials"));
super(f, f.url("credentials/store/folder/domain/" + domainName));
}

/**
* Create a new personal Credential
*/
public CredentialsPage(Jenkins j, String domainName, String userName) {
super(j, j.url(String.format("user/%s/credentials/store/user/domain/%s/newCredentials", userName, domainName)));
super(j, j.url(String.format("user/%s/credentials/store/user/domain/%s", userName, domainName)));
}

public <T extends Credential> T add(Class<T> type) {
addButton.selectDropdownMenuAlt(type);
String path = find(by.name("credentials")).getAttribute("path");
WebElement radio = findCaption(type, caption -> {
for (WebElement webElement : all(by.css(".jenkins-choice-list__item__label"))) {
if (webElement.getText().equals(caption)) {
webElement.click();
return webElement.findElement(by.xpath("./../input"));
}
}
return null;
});

String path = radio.getAttribute("path");

WebElement nextButton = find(by.id("cr-dialog-next"));
nextButton.click();
waitFor(by.id("cr-dialog-submit"));
new Scroller(driver).disableStickyElements();

return newInstance(type, this, path);
}

Expand All @@ -56,7 +73,7 @@ public void setConfigUrl(String url) throws MalformedURLException {
}

public void create() {
find(by.name("Submit")).click();
find(by.id("cr-dialog-submit")).click();
assertThat(driver, not(hasContent("This page expects a form submission")));
}

Expand All @@ -72,9 +89,10 @@ public void delete() {
@Override
public WebDriver open() {
WebDriver wd = super.open();
// wait for default form fields to be present to avoid possible race
// condition when changing credentials type too fast (happens rarely)
waitFor(by.name("_.id"));

clickButton("Add Credentials");
// Selenium will execute the next step before the options have loaded if we don't wait for them
waitFor(by.css(".jenkins-choice-list__item__label"));
return wd;
}

Expand Down