From 25535e3add92f6c3b01def4ca2db7d55af19fd74 Mon Sep 17 00:00:00 2001 From: helkv Date: Mon, 12 Nov 2018 10:47:38 +0100 Subject: [PATCH] #37 Try to Fix: WebElement.click() not working on Jenkins (Approach I) - Clicking on the minusButton in deleteMetadata() method on the EditItemPage is not working, when running the tests on jenkins - Solution I: Use JavascriptExecutor.executeScript (instead of the normally used WebElement.click()) to click on the element --- res/testng_edmond_firefox.xml | 28 ++++++++++----------- src/spot/pages/registered/EditItemPage.java | 6 ++++- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/res/testng_edmond_firefox.xml b/res/testng_edmond_firefox.xml index 8d27ad2..af4cba7 100644 --- a/res/testng_edmond_firefox.xml +++ b/res/testng_edmond_firefox.xml @@ -18,7 +18,7 @@ - + - + - + - + - + - + @@ -107,13 +107,13 @@ - + diff --git a/src/spot/pages/registered/EditItemPage.java b/src/spot/pages/registered/EditItemPage.java index 8d94824..c351d0f 100644 --- a/src/spot/pages/registered/EditItemPage.java +++ b/src/spot/pages/registered/EditItemPage.java @@ -3,6 +3,7 @@ import java.util.List; import org.openqa.selenium.By; +import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.NoSuchElementException; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; @@ -84,7 +85,10 @@ private void deleteMetadata(String metaDataLabelName) { String currentName = metaDataLabel.getText(); if (currentName.equals(metaDataLabelName)) { WebElement minusButton = metaDataLabel.findElement(By.xpath("./following-sibling::div/a[contains(@class,'fa-minus-square-o')]")); - minusButton.click(); + //FIXME: On Jenkins the waiting for the staleness does not work -> reason? + // Try: Use a JavaSript click on the minusButton OR wait for the invisibility of metaDataLabel OR wait for another stale element to become stale + ((JavascriptExecutor) driver).executeScript("arguments[0].click();", minusButton); +// minusButton.click(); wait.until(ExpectedConditions.stalenessOf(metaDataLabel)); break; }