-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7b5db4e
commit 9f83c37
Showing
5 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
webdriver_java/src/main/java/pages/DynamicLoadingExample1Page.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package pages; | ||
|
||
import org.openqa.selenium.By; | ||
import org.openqa.selenium.NoSuchElementException; | ||
import org.openqa.selenium.WebDriver; | ||
import org.openqa.selenium.support.ui.ExpectedConditions; | ||
import org.openqa.selenium.support.ui.FluentWait; | ||
import org.openqa.selenium.support.ui.WebDriverWait; | ||
|
||
import java.time.Duration; | ||
|
||
public class DynamicLoadingExample1Page { | ||
|
||
private WebDriver driver; | ||
private By startButton = By.cssSelector("#start button"); | ||
private By loadingIndicator = By.id("loading"); | ||
private By loadedText = By.id("finish"); | ||
|
||
public DynamicLoadingExample1Page(WebDriver driver){ | ||
this.driver = driver; | ||
} | ||
|
||
public void clickStart(){ | ||
driver.findElement(startButton).click(); | ||
WebDriverWait wait = new WebDriverWait(driver, 5); | ||
wait.until(ExpectedConditions.invisibilityOf( | ||
driver.findElement(loadingIndicator))); | ||
|
||
/* FLUENT WAIT */ | ||
// FluentWait wait = new FluentWait(driver) | ||
// .withTimeout(Duration.ofSeconds(5)) | ||
// .pollingEvery(Duration.ofSeconds(1)) | ||
// .ignoring(NoSuchElementException.class); | ||
// wait.until(ExpectedConditions.invisibilityOf( | ||
// driver.findElement(loadingIndicator))); | ||
|
||
} | ||
|
||
public String getLoadedText(){ | ||
return driver.findElement(loadedText).getText(); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
webdriver_java/src/main/java/pages/DynamicLoadingPage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package pages; | ||
|
||
import org.openqa.selenium.By; | ||
import org.openqa.selenium.WebDriver; | ||
|
||
public class DynamicLoadingPage { | ||
|
||
private WebDriver driver; | ||
private String linkXpath_Format = ".//a[contains(text(), '%s')]"; | ||
private By link_Example1 = By.xpath(String.format(linkXpath_Format, "Example 1")); | ||
|
||
public DynamicLoadingPage(WebDriver driver){ | ||
this.driver = driver; | ||
} | ||
|
||
public DynamicLoadingExample1Page clickExample1(){ | ||
driver.findElement(link_Example1).click(); | ||
return new DynamicLoadingExample1Page(driver); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package wait; | ||
|
||
import base.BaseTests; | ||
import org.testng.annotations.Test; | ||
|
||
import static org.testng.Assert.assertEquals; | ||
|
||
public class WaitTests extends BaseTests { | ||
|
||
@Test | ||
public void testWaitUntilHidden(){ | ||
var loadingPage = homePage.clickDynamicLoading().clickExample1(); | ||
loadingPage.clickStart(); | ||
assertEquals(loadingPage.getLoadedText(), "Hello World!", "Loaded text incorrect"); | ||
} | ||
} |