-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* added exception wait time out to handle tolerant methods * applied the changes as mentioned in the review comments for tolerant methods * Changed the method to package private to not expose this method * Added test to validate the tolerant method without passing wait time for method * changed the variable names for the TolerantAction object as mentioned * futureDataAvoidingWeekendsAndBankHolidays issue which need to avoid weekends when adding bank holidays count * added overload method for tolerantItemByIndex and tolerantItemByHtmlValueAttribute * resolved conflicts * changed from private package to public * Changed onException method to take screenshot only on Local run not on running on grid * Changed onException method to take screenshot only on Local run not on running on grid * Added boolean parameter in config file to handle taking snapshots * 1.Created tolerant methods for clear,getAttribute,getText and isDisplayed methods. 2. Modified interact methods to handle tolerant methods. * 1.Created tolerant methods for clear,getAttribute and getText methods to handle required exceptions * added chrome browser preferences to change the default file download path. * Added unit test for chrome preferences. * removed unnecessary imports * removed unnecessary imports * added chrome preferences saucelabs config file * updated chrome options variable name * updated download file directory for browser and added unit test for browser preference applied * removed unused imports * added chrome and firefox integration tests to test browser preferences * updated tear down method to reset system config value to default Co-authored-by: balavengaiah.matam <balavengaiah.matam@dwp.gov.uk> Co-authored-by: Steve Walton <steve.walton@evoco.co.uk>
- Loading branch information
1 parent
002a329
commit e90b3ae
Showing
17 changed files
with
318 additions
and
34 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -51,4 +51,5 @@ script/dist | |
logs/* | ||
src/main/resources/bank-holidays.json | ||
node_modules | ||
dist | ||
dist | ||
run-generated-files/* |
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
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
10 changes: 9 additions & 1 deletion
10
src/test/java/uk/co/evoco/webdriver/configuration/driver/ConfiguredSauceLabsDriverTests.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 |
---|---|---|
@@ -1,21 +1,29 @@ | ||
package uk.co.evoco.webdriver.configuration.driver; | ||
|
||
import org.junit.jupiter.api.AfterAll; | ||
import org.junit.jupiter.api.Test; | ||
import org.openqa.selenium.WebDriver; | ||
import uk.co.evoco.exceptions.SauceLabsCredentialsException; | ||
|
||
import java.io.IOException; | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.Matchers.containsString; | ||
|
||
public class ConfiguredSauceLabsDriverTests { | ||
|
||
@Test | ||
public void testCanRunTestOnSauceLabsUsingConfigiration() throws SauceLabsCredentialsException{ | ||
public void testCanRunTestOnSauceLabsUsingConfigiration() throws SauceLabsCredentialsException, IOException { | ||
System.setProperty("config", "config-saucelabs.json"); | ||
ConfiguredDriver configuredSauceLabsGridDriver = new ConfiguredSauceLabsGridDriver(); | ||
WebDriver webDriver = configuredSauceLabsGridDriver.getRemoteDriver(); | ||
webDriver.get("https://www.evoco.co.uk"); | ||
assertThat("Didn't make it to evoco.co.uk", webDriver.getCurrentUrl(), containsString("evoco.co.uk")); | ||
webDriver.quit(); | ||
} | ||
|
||
@AfterAll | ||
public static void tearDown() { | ||
System.setProperty("config", "DEFAULT"); | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
src/test/java/uk/co/evoco/webdriver/utils/ChromeDriverPreferenceTests.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,48 @@ | ||
package uk.co.evoco.webdriver.utils; | ||
|
||
import org.apache.commons.io.FileUtils; | ||
import org.junit.jupiter.api.*; | ||
import org.openqa.selenium.By; | ||
import org.openqa.selenium.WebDriver; | ||
import uk.co.evoco.webdriver.configuration.driver.ConfiguredChromeDriver; | ||
|
||
import java.io.File; | ||
|
||
import static org.hamcrest.CoreMatchers.is; | ||
import static org.hamcrest.MatcherAssert.assertThat; | ||
|
||
public class ChromeDriverPreferenceTests { | ||
|
||
private static String baseUrl; | ||
private static EmbeddedJetty embeddedJetty; | ||
private WebDriver webDriver; | ||
|
||
@BeforeAll | ||
public static void webDriverSetup() throws Exception { | ||
embeddedJetty = new EmbeddedJetty(); | ||
embeddedJetty.start(); | ||
baseUrl = "http://localhost:" + embeddedJetty.getPort() + "/index.html"; | ||
} | ||
|
||
@Test | ||
public void testChromeBrowserPreferencesApplied() throws Exception { | ||
System.setProperty("config", "fixtures/sample-config-with-chrome-preferences.json"); | ||
webDriver = new ConfiguredChromeDriver().getDriver(FileUtils.getTempDirectory()); | ||
webDriver.get(baseUrl); | ||
String expectedFile = new File("run-generated-files/chrome/downloads").getCanonicalPath() + "/sampleFile.pdf"; | ||
webDriver.findElement(By.xpath("//a[text()='clickHereToDownLoadAFile']")).click(); | ||
Thread.sleep(2000);//need to wait until file download | ||
assertThat(new File(expectedFile).exists(), is(true)); | ||
} | ||
|
||
@AfterEach | ||
public void tearDown() { | ||
this.webDriver.quit(); | ||
} | ||
|
||
@AfterAll | ||
public static void webDriverTearDown() throws Exception { | ||
System.setProperty("config", "DEFAULT"); | ||
embeddedJetty.stop(); | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
src/test/java/uk/co/evoco/webdriver/utils/FirefoxDriverPreferenceTests.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,49 @@ | ||
package uk.co.evoco.webdriver.utils; | ||
|
||
import org.apache.commons.io.FileUtils; | ||
import org.junit.jupiter.api.*; | ||
import org.openqa.selenium.By; | ||
import org.openqa.selenium.WebDriver; | ||
import uk.co.evoco.webdriver.configuration.driver.ConfiguredFirefoxDriver; | ||
|
||
import java.io.File; | ||
|
||
import static org.hamcrest.CoreMatchers.is; | ||
import static org.hamcrest.MatcherAssert.assertThat; | ||
|
||
public class FirefoxDriverPreferenceTests { | ||
|
||
private static String baseUrl; | ||
private static EmbeddedJetty embeddedJetty; | ||
private WebDriver webDriver; | ||
|
||
@BeforeAll | ||
public static void webDriverSetup() throws Exception { | ||
embeddedJetty = new EmbeddedJetty(); | ||
embeddedJetty.start(); | ||
baseUrl = "http://localhost:" + embeddedJetty.getPort() + "/index.html"; | ||
} | ||
|
||
@Test | ||
public void testFirefoxBrowserPreferencesApplied() throws Exception { | ||
System.setProperty("config", "fixtures/sample-config-with-firefox-preferences.json"); | ||
webDriver = new ConfiguredFirefoxDriver().getDriver(FileUtils.getTempDirectory()); | ||
webDriver.get(baseUrl); | ||
String expectedFile = new File("run-generated-files/firefox/downloads").getCanonicalPath() + "/sampleFile.pdf"; | ||
webDriver.findElement(By.xpath("//a[text()='clickHereToDownLoadAFile']")).click(); | ||
Thread.sleep(2000);//need to wait until file download | ||
assertThat(new File(expectedFile).exists(), is(true)); | ||
} | ||
|
||
@AfterEach | ||
public void tearDown() { | ||
this.webDriver.quit(); | ||
} | ||
|
||
@AfterAll | ||
public static void webDriverTearDown() throws Exception { | ||
System.setProperty("config", "DEFAULT"); | ||
embeddedJetty.stop(); | ||
} | ||
|
||
} |
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
Oops, something went wrong.