Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ad30b94

Browse files
fixed stale element in CompareProduct
1 parent 9778368 commit ad30b94

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

‎src/test/java/Utills/WebDriverHelper.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import org.openqa.selenium.By;
44
import org.openqa.selenium.Keys;
5+
import org.openqa.selenium.StaleElementReferenceException;
56
import org.openqa.selenium.WebElement;
67
import org.openqa.selenium.interactions.Actions;
78
import org.openqa.selenium.remote.RemoteWebDriver;
@@ -76,8 +77,12 @@ public void mouseHoverOnElement(By locator) {
7677
}
7778

7879
public void staleElementRefresh(By locator) {
79-
WebDriverWait wait = new WebDriverWait(driver, 30);
80-
wait.until(ExpectedConditions.stalenessOf(driver.findElement(locator)));
80+
try {
81+
WebDriverWait wait = new WebDriverWait(driver, 30);
82+
wait.until(ExpectedConditions.stalenessOf(driver.findElement(locator)));
83+
} catch (StaleElementReferenceException exception) {
84+
exception.printStackTrace();
85+
}
8186
}
8287

8388
public void waitForTime(int timeout) {

‎src/test/java/com/lambdatest/AddProduct.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public class AddProduct {
6666
driverHelper.waitForVisibility(WEBSITE_DISCLAIMER_HEADING_ON_HOME_PAGE, 30);
6767
boolean value = driver.findElement(WEBSITE_DISCLAIMER_HEADING_ON_HOME_PAGE).isDisplayed();
6868
Assert.assertTrue(value, "Element is not displayed.");
69-
Status = "Passed";
69+
Status = "passed";
7070
}
7171

7272
@AfterMethod public void tearDown() {

‎src/test/java/com/lambdatest/CompareProducts.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,16 @@ public class CompareProducts {
5454
driverHelper.getURL("https://ecommerce-playground.lambdatest.io/");
5555
driverHelper.click(SHOP_BY_CATEGORY_NAVIGATION);
5656
driverHelper.click(PHONE_TABLETS_IPOD_NAVIGATION);
57-
driverHelper.click(HTC_TOUCH_ID_FIRST_PRODUCT);
5857
driverHelper.mouseHoverOnElement(HTC_TOUCH_ID_FIRST_PRODUCT);
5958
driverHelper.click(COMPARE_TO_THIS_PRODUCT_OPTION);
6059
driverHelper.click(APPLE_MANUFACTURER_FILTER);
60+
driverHelper.waitForVisibility(FIRST_IPOD_PRODUCT, 30);
61+
driverHelper.staleElementRefresh(FIRST_IPOD_PRODUCT);
6162
driverHelper.mouseHoverOnElement(FIRST_IPOD_PRODUCT);
6263
driverHelper.click(COMPARE_TO_THIS_PRODUCT_OPTION);
6364
driverHelper.click(COMPARE_PRODUCT_BUTTON);
6465
driverHelper.isDisplayed(PRODUCT_COMPARISON_HEADING);
65-
Status = "Passed";
66+
Status = "passed";
6667
}
6768

6869
@AfterMethod public void tearDown() {

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /