From d8bf4d21eeff92f9a855447fe55034277720ec23 Mon Sep 17 00:00:00 2001 From: Markus Winter Date: Mon, 7 Oct 2024 23:36:59 +0200 Subject: [PATCH] make forward comaptible --- .../test/acceptance/po/LabelAxis.java | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/jenkinsci/test/acceptance/po/LabelAxis.java b/src/main/java/org/jenkinsci/test/acceptance/po/LabelAxis.java index 15797e579..48bbc9fd1 100644 --- a/src/main/java/org/jenkinsci/test/acceptance/po/LabelAxis.java +++ b/src/main/java/org/jenkinsci/test/acceptance/po/LabelAxis.java @@ -1,6 +1,7 @@ package org.jenkinsci.test.acceptance.po; import java.time.Duration; +import org.openqa.selenium.NoSuchElementException; import org.openqa.selenium.WebElement; /** @@ -16,11 +17,25 @@ public void select(String name) { WebElement checkBox = find(by.path(getPath())).findElement(by.xpath(".//input[@name='values' and @json='%s']", name)); if (!checkBox.isDisplayed()) { - // unfold the labels and slaves sub-nodes - find(by.xpath("(//button[@class='jenkins-button mp-label-axis__button'])[1]")) - .click(); - find(by.xpath("(//button[@class='jenkins-button mp-label-axis__button'])[2]")) - .click(); + try { + // unfold the labels and slaves sub-nodes + find(by.xpath("(//button[@class='jenkins-button mp-label-axis__button'])[1]")) + .click(); + find(by.xpath("(//button[@class='jenkins-button mp-label-axis__button'])[2]")) + .click(); + } catch (NoSuchElementException e) { + // forward compatibility + } + + try { + // unfold the labels and slaves sub-nodes + find(by.xpath("//div[@class='yahooTree labelAxis-tree']//table[@id='ygtvtableel1']//a")) + .click(); + find(by.xpath("//div[@class='yahooTree labelAxis-tree']//table[@id='ygtvtableel2']//a")) + .click(); + } catch (NoSuchElementException e) { + // backward compatibility + } waitFor().withTimeout(Duration.ofSeconds(3)).until(checkBox::isDisplayed); }