Skip to content

Commit

Permalink
[JENKINS-50023] Keep the existing behavior for previous jenkins versions
Browse files Browse the repository at this point in the history
  • Loading branch information
raul-arabaolaza committed Mar 9, 2018
1 parent f18d77a commit 576f8c9
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/main/java/org/jenkinsci/test/acceptance/po/TopLevelItem.java
Expand Up @@ -6,6 +6,8 @@
import java.util.ArrayList;
import java.util.List;

import hudson.util.VersionNumber;
import org.jenkinsci.test.acceptance.junit.Since;
import org.openqa.selenium.WebElement;

import com.google.inject.Injector;
Expand Down Expand Up @@ -43,12 +45,20 @@ public TopLevelItem(PageObject context, URL url, String name) {
*/
@CheckReturnValue
public <T extends TopLevelItem> T renameTo(final String newName) {
open();
String oldName = name;
control(by.href("/job/" + oldName + "/confirm-rename")).click();
WebElement renameButton = waitFor(by.button("Rename"));
control(by.name("newName")).set(newName);
renameButton.click();
// Change in behaviour of the rename is in versions > 2.110 see JENKINS-22936
if (getJenkins().getVersion().isOlderThan(new VersionNumber("2.110"))) {
configure();
control("/name").set(newName);
save();
waitFor(by.button("Yes")).click();
} else {
open();
control(by.href("/job/" + oldName + "/confirm-rename")).click();
WebElement renameButton = waitFor(by.button("Rename"), 5);
control(by.name("newName")).set(newName);
renameButton.click();
}
try {
return (T) newInstance(getClass(),
injector, new URL(url.toExternalForm().replace(oldName, newName)), newName);
Expand Down

0 comments on commit 576f8c9

Please sign in to comment.