Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid depending on labels, rather use the button name #1754

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@
* @author ogondza.
*/
public abstract class ConfigurablePageObject extends PageObject {

private static final By SAVE_BUTTON = By.xpath(
"//div[contains(@class, 'bottom-sticker-inner')]//input[@type='submit'] | //div[contains(@class, 'bottom-sticker-inner')]//button[contains(@name, 'Submit')]");

protected ConfigurablePageObject(PageObject context, URL url) {
super(context, url);
}
Expand Down Expand Up @@ -109,21 +113,13 @@ public void configure() {
visit(getConfigUrl());
}
waitFor(By.xpath("//form[contains(@name, '" + getFormName() + "')]"), 10);
waitFor(
By.xpath(
"//div[contains(@class, 'bottom-sticker-inner')]//input[@type='submit'] | //div[contains(@class, 'bottom-sticker-inner')]//button[contains(text(), '"
+ getSubmitButtonText() + "')]"),
5);
waitFor(SAVE_BUTTON, 5);
}

public String getFormName() {
return "config";
}

public String getSubmitButtonText() {
return "Save";
}

/**
* Makes sure that the browser is currently opening the configuration page.
*/
Expand All @@ -135,7 +131,7 @@ public void ensureConfigPage() {
public abstract URL getConfigUrl();

public void save() {
WebElement e = find(by.button("Save"));
WebElement e = find(SAVE_BUTTON);
e.click();
waitFor(e).until(CapybaraPortingLayerImpl::isStale);
}
Expand Down
11 changes: 0 additions & 11 deletions src/main/java/org/jenkinsci/test/acceptance/po/View.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,6 @@ public void delete() {
runThenHandleDialog(() -> clickLink("Delete View"));
}

@Override
public void save() {
clickButton("OK");
assertThat(driver, not(hasContent("This page expects a form submission")));
}

public BuildHistory getBuildHistory() {
return new BuildHistory(this);
}
Expand Down Expand Up @@ -114,11 +108,6 @@ public String getFormName() {
return "viewConfig";
}

@Override
public String getSubmitButtonText() {
return "OK";
}

public static Matcher<View> hasDescription(String description) {
return new Matcher<>("Has description " + description) {
@Override
Expand Down
Loading