Skip to content

Commit

Permalink
Update selectors for credentials dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
zbynek committed Mar 9, 2024
1 parent d53a587 commit 132e125
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.jenkinsci.test.acceptance.po.PageArea;
import org.jenkinsci.test.acceptance.po.PageAreaImpl;
import org.jenkinsci.test.acceptance.po.PageObject;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedConditions;

Expand All @@ -27,11 +28,18 @@ protected Credential(PageArea area, String relativePath) {
* Adds this credential and close the dialog.
*/
public void add() {
WebElement dialog = find(by.id("credentialsDialog"));
WebElement we = find(by.id("credentials-add-submit-button"));
WebElement dialog = find(by.id("credentials-dialog-form"));
WebElement we = find(submitButton());
we.click();
// wait for the form to be removed from the UI
waitFor(driver).until(ExpectedConditions.invisibilityOf(dialog));
}

/**
* @return dialog submit button selector
*/
public static By submitButton() {
return by.css(".jenkins-button[data-id='ok']");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,11 @@ protected void resolve(String caption) {
* Adds this credential and close the modal dialog.
*/
public void add() {
final By addSubmitButton = by.id("credentials-add-submit-button");

this.findAndPerformClick(addSubmitButton);
this.findAndPerformClick(Credential.submitButton());

waitFor().withTimeout(Duration.ofSeconds(5)).until(() -> {
try {
return !find(addSubmitButton).isDisplayed();
return !find(Credential.submitButton()).isDisplayed();
} catch (final NoSuchElementException | StaleElementReferenceException ex) {
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void basicDeclarativeTests() throws Exception {
assertThat(driver, hasElement( By.className( "rectangle-conversion-success")));
assertThat(driver, hasElement(By.className("review-converted")));
assertThat(driver, hasElement(By.id("jenkinsfile-content")));
String jenkinsFile = driver.findElement(By.id("jenkinsfile-content")).getAttribute("value");
String jenkinsFile = driver.findElement(By.id("jenkinsfile-content")).getText();
assertThat(jenkinsFile, containsString( "echo 1" ));
}
}

0 comments on commit 132e125

Please sign in to comment.