diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..5c98b42
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,2 @@
+# Default ignored files
+/workspace.xml
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index c6dac1a..957fbcc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -12,67 +12,26 @@
UTF-8
- 1.7
- 1.7
+ 1.8
+ 1.8org.junit.jupiterjunit-jupiter-api
- 5.3.2
+ 5.4.0testorg.seleniumhq.seleniumselenium-java
- 3.10.0
+ 4.0.0-rc-3org.apache.commonscommons-lang33.6
-
- commons-io
- commons-io
- 2.5
-
-
-
-
-
-
- maven-clean-plugin
- 3.0.0
-
-
-
- maven-resources-plugin
- 3.0.2
-
-
- maven-compiler-plugin
- 3.7.0
-
-
- maven-surefire-plugin
- 2.20.1
-
-
- maven-jar-plugin
- 3.0.2
-
-
- maven-install-plugin
- 2.5.2
-
-
- maven-deploy-plugin
- 2.8.2
-
-
-
-
diff --git a/src/main/java/browser/BrowserGetter.java b/src/main/java/browser/BrowserGetter.java
index 3a12832..9a7e955 100644
--- a/src/main/java/browser/BrowserGetter.java
+++ b/src/main/java/browser/BrowserGetter.java
@@ -1,7 +1,9 @@
package browser;
+import org.openqa.selenium.Dimension;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
+import org.openqa.selenium.firefox.FirefoxDriver;
import static java.lang.System.setProperty;
import static org.apache.commons.lang3.SystemUtils.*;
@@ -12,9 +14,15 @@ public class BrowserGetter {
* if it is not one of the predefined ones, just throw exception
* only create a webDriver instance for a known operating system
*/
- public WebDriver getChromeDriver() {
+ public WebDriver getWinChromeDriver() {
+ setProperty("webdriver.chrome.driver", "src/test/resources/browserBinaries/chromedriver.exe");
+ WebDriver driver = new ChromeDriver();
+ driver.manage().window().maximize();
+ return driver;
+ }
+ public WebDriver getChromeDriver() {
if (!IS_OS_WINDOWS && !IS_OS_LINUX && !IS_OS_MAC) {
throw new RuntimeException("Could not initialize browser due to unknown operating system!");
}
@@ -32,4 +40,56 @@ public WebDriver getChromeDriver() {
driver.manage().window().maximize();
return driver;
}
+
+ public WebDriver getFirefoxDriver() {
+ if (!IS_OS_WINDOWS && !IS_OS_LINUX && !IS_OS_MAC) {
+ throw new RuntimeException("Could not initialize browser due to unknown operating system!");
+ }
+ if (IS_OS_WINDOWS) {
+ setProperty("webdriver.gecko.driver", "src/test/resources/browserBinaries/geckodriver.exe");
+ }
+ if (IS_OS_LINUX) {
+ setProperty("webdriver.gecko.driver", "src/test/resources/browserBinaries/geckodriver");
+ }
+ if (IS_OS_MAC) {
+ setProperty("webdriver.gecko.driver", "src/test/resources/browserBinaries/geckodriverMac");
+ }
+
+ WebDriver driver = new FirefoxDriver();
+ driver.manage().window().maximize();
+ return driver;
+ }
+
+ public WebDriver getDriver() {
+ switch (System.getProperty("browser").toLowerCase()) {
+ case "chrome" :
+ System.out.println("Chrome was chosen!");
+ return getChromeDriver();
+ case "firefox" :
+ System.out.println("Firefox was chosen!");
+ return getFirefoxDriver();
+ default:
+ throw new RuntimeException("Unsupported browser! Will not start any browser!");
+ }
+ }
+
+ public WebDriver getChromeDriverCustomSize(int width, int height) {
+ if (!IS_OS_WINDOWS && !IS_OS_LINUX && !IS_OS_MAC) {
+ throw new RuntimeException("Could not initialize browser due to unknown operating system!");
+ }
+ if (IS_OS_WINDOWS) {
+ setProperty("webdriver.chrome.driver", "src/test/resources/browserBinaries/chromedriver.exe");
+ }
+ if (IS_OS_LINUX) {
+ setProperty("webdriver.chrome.driver", "src/test/resources/browserBinaries/chromedriver");
+ }
+ if (IS_OS_MAC) {
+ setProperty("webdriver.chrome.driver", "src/test/resources/browserBinaries/chromedriverMac");
+ }
+
+ WebDriver driver = new ChromeDriver();
+ driver.manage().window().setSize(new Dimension(width, height));
+ return driver;
+ }
+
}
diff --git a/src/main/java/objects/Article.java b/src/main/java/objects/Article.java
new file mode 100644
index 0000000..aa84b32
--- /dev/null
+++ b/src/main/java/objects/Article.java
@@ -0,0 +1,48 @@
+package objects;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebElement;
+
+import java.util.Objects;
+
+public class Article {
+ private Image img;
+ private String tag;
+ private Link link;
+
+ public Article(Image img, String tag, Link link) {
+ this.img = img;
+ this.tag = tag;
+ this.link = link;
+ }
+
+ public Article(WebElement element) {
+ this.img = new Image(element.findElement(By.cssSelector("img")));
+ this.tag = element.findElement(By.cssSelector("span")).getText();
+ this.link = new Link(element.findElement(By.cssSelector("a")));
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ Article article = (Article) o;
+ return Objects.equals(img, article.img) &&
+ Objects.equals(tag, article.tag) &&
+ Objects.equals(link, article.link);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(img, tag, link);
+ }
+
+ @Override
+ public String toString() {
+ return "Article{" +
+ "img=" + img +
+ ", tag='" + tag + '\'' +
+ ", link=" + link +
+ '}';
+ }
+}
diff --git a/src/main/java/objects/Image.java b/src/main/java/objects/Image.java
new file mode 100644
index 0000000..4658441
--- /dev/null
+++ b/src/main/java/objects/Image.java
@@ -0,0 +1,47 @@
+package objects;
+
+import org.openqa.selenium.WebElement;
+
+import java.util.Objects;
+
+public class Image {
+ private String src;
+ private String height;
+ private String width;
+
+ public Image(String src, String height, String width) {
+ this.src = src;
+ this.height = height;
+ this.width = width;
+ }
+
+ public Image(WebElement element) {
+ this.src = element.getAttribute("src");
+ this.height = element.getAttribute("height");
+ this.width = element.getAttribute("width");
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ Image image = (Image) o;
+ return Objects.equals(src, image.src) &&
+ Objects.equals(height, image.height) &&
+ Objects.equals(width, image.width);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(src, height, width);
+ }
+
+ @Override
+ public String toString() {
+ return "Image{" +
+ "src='" + src + '\'' +
+ ", height='" + height + '\'' +
+ ", width='" + width + '\'' +
+ '}';
+ }
+}
diff --git a/src/main/java/objects/Link.java b/src/main/java/objects/Link.java
new file mode 100644
index 0000000..ea61241
--- /dev/null
+++ b/src/main/java/objects/Link.java
@@ -0,0 +1,42 @@
+package objects;
+
+import org.openqa.selenium.WebElement;
+
+import java.util.Objects;
+
+public class Link {
+ private String url;
+ private String label;
+
+ public Link(String url, String label) {
+ this.url = url;
+ this.label = label;
+ }
+
+ public Link(WebElement element) {
+ this.url = element.getAttribute("href");
+ this.label = element.getText();
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ Link link = (Link) o;
+ return Objects.equals(url, link.url) &&
+ Objects.equals(label, link.label);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(url, label);
+ }
+
+ @Override
+ public String toString() {
+ return "Link{" +
+ "url='" + url + '\'' +
+ ", label='" + label + '\'' +
+ '}';
+ }
+}
diff --git a/src/main/java/pages/InteractionsPage.java b/src/main/java/pages/InteractionsPage.java
new file mode 100644
index 0000000..f1ffa70
--- /dev/null
+++ b/src/main/java/pages/InteractionsPage.java
@@ -0,0 +1,30 @@
+package pages;
+
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.support.FindBy;
+
+import java.util.List;
+
+public class InteractionsPage {
+ @FindBy(css = "[name='checkboxToClick']") public WebElement checkbox;
+ @FindBy(css = "#radioButtonToClick") public WebElement radioButton;
+ @FindBy(css = "#linkToClick") public WebElement link;
+
+ @FindBy(css = "[type='text']") public WebElement textInput;
+ @FindBy(css = "textarea") public WebElement textArea;
+ @FindBy(css = "[maxlength='100']") public WebElement predefinedTextArea;
+
+ @FindBy(css = "[src*='42514697560_1740d1993f_n.jpg']") public WebElement img;
+ @FindBy(css = ".w3-purple") public WebElement disabledButton;
+
+ @FindBy(css = "#getTextOuterDiv") public WebElement div;
+ @FindBy(css = "#getTextInnerDiv h5") public WebElement h5;
+
+ @FindBy(css = "#getCssValueDiv") public WebElement container;
+ @FindBy(css = "#getCssValueDiv h2") public WebElement h2;
+
+ @FindBy(css = "[name='coffee']") public WebElement coffeeSelectWebElement;
+ @FindBy(css = "[name='refreshment']") public WebElement refreshmentSelectWebElement;
+
+ @FindBy(css = "h1") public WebElement h1;
+}
diff --git a/src/main/java/pages/SeOOPage.java b/src/main/java/pages/SeOOPage.java
new file mode 100644
index 0000000..d398d26
--- /dev/null
+++ b/src/main/java/pages/SeOOPage.java
@@ -0,0 +1,11 @@
+package pages;
+
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.support.FindBy;
+
+import java.util.List;
+
+public class SeOOPage {
+ @FindBy(css = "article") public
+ List elements;
+}
diff --git a/src/main/java/pages/TabsPage.java b/src/main/java/pages/TabsPage.java
new file mode 100644
index 0000000..c0dd8d3
--- /dev/null
+++ b/src/main/java/pages/TabsPage.java
@@ -0,0 +1,10 @@
+package pages;
+
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.support.FindBy;
+
+public class TabsPage {
+ @FindBy(css = "[href*='secondpage']") public WebElement linkToSecondPage;
+ @FindBy(css = "[href*='thirdpage']") public WebElement linkToThirdPage;
+ @FindBy(css = "h1") public WebElement h1;
+}
diff --git a/src/main/java/tutorialSolution/pages/BasicPage.java b/src/main/java/tutorialsolution/pages/BasicPage.java
similarity index 71%
rename from src/main/java/tutorialSolution/pages/BasicPage.java
rename to src/main/java/tutorialsolution/pages/BasicPage.java
index ddbb1bb..ced5d76 100644
--- a/src/main/java/tutorialSolution/pages/BasicPage.java
+++ b/src/main/java/tutorialsolution/pages/BasicPage.java
@@ -1,4 +1,4 @@
-package tutorialSolution.pages;
+package tutorialsolution.pages;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
@@ -28,10 +28,10 @@ public class BasicPage {
@FindBy(css = "div")
public List divElements;
//image whose width attribute equals 189
- @FindBy(css = "img[width='189']")
+ @FindBy(css = "[width='189'][height='125']")
public WebElement imageWithSpecifiedWidth;
//image whose sources (src) attribute contains 1878
- @FindBy(css = "img[src*='1878']")
+ @FindBy(css = "[src*='1878']")
public WebElement imageWithSrcContains;
//relativity: first button from the module with id relativeModule
@FindBy(css = "#relativeModule button")
@@ -51,6 +51,8 @@ public class BasicPage {
public WebElement level2SiblingsWithDifferentTags;
@FindBy(css = "#level2SiblingsSameTag h3")
public List level2SiblingsSameTag;
+ @FindBy(css = "#level2SiblingsSameTagAndClass .someClass")
+ public WebElement level2SiblingsSameTagAndAlphaHasClass;
@FindBy(css = "select[name='BRAVO'] option")
public List dropdownOptions;
@FindBy(css = "#BRAVOUL li")
@@ -61,7 +63,19 @@ public class BasicPage {
public WebElement level3;
@FindBy(css = "#level3AEqualsB div div")
public WebElement level3AlphaEqualsBravo;
+ @FindBy(css = "#level3AEqualsBAHasClass .w3-red")
+ public WebElement level3AlphaEqualsBravoAlphaHasClass;
@FindBy(css = "#level3BravoIdenticalSiblings h3") public List level3BravoIdenticalSiblings;
@FindBy(css = "#level3AllIdenticalSiblings div div") public List level3AllIdentical;
@FindBy(css = "#level3OneBravoSeveralAlphas h3") public List level3OneBravoSeveralAlphas;
+
+ //iframes page
+ //button found inside the frame identified by id
+ @FindBy(css = "#btnForFrameWithId") public WebElement buttonForFrameWithId;
+ //button found inside the frame identified by index
+ @FindBy(css = "#btnForFrameWithIndex") public WebElement buttonForFrameWithIndex;
+ //button found inside the frame identified as a WebElement
+ @FindBy(css = "#btnForFrameAsWebElement") public WebElement buttonForFrameWithName;
+ //selector for identifying frame as WebElement (when frame has no id, name and will not be identified by index)
+ @FindBy(css = "[src*='FrameAsWebElement']") public WebElement frameAsWebElement;
}
diff --git a/src/main/java/tutorialsolution/pages/UserPromptsPage.java b/src/main/java/tutorialsolution/pages/UserPromptsPage.java
new file mode 100644
index 0000000..5c7de04
--- /dev/null
+++ b/src/main/java/tutorialsolution/pages/UserPromptsPage.java
@@ -0,0 +1,11 @@
+package tutorialsolution.pages;
+
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.support.FindBy;
+
+public class UserPromptsPage {
+ @FindBy(css = "#alertButton") public WebElement alertButton;
+ @FindBy(css = "#confirmButton") public WebElement confirmButton;
+ @FindBy(css = "#promptButton") public WebElement promptButton;
+ @FindBy(css = "#userClicked") public WebElement userClicked;
+}
diff --git a/src/main/java/tutorialsolution/pages/WebElementInteractionPage.java b/src/main/java/tutorialsolution/pages/WebElementInteractionPage.java
new file mode 100644
index 0000000..93b2b2a
--- /dev/null
+++ b/src/main/java/tutorialsolution/pages/WebElementInteractionPage.java
@@ -0,0 +1,47 @@
+package tutorialsolution.pages;
+
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.support.FindBy;
+
+public class WebElementInteractionPage {
+ //WebElement with ID
+ @FindBy(css = "#idModuleImage")
+ public WebElement elementWithId;
+
+ //inputs section
+ @FindBy(css = "[name='checkedCheckbox']") public WebElement checkedCheckbox;
+ @FindBy(css = "[name='uncheckedCheckbox']") public WebElement uncheckedCheckbox;
+ @FindBy(css = "#myRadio") public WebElement radioButton;
+
+ //elements for clicking
+ @FindBy(css = "[name='checkboxToClick']") public WebElement checkboxToClick;
+ @FindBy(css = "#radioButtonToClick") public WebElement radioButtonToClick;
+ @FindBy(css = "#buttonToClick") public WebElement buttonToClick;
+ @FindBy(css = "#linkToClick") public WebElement linkToClick;
+
+ //elements for typing
+ @FindBy(css = "[type='text']") public WebElement textInput;
+ @FindBy(css = "textarea") public WebElement textarea;
+
+ //disabled button
+ @FindBy(css = "input[type='button']") public WebElement disabledButton;
+
+ //elements for getText
+ @FindBy(css = "#getTextOuterDiv") public WebElement getTextOuterDiv;
+ @FindBy(css = "#getTextInnerDiv") public WebElement getTextInnerDiv;
+ @FindBy(css = "#getTextInnerDiv h5") public WebElement getTexth5;
+ @FindBy(css = "#getTextInnerDiv img") public WebElement getTextImg;
+ @FindBy(css = "#getTextInnerDiv a") public WebElement getTextLink;
+ @FindBy(css = "#getTextInnerDiv button") public WebElement getTextButton;
+ @FindBy(css = "#getTextInnerDiv select option") public WebElement getTextDropdownFirstOption;
+ @FindBy(css = "[maxlength='100']") public WebElement getTextTextarea;
+
+ //dropdowns
+ @FindBy(css = "[name='coffee']") public WebElement coffeeSelect;
+ @FindBy(css = "[name='tea']") public WebElement teaSelect;
+ @FindBy(css = "[name='refreshment']") public WebElement refreshmentSelect;
+
+ //for getting the CSS attributes
+ @FindBy(css = "h2") public WebElement h2Element;
+ @FindBy(css = "#getCssValueDiv") public WebElement h2DivElement;
+}
diff --git a/src/main/java/tutorialsolution/pages/WindowsPage.java b/src/main/java/tutorialsolution/pages/WindowsPage.java
new file mode 100644
index 0000000..a4993b2
--- /dev/null
+++ b/src/main/java/tutorialsolution/pages/WindowsPage.java
@@ -0,0 +1,10 @@
+package tutorialsolution.pages;
+
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.support.FindBy;
+
+public class WindowsPage {
+ @FindBy(css = "[href*='secondpage']") public WebElement linkToSecondPage;
+ @FindBy(css = "[href*='thirdpage']") public WebElement linkToThirdPage;
+ @FindBy(css = "h1") public WebElement h1Element;
+}
diff --git a/src/main/java/waiter/Waiter.java b/src/main/java/waiter/Waiter.java
new file mode 100644
index 0000000..dfc8641
--- /dev/null
+++ b/src/main/java/waiter/Waiter.java
@@ -0,0 +1,982 @@
+package waiter;
+
+import org.openqa.selenium.JavascriptExecutor;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.support.ui.ExpectedCondition;
+import org.openqa.selenium.support.ui.ExpectedConditions;
+import org.openqa.selenium.support.ui.Wait;
+import org.openqa.selenium.support.ui.WebDriverWait;
+
+/**
+ * A class that holds only Selenium wait methods
+ */
+public class Waiter {
+ //hardcoded timeout value; up to how much to wait for a condition to take place
+ private final int TIMEOUT = 30;
+
+ //GET METHODS
+
+ /**
+ * Open a specified url and wait for the page to load completely.
+ * Should replace driver.get().
+ * Will wait for the TIMEOUT constant value amount of seconds for the page to load.
+ *
+ * @param url - the url to open in the browser
+ * @param driver - the driver instance
+ */
+ public void get(String url, WebDriver driver) {
+ get(url, driver, TIMEOUT);
+ }
+
+ /**
+ * Open a specified url and wait for the page to load completely.
+ * Should replace driver.get().
+ * Will wait for the specified number of seconds.
+ *
+ * @param url - the url to open in the browser
+ * @param driver - the driver instance
+ * @param specifiedTimeout - number of seconds to wait for
+ */
+ public void get(String url, WebDriver driver, int specifiedTimeout) {
+ driver.get(url);
+ waitForPageLoadComplete(driver, specifiedTimeout);
+ }
+
+ /**
+ * Method that opens a url and waits for page load complete and for a specified WebElement to be displayed.
+ * Uses Selenium's isDisplayed() method to check for element.
+ * Wait for up to TIMEOUT.
+ *
+ * @param url - url of the page that needs to open
+ * @param element - the element to wait for
+ * @param driver - the WebDriver instance
+ */
+ public void getAndWaitForElementToBeDisplayed(String url, WebElement element, WebDriver driver) {
+ getAndWaitForElementToBeDisplayed(url, element, driver, TIMEOUT);
+ }
+
+ /**
+ * Method that opens a url and waits for page load complete and for a specified WebElement to be displayed.
+ * Uses Selenium's isDisplayed() method to check for element.
+ * Wait for up to the specified amount of seconds.
+ *
+ * @param url - url of the page that needs to open
+ * @param element - the element to wait for
+ * @param driver - the WebDriver instance
+ * @param specifiedTimeout - number of seconds to wait for
+ */
+ public void getAndWaitForElementToBeDisplayed(String url, WebElement element, WebDriver driver, int
+ specifiedTimeout) {
+ get(url, driver, specifiedTimeout);
+ waitForElementToBeDisplayed(element, driver, specifiedTimeout);
+ }
+
+ /**
+ * Method that opens a URL in the browser and waits for another URL to be loaded.
+ * Also waits for page to load completely after expected URL is loaded in the browser.
+ * Useful when a URL you want to open performs a redirect to another page.
+ * Wait for TIMEOUT number of seconds.
+ *
+ * @param urlToGet - the URL to open initially
+ * @param urlToWaitFor - the URL you expect to be redirected to
+ * @param driver - the WebDriver instance
+ */
+ public void getUrlAndWaitForUrl(String urlToGet, String urlToWaitFor, WebDriver driver) {
+ getUrlAndWaitForUrl(urlToGet, urlToWaitFor, driver, TIMEOUT);
+ }
+
+ /**
+ * Method that opens a URL in the browser and waits for another URL to be loaded.
+ * Also waits for page to load completely after expected URL is loaded in the browser.
+ * Useful when a URL you want to open performs a redirect to another page.
+ * Wait for a specifiedTimeout number of seconds.
+ *
+ * @param urlToGet - the URL to open initially
+ * @param urlToWaitFor - the URL you expect to be redirected to
+ * @param driver - the WebDriver instance
+ * @param specifiedTimeout - number of seconds to wait for
+ */
+ public void getUrlAndWaitForUrl(String urlToGet, String urlToWaitFor, WebDriver driver, int specifiedTimeout) {
+ driver.get(urlToGet);
+ waitForUrl(urlToWaitFor, driver, specifiedTimeout);
+ }
+
+ //PAGE LOAD METHODS
+
+ /**
+ * Wait for a page to load completely for up to TIMEOUT seconds.
+ *
+ * @param driver - the WebDriver instance
+ */
+ public void waitForPageLoadComplete(WebDriver driver) {
+ waitForPageLoadComplete(driver, TIMEOUT);
+ }
+
+ /**
+ * Wait for a page to load completely for the specified number of seconds.
+ *
+ * @param driver - the WebDriver instance
+ * @param specifiedTimeout - amount of seconds you want to wait for
+ */
+ public void waitForPageLoadComplete(WebDriver driver, int specifiedTimeout) {
+ Wait wait = new WebDriverWait(driver, specifiedTimeout);
+ wait.until(driver1 -> String
+ .valueOf(((JavascriptExecutor) driver1).executeScript("return document.readyState"))
+ .equals("complete"));
+ }
+
+ //ELEMENT WAIT METHODS
+
+ /**
+ * Method that waits for the Selenium isDisplayed() method to return true.
+ * Hence waits for an element to be displayed.
+ * Will wait for up to TIMEOUT seconds.
+ *
+ * @param element - the WebElement to be displayed
+ * @param driver - the WebDriver instance
+ */
+ public void waitForElementToBeDisplayed(WebElement element, WebDriver driver) {
+ waitForElementToBeDisplayed(element, driver, TIMEOUT);
+ }
+
+ /**
+ * Method that waits for the Selenium isDisplayed() method to return true.
+ * Hence waits for an element to be displayed.
+ * Will wait for up to the specified amount of seconds.
+ *
+ * @param element - the WebElement to be displayed
+ * @param driver - the WebDriver instance
+ * @param specifiedTimeout - amount of seconds you want to wait for
+ */
+ public void waitForElementToBeDisplayed(WebElement element, WebDriver driver, int specifiedTimeout) {
+ WebDriverWait wait = new WebDriverWait(driver, specifiedTimeout);
+ ExpectedCondition elementIsDisplayed = arg0 -> element.isDisplayed();
+ wait.until(elementIsDisplayed);
+ }
+
+ public void clickWithExpectedConditions(WebElement element, WebDriver driver, int specifiedTimeout) {
+ WebDriverWait wait = new WebDriverWait(driver, specifiedTimeout);
+ wait.until(ExpectedConditions.elementToBeClickable(element));
+ element.click();
+ }
+
+ /**
+ * Try to click on an element during the TIMEOUT number of seconds.
+ *
+ * @param element - the element to click on
+ * @param driver - the WebDriver instance
+ */
+ public void click(WebElement element, WebDriver driver) {
+ click(element, driver, TIMEOUT);
+ }
+
+ /**
+ * Try to click on an element during the specifiedTimeout number of seconds.
+ *
+ * @param element - the element to click on
+ * @param driver - the WebDriver instance
+ * @param specifiedTimeout - amount of seconds you want to wait for
+ */
+ public void click(WebElement element, WebDriver driver, int specifiedTimeout) {
+ WebDriverWait wait = new WebDriverWait(driver, specifiedTimeout);
+ ExpectedCondition elementIsClickable = arg0 -> {
+ try {
+ element.click();
+ return true;
+ } catch (Exception e) {
+ return false;
+ }
+ };
+ wait.until(elementIsClickable);
+ }
+
+ /**
+ * Method that waits for the text on the element to equal an expected String.
+ * Compares the value resulted from getText() on the element with the expected String.
+ * Will wait for up to the TIMEOUT number of seconds for the text on the element to be the expected one.
+ *
+ * @param element - the WebElement whose text will be compared to an expected value
+ * @param expectedString - the expected value of the WebElement's text
+ * @param driver - the WebDriver instance
+ */
+ public void waitForElementTextEqualsString(WebElement element, String expectedString, WebDriver driver) {
+ waitForElementTextEqualsString(element, expectedString, driver, TIMEOUT);
+ }
+
+ /**
+ * Method that waits for the text on the element to equal an expected String.
+ * Compares the value resulted from getText() on the element with the expected String.
+ * Will wait for up to the specifiedTimeout number of seconds for the text on the element to be the expected one.
+ *
+ * @param element - the WebElement whose text will be compared to an expected value
+ * @param expectedString - the expected value of the WebElement's text
+ * @param driver - the WebDriver instance
+ * @param specifiedTimeout - amount of seconds you want to wait for
+ */
+ public void waitForElementTextEqualsString(WebElement element, String expectedString, WebDriver driver, int
+ specifiedTimeout) {
+ WebDriverWait wait = new WebDriverWait(driver, specifiedTimeout);
+ ExpectedCondition elementTextEqualsString = arg0 -> element.getText().equals(expectedString);
+ wait.until(elementTextEqualsString);
+ }
+
+ /**
+ * Method that waits for the text on the element to equal an expected String but ignoring the case of the two.
+ * Compares the value resulted from getText() on the element with the expected String, but without taking into
+ * account the case of the two values.
+ * Therefore, for example 'tHis' and 'This' will be equal when calling this method.
+ * Will wait for up to the TIMEOUT number of seconds for the text on the element to be the expected one.
+ *
+ * @param element - the WebElement whose text will be compared to an expected value
+ * @param expectedString - the expected value of the WebElement's text
+ * @param driver - the WebDriver instance
+ */
+ public void waitForElementTextEqualsString_IgnoreCase(WebElement element, String expectedString, WebDriver driver) {
+ waitForElementTextEqualsString_IgnoreCase(element, expectedString, driver, TIMEOUT);
+ }
+
+ /**
+ * Method that waits for the text on the element to equal an
+ * expected String but ignoring the case of the two.
+ * Compares the value resulted from getText() on the element with the expected String, but without taking into
+ * account the case of the two values.
+ * Therefore, for example 'tHis' and 'This' will be equal when calling this method.
+ * Will wait for up to the specifiedTimeout number of seconds for the text on the element to be the expected one.
+ *
+ * @param element - the WebElement whose text will be compared to an expected value
+ * @param expectedString - the expected value of the WebElement's text
+ * @param driver - the WebDriver instance
+ * @param specifiedTimeout - amount of seconds you want to wait for
+ */
+ public void waitForElementTextEqualsString_IgnoreCase(WebElement element, String expectedString, WebDriver driver,
+ int
+ specifiedTimeout) {
+ WebDriverWait wait = new WebDriverWait(driver, specifiedTimeout);
+ ExpectedCondition elementTextEqualsStringIgnoreCase = arg0 -> element.getText().equalsIgnoreCase
+ (expectedString);
+ wait.until(elementTextEqualsStringIgnoreCase);
+ }
+
+ /**
+ * Method that waits for the text on the element (whose
+ * whitespaces are removed) to equal an expected String (whose whitespaces are also removed).
+ * Basically, does a getText() on the WebElement, removes all whitespaces from this resulting String, then compares
+ * this value to another String that contains no whitespaces.
+ * Whitespaces include: space, new line, tab.
+ * Having said that, only the non whitespace characters are compared.
+ * When calling the method, the expectedString can contain whitespaces, as they are removed inside this method.
+ * Therefore, 'this string here' will equal 'this string here'.
+ * Will wait for up to the TIMEOUT number of seconds for the text on the element to be the expected one.
+ *
+ * @param element - the WebElement whose text will be compared to an expected value after removing the
+ * whitespaces on this text
+ * @param expectedString - the expected value of the WebElement's text on which a whitespace removal is also done
+ * @param driver - the WebDriver instance
+ */
+ public void waitForElementTextEqualsString_IgnoreWhitespaces(WebElement element, String expectedString, WebDriver
+ driver) {
+ waitForElementTextEqualsString_IgnoreWhitespaces(element, expectedString, driver, TIMEOUT);
+ }
+
+ /**
+ * Method that waits for the text on the element (whose
+ * whitespaces are removed) to equal an expected String (whose whitespaces are also removed).
+ * Basically, does a getText() on the WebElement, removes all whitespaces from this resulting String, then compares
+ * this value to another String that contains no whitespaces.
+ * Whitespaces include: space, new line, tab.
+ * When calling the method, the expectedString can contain whitespaces, as they are removed inside this method.
+ * Therefore, 'this string here' will equal 'this string here'.
+ * Will wait for up to the specifiedTimeout number of seconds for the text on the element to be the expected one.
+ *
+ * @param element - the WebElement whose text will be compared to an expected value after removing the
+ * whitespaces on this text
+ * @param expectedString - the expected value of the WebElement's text on which a whitespace removal is also done
+ * @param driver - the WebDriver instance
+ * @param specifiedTimeout - amount of seconds you want to wait for
+ */
+ public void waitForElementTextEqualsString_IgnoreWhitespaces(WebElement element, String expectedString, WebDriver
+ driver, int specifiedTimeout) {
+ WebDriverWait wait = new WebDriverWait(driver, specifiedTimeout);
+ ExpectedCondition elementTextEqualsString = arg0 -> element.getText().replaceAll("\\s", "").equals
+ (expectedString.replaceAll("\\s", ""));
+ wait.until(elementTextEqualsString);
+ }
+
+ /**
+ * Method that waits for the text on the element to contain an expected String.
+ * Checks whether the value resulted from getText() on the element contains the expected String.
+ * Will wait for up to the TIMEOUT number of seconds for the text on the element to contain the expected one.
+ *
+ * @param element - the WebElement whose text will be checked
+ * @param expectedString - the value expected to be contained in the WebElement's text
+ * @param driver - the WebDriver instance
+ */
+ public void waitForElementTextContainsString(WebElement element, String expectedString, WebDriver driver) {
+ waitForElementTextContainsString(element, expectedString, driver, TIMEOUT);
+ }
+
+ /**
+ * Method that waits for the text on the element to contain an expected String.
+ * Checks whether the value resulted from getText() on the element contains the expected String.
+ * Will wait for up to the specifiedTimeout number of seconds for the text on the element to contain the expected
+ * one.
+ *
+ * @param element - the WebElement whose text will be checked
+ * @param expectedString - the value expected to be contained in the WebElement's text
+ * @param driver - the WebDriver instance
+ * @param specifiedTimeout - amount of seconds you want to wait for
+ */
+ public void waitForElementTextContainsString(WebElement element, String expectedString, WebDriver driver, int
+ specifiedTimeout) {
+ WebDriverWait wait = new WebDriverWait(driver, specifiedTimeout);
+ ExpectedCondition elementTextContainsString = arg0 -> element.getText().contains(expectedString);
+ wait.until(elementTextContainsString);
+ }
+
+ /**
+ * Method that waits for the text on the element to contain an expected String but ignoring the case of the two.
+ * Checks whether the value resulted from getText() on the element contains the expected String, but without taking
+ * into account the case of the two values.
+ * Therefore, for example 'tHis' will contain 'his'.
+ * Will wait for up to the TIMEOUT number of seconds for the text on the element to contain the expected one.
+ *
+ * @param element - the WebElement whose text will be checked
+ * @param expectedString - the value expected to be part of the WebElement's text, ignoring the case
+ * @param driver - the WebDriver instance
+ */
+ public void waitForElementTextContainsString_IgnoreCase(WebElement element, String expectedString, WebDriver
+ driver) {
+ waitForElementTextContainsString_IgnoreCase(element, expectedString, driver, TIMEOUT);
+ }
+
+ /**
+ * Method that then waits for the text on the element to contain an
+ * expected String but ignoring the case of the two.
+ * Checks whether the value resulted from getText() on the element contains the expected String, but without taking
+ * into account the case of the two values.
+ * Therefore, for example 'tHis' will contain 'his'.
+ * Will wait for up to the specifiedTimeout number of seconds for the text on the element to be the expected one.
+ *
+ * @param element - the WebElement whose text will be checked
+ * @param expectedString - the value expected to be part of the WebElement's text, ignoring the case
+ * @param driver - the WebDriver instance
+ * @param specifiedTimeout - amount of seconds you want to wait for
+ */
+ public void waitForElementTextContainsString_IgnoreCase(WebElement element, String expectedString, WebDriver driver,
+ int specifiedTimeout) {
+ WebDriverWait wait = new WebDriverWait(driver, specifiedTimeout);
+ ExpectedCondition elementTextContainsString = arg0 -> element.getText().toLowerCase().contains
+ (expectedString.toLowerCase());
+ wait.until(elementTextContainsString);
+ }
+
+ /**
+ * Method that waits for the text on the element (whose
+ * whitespaces are removed) to contain an expected String (whose whitespaces are also removed).
+ * Basically, does a getText() on the WebElement, removes all whitespaces from this resulting String, then checks
+ * that this value contains another String that has no whitespaces.
+ * Whitespaces include: space, new line, tab.
+ * When calling the method, the expectedString can contain whitespaces, as they are removed inside this method.
+ * Therefore, 'this string here' will contain 'str ing here'.
+ * Will wait for up to the TIMEOUT number of seconds for the text on the element to be the expected one.
+ *
+ * @param element - the WebElement whose text will be compared to an expected value after removing the
+ * whitespaces on this text
+ * @param expectedString - the value expected to be part of the WebElement's text on which a whitespace removal is
+ * also done
+ * @param driver - the WebDriver instance
+ */
+ public void waitForElementTextContainsString_IgnoreWhitespaces(WebElement element, String expectedString, WebDriver
+ driver) {
+ waitForElementTextContainsString_IgnoreWhitespaces(element, expectedString, driver, TIMEOUT);
+ }
+
+ /**
+ * Method that waits for the text on the element (whose
+ * whitespaces are removed) to contain an expected String (whose whitespaces are also removed).
+ * Basically, does a getText() on the WebElement, removes all whitespaces from this resulting String, then checks
+ * that this value contains another String that has no whitespaces.
+ * Whitespaces include: space, new line, tab.
+ * When calling the method, the expectedString can contain whitespaces, as they are removed inside this method.
+ * Therefore, 'this string here' will contain 'str ing here'.
+ * Will wait for up to the specifiedTimeout number of seconds for the text on the element to be the expected one.
+ *
+ * @param element - the WebElement whose text will be compared to an expected value after removing the
+ * whitespaces on this text
+ * @param expectedString - the value expected to be part of the WebElement's text on which a whitespace removal is
+ * also done
+ * @param driver - the WebDriver instance
+ * @param specifiedTimeout - amount of seconds you want to wait for
+ */
+ public void waitForElementTextContainsString_IgnoreWhitespaces(WebElement element, String expectedString, WebDriver
+ driver, int specifiedTimeout) {
+ WebDriverWait wait = new WebDriverWait(driver, specifiedTimeout);
+ ExpectedCondition elementTextContainsString = arg0 -> element.getText().replaceAll("\\s", "").contains
+ (expectedString.replaceAll("\\s", ""));
+ wait.until(elementTextContainsString);
+ }
+
+ // Element attribute methods
+
+ /**
+ * Method that waits for an element's specified attribute's value to equal another specified String.
+ * Compares the value resulted from getAttribute(nameOfAttribute) on the element with the expected String.
+ * Will wait for up to the TIMEOUT number of seconds for an element's attribute value to equal an expected String.
+ *
+ * @param element - the WebElement whose attribute we are interested in
+ * @param attribute - the attribute whose value needs to be compared to another value
+ * @param expectedString - the expected value of the WebElement's attribute
+ * @param driver - the WebDriver instance
+ */
+ public void waitForElementAttributeEqualsString(WebElement element, String attribute, String expectedString,
+ WebDriver driver) {
+ waitForElementAttributeEqualsString(element, attribute, expectedString, driver, TIMEOUT);
+ }
+
+ /**
+ * Method that waits for an element's specified attribute's value to equal another specified String.
+ * Compares the value resulted from getAttribute(nameOfAttribute) on the element with the expected String.
+ * Will wait for up to the specified number of seconds for an element's attribute value to equal an expected String.
+ *
+ * @param element - the WebElement whose attribute we are interested in
+ * @param attribute - the attribute whose value needs to be compared to another value
+ * @param expectedString - the expected value of the WebElement's attribute
+ * @param driver - the WebDriver instance
+ * @param specifiedTimeout - amount of seconds you want to wait for
+ */
+ public void waitForElementAttributeEqualsString(WebElement element, String attribute, String expectedString,
+ WebDriver driver, int specifiedTimeout) {
+ WebDriverWait wait = new WebDriverWait(driver, specifiedTimeout);
+ ExpectedCondition elementAttributeEqualsString = arg0 -> element.getAttribute(attribute).equals
+ (expectedString);
+ wait.until(elementAttributeEqualsString);
+ }
+
+ /**
+ * Method that waits for an element's specified attribute's value to equal another specified String, no matter
+ * the case of the actual or expected value.
+ * Compares the value resulted from getAttribute(nameOfAttribute) on the element with the expected String,
+ * ignoring the cases.
+ * Will wait for up to the TIMEOUT number of seconds for an element's attribute value to equal an expected
+ * String, ignoring the cases.
+ *
+ * @param element - the WebElement whose attribute we are interested in
+ * @param attribute - the attribute whose value needs to be compared to another value
+ * @param expectedString - the expected value of the WebElement's attribute, case insensitive
+ * @param driver - the WebDriver instance
+ */
+ public void waitForElementAttributeEqualsString_IgnoreCase(WebElement element, String attribute, String
+ expectedString, WebDriver driver) {
+ waitForElementAttributeEqualsString_IgnoreCase(element, attribute, expectedString, driver, TIMEOUT);
+ }
+
+ /**
+ * Method that waits for an element's specified attribute's value to equal another specified String, no matter
+ * the case of the actual or expected value.
+ * Compares the value resulted from getAttribute(nameOfAttribute) on the element with the expected String,
+ * ignoring the cases.
+ * Will wait for up to the TIMEOUT number of seconds for an element's attribute value to equal an expected String.
+ *
+ * @param element - the WebElement whose attribute we are interested in
+ * @param attribute - the attribute whose value needs to be compared to another value
+ * @param expectedString - the expected value of the WebElement's attribute, case insensitive
+ * @param driver - the WebDriver instance
+ * @param specifiedTimeout - amount of seconds you want to wait for
+ */
+ public void waitForElementAttributeEqualsString_IgnoreCase(WebElement element, String attribute, String
+ expectedString, WebDriver driver, int specifiedTimeout) {
+ WebDriverWait wait = new WebDriverWait(driver, specifiedTimeout);
+ ExpectedCondition elementAttributeEqualsStringIgnoreCase = arg0 -> element.getAttribute(attribute)
+ .equalsIgnoreCase
+ (expectedString);
+ wait.until(elementAttributeEqualsStringIgnoreCase);
+ }
+
+ /**
+ * Method that waits for an element's attribute value (whose whitespaces are removed) to equal an expected
+ * String (whose whitespaces are also removed).
+ * Basically, does a getAttribute(nameOfAttribute) on the WebElement, removes all whitespaces from this resulting
+ * String, then compares this value to another String that contains no whitespaces.
+ * When calling the method, the expectedString can contain whitespaces, as they are removed inside this method.
+ * Whitespaces include: space, new line, tab.
+ * Having said that, only the non whitespace characters are compared.
+ * Therefore, 'this string here' will equal 'this string here'.
+ * Will wait for up to the TIMEOUT number of seconds for expected condition to occur.
+ *
+ * @param element - the WebElement whose attribute will be verified
+ * @param attribute - the attribute whose value will be verified
+ * @param expectedString - the expected value of the WebElement's attribute on which a whitespace removal is also
+ * done
+ * @param driver - the WebDriver instance
+ */
+ public void waitForElementAttributeEqualsString_IgnoreWhitespaces(WebElement element, String attribute, String
+ expectedString, WebDriver driver) {
+ waitForElementAttributeEqualsString_IgnoreWhitespaces(element, attribute, expectedString, driver, TIMEOUT);
+ }
+
+ /**
+ * Method that waits for an element's attribute value (whose whitespaces are removed) to equal an expected
+ * String (whose whitespaces are also removed).
+ * Basically, does a getAttribute(nameOfAttribute) on the WebElement, removes all whitespaces from this resulting
+ * String, then compares this value to another String that contains no whitespaces.
+ * When calling the method, the expectedString can contain whitespaces, as they are removed inside this method.
+ * Whitespaces include: space, new line, tab.
+ * Having said that, only the non whitespace characters are compared.
+ * Therefore, 'this string here' will equal 'this string here'.
+ * Will wait for up to the specified timeout number of seconds for expected condition to occur.
+ *
+ * @param element - the WebElement whose attribute will be verified
+ * @param attribute - the attribute whose value will be verified
+ * @param expectedString - the expected value of the WebElement's attribute on which a whitespace removal is also
+ * done
+ * @param driver - the WebDriver instance
+ * @param specifiedTimeout - the amount of seconds to wait for the condition to occur
+ */
+ public void waitForElementAttributeEqualsString_IgnoreWhitespaces(WebElement element, String attribute, String
+ expectedString, WebDriver driver, int specifiedTimeout) {
+ WebDriverWait wait = new WebDriverWait(driver, specifiedTimeout);
+ ExpectedCondition elementAttributeEqualsStringIW = arg0 -> element.getAttribute(attribute)
+ .replaceAll("\\s", "").equals(expectedString.replaceAll("\\s", ""));
+ wait.until(elementAttributeEqualsStringIW);
+ }
+
+ /**
+ * Method that waits for an element's specified attribute's value to contain another specified String.
+ * Compares the value resulted from getAttribute(nameOfAttribute) on the element with the expected String.
+ * Will wait for up to the TIMEOUT number of seconds for condition to occur.
+ *
+ * @param element - the WebElement whose attribute we are interested in
+ * @param attribute - the attribute whose value needs to be compared to another value
+ * @param expectedString - the expected value of the WebElement's attribute
+ * @param driver - the WebDriver instance
+ */
+ public void waitForElementAttributeContainsString(WebElement element, String attribute, String expectedString,
+ WebDriver driver) {
+ waitForElementAttributeContainsString(element, attribute, expectedString, driver, TIMEOUT);
+ }
+
+ /**
+ * Method that waits for an element's specified attribute's value to contain another specified String.
+ * Compares the value resulted from getAttribute(nameOfAttribute) on the element with the expected String.
+ * Will wait for up to the specified number of seconds for the condition to occur.
+ *
+ * @param element - the WebElement whose attribute we are interested in
+ * @param attribute - the attribute whose value needs to be compared to another value
+ * @param expectedString - the expected value of the WebElement's attribute
+ * @param driver - the WebDriver instance
+ * @param specifiedTimeout - amount of seconds you want to wait for
+ */
+ public void waitForElementAttributeContainsString(WebElement element, String attribute, String expectedString,
+ WebDriver driver, int specifiedTimeout) {
+ WebDriverWait wait = new WebDriverWait(driver, specifiedTimeout);
+ ExpectedCondition elementAttributeContainsString = arg0 -> element.getAttribute(attribute).contains
+ (expectedString);
+ wait.until(elementAttributeContainsString);
+ }
+
+ /**
+ * Method that waits for an element's specified attribute's value to equal another specified String, no matter
+ * the case of the actual or expected value.
+ * Compares the value resulted from getAttribute(nameOfAttribute) on the element with the expected String,
+ * ignoring the cases.
+ * Will wait for up to the TIMEOUT number of seconds for an element's attribute value to equal an expected String.
+ *
+ * @param element - the WebElement whose attribute we are interested in
+ * @param attribute - the attribute whose value needs to be compared to another value
+ * @param expectedString - the expected value of the WebElement's attribute, case insensitive
+ * @param driver - the WebDriver instance
+ */
+ public void waitForElementAttributeContainsString_IgnoreCase(WebElement element, String attribute, String
+ expectedString, WebDriver driver) {
+ waitForElementAttributeContainsString_IgnoreCase(element, attribute, expectedString, driver, TIMEOUT);
+ }
+
+ /**
+ * Method that waits for an element's specified attribute's value to contain another specified String, no matter
+ * the case of the actual or expected value.
+ * Compares the value resulted from getAttribute(nameOfAttribute) on the element with the expected String,
+ * ignoring the cases.
+ * Will wait for up to the specifiedTimeout number of seconds for the expected condition to occur.
+ *
+ * @param element - the WebElement whose attribute we are interested in
+ * @param attribute - the attribute whose value needs to be compared to another value
+ * @param expectedString - the expected value of the WebElement's attribute, case insensitive
+ * @param driver - the WebDriver instance
+ * @param specifiedTimeout - amount of seconds you want to wait for
+ */
+ public void waitForElementAttributeContainsString_IgnoreCase(WebElement element, String attribute, String
+ expectedString, WebDriver driver, int specifiedTimeout) {
+ WebDriverWait wait = new WebDriverWait(driver, specifiedTimeout);
+ ExpectedCondition elementAttributeContainsStringIC = arg0 -> element.getAttribute(attribute)
+ .toLowerCase()
+ .contains(expectedString.toLowerCase());
+ wait.until(elementAttributeContainsStringIC);
+ }
+
+ /**
+ * Method that waits for an element's attribute value (whose whitespaces are removed) to equal an expected
+ * String (whose whitespaces are also removed).
+ * Basically, does a getAttribute(nameOfAttribute) on the WebElement, removes all whitespaces from this resulting
+ * String, then compares this value to another String that contains no whitespaces.
+ * When calling the method, the expectedString can contain whitespaces, as they are removed inside this method.
+ * Whitespaces include: space, new line, tab.
+ * Having said that, only the non whitespace characters are compared.
+ * Therefore, 'this string here' will equal 'this string here'.
+ * Will wait for up to the TIMEOUT timeout number of seconds for expected condition to occur.
+ *
+ * @param element - the WebElement whose attribute will be verified
+ * @param attribute - the attribute whose value will be verified
+ * @param expectedString - the expected value of the WebElement's attribute on which a whitespace removal is also
+ * done
+ * @param driver - the WebDriver instance
+ */
+ public void waitForElementAttributeContainsString_IgnoreWhitespaces(WebElement element, String attribute, String
+ expectedString, WebDriver driver) {
+ waitForElementAttributeContainsString_IgnoreWhitespaces(element, attribute, expectedString, driver, TIMEOUT);
+ }
+
+ /**
+ * Method that waits for an element's attribute value (whose whitespaces are removed) to contain an expected
+ * String (whose whitespaces are also removed).
+ * Basically, does a getAttribute(nameOfAttribute) on the WebElement, removes all whitespaces from this resulting
+ * String, then compares this value to another String that contains no whitespaces.
+ * When calling the method, the expectedString can contain whitespaces, as they are removed inside this method.
+ * Whitespaces include: space, new line, tab.
+ * Having said that, only the non whitespace characters are compared.
+ * Will wait for up to the specified timeout number of seconds for expected condition to occur.
+ *
+ * @param element - the WebElement whose attribute will be verified
+ * @param attribute - the attribute whose value will be verified
+ * @param expectedString - the expected value of the WebElement's attribute on which a whitespace removal is also
+ * done
+ * @param driver - the WebDriver instance
+ * @param specifiedTimeout - the amount of seconds to wait for the condition to occur
+ */
+ public void waitForElementAttributeContainsString_IgnoreWhitespaces(WebElement element, String attribute, String
+ expectedString, WebDriver driver, int specifiedTimeout) {
+ WebDriverWait wait = new WebDriverWait(driver, specifiedTimeout);
+ ExpectedCondition elementAttributeContainsStringIW = arg0 -> element.getAttribute(attribute)
+ .replaceAll("\\s", "")
+ .contains(expectedString.replaceAll("\\s", ""));
+ wait.until(elementAttributeContainsStringIW);
+ }
+
+
+ // URL wait methods
+
+ /**
+ * Wait for a URL to open in the browser and for the page to load completely.
+ * Wait for TIMEOUT number of seconds.
+ *
+ * @param url - the URL to open
+ * @param driver - the WebDriver instance
+ */
+ public void waitForUrl(String url, WebDriver driver) {
+ waitForUrl(url, driver, TIMEOUT);
+ }
+
+ /**
+ * Wait for a URL to open in the browser and for the page to load completely.
+ * Wait for the specifiedTimeout number of seconds.
+ *
+ * @param url - the URL to open
+ * @param driver - the WebDriver instance
+ * @param specifiedTimeout - amount of seconds you want to wait for
+ */
+ public void waitForUrl(String url, WebDriver driver, int specifiedTimeout) {
+ WebDriverWait wait = new WebDriverWait(driver, specifiedTimeout);
+ ExpectedCondition urlIsCorrect = arg0 -> driver.getCurrentUrl().equals(url);
+ wait.until(urlIsCorrect);
+ waitForPageLoadComplete(driver, specifiedTimeout);
+ }
+
+ /**
+ * Wait for a URL containing a specified String to open in the browser.
+ * The URL will not equal the specified String. Just contain it.
+ * Wait for TIMEOUT number of seconds.
+ *
+ * @param expectedString - the String that needs to be included in the URL
+ * @param driver - the WebDriver instance
+ */
+ public void waitForUrlContains(String expectedString, WebDriver driver) {
+ waitForUrlContains(expectedString, driver, TIMEOUT);
+ }
+
+ /**
+ * Wait for a URL containing a specified String to open in the browser.
+ * The URL will not equal the specified String. Just contain it.
+ * Wait for the specifiedTimeout number of seconds.
+ *
+ * @param expectedString - the String that needs to be included in the URL
+ * @param driver - the WebDriver instance
+ * @param specifiedTimeout - amount of seconds you want to wait for
+ */
+ public void waitForUrlContains(String expectedString, WebDriver driver, int specifiedTimeout) {
+ WebDriverWait wait = new WebDriverWait(driver, specifiedTimeout);
+ ExpectedCondition urlIsCorrect = arg0 -> driver.getCurrentUrl().contains(expectedString);
+ wait.until(urlIsCorrect);
+ waitForPageLoadComplete(driver, specifiedTimeout);
+ }
+
+ /**
+ * Wait for an expected URL to load in the browser, but ignore the case of the url.
+ * Compares a lower case value of the actual url in the browser with the lower case value of the expected url.
+ * Wait for the TIMEOUT number of seconds.
+ *
+ * @param url - the url expected to load in the browser, ignoring its case
+ * @param driver - the WebDriver instance
+ */
+ public void waitForUrl_IgnoreCase(String url, WebDriver driver) {
+ waitForUrl_IgnoreCase(url, driver, TIMEOUT);
+ }
+
+ /**
+ * Wait for an expected URL to load in the browser, but ignore the case of the url.
+ * Compares a lower case value of the actual url in the browser with the lower case value of the expected url.
+ * Wait for the specifiedTimeout number of seconds.
+ *
+ * @param url - the url expected to load in the browser, ignoring its case
+ * @param driver - the WebDriver instance
+ * @param specifiedTimeout - amount of seconds you want to wait for
+ */
+ public void waitForUrl_IgnoreCase(String url, WebDriver driver, int specifiedTimeout) {
+ WebDriverWait wait = new WebDriverWait(driver, specifiedTimeout);
+ ExpectedCondition urlIsCorrect = arg0 -> driver.getCurrentUrl().toLowerCase().equals(url.toLowerCase
+ ());
+ wait.until(urlIsCorrect);
+ waitForPageLoadComplete(driver, specifiedTimeout);
+ }
+
+ /**
+ * Wait for a URL containing a specified String to open in the browser, ignoring the case of the url.
+ * Checks whether a lower case value of the actual URL contains a lower case value of the expected String.
+ * Wait for the TIMEOUT number of seconds.
+ *
+ * @param expectedString - the String that needs to be included in the URL
+ * @param driver - the WebDriver instance
+ */
+ public void waitForUrlContains_IgnoreCase(String expectedString, WebDriver driver) {
+ waitForUrlContains_IgnoreCase(expectedString, driver, TIMEOUT);
+ }
+
+ /**
+ * Wait for a URL containing a specified String to open in the browser, ignoring the case of the url.
+ * Checks whether a lower case value of the actual URL contains a lower case value of the expected String.
+ * Wait for the specifiedTimeout number of seconds.
+ *
+ * @param expectedString - the String that needs to be included in the URL
+ * @param driver - the WebDriver instance
+ * @param specifiedTimeout - amount of seconds you want to wait for
+ */
+ public void waitForUrlContains_IgnoreCase(String expectedString, WebDriver driver, int specifiedTimeout) {
+ WebDriverWait wait = new WebDriverWait(driver, specifiedTimeout);
+ ExpectedCondition urlIsCorrect = arg0 -> driver.getCurrentUrl().toLowerCase().contains(expectedString
+ .toLowerCase());
+ wait.until(urlIsCorrect);
+ waitForPageLoadComplete(driver, specifiedTimeout);
+ }
+
+ /**
+ * Wait for the URL in the browser to start with a specified String.
+ * Please see the startsWith method from the String class for details on how this method determines whether a
+ * String starts with another one.
+ * Wait for the TIMEOUT number of seconds.
+ *
+ * @param expectedString - the expected String to be found at the start of the URL loaded in the browser
+ * @param driver - the WebDriver instance
+ */
+ public void waitForUrlStartsWith(String expectedString, WebDriver driver) {
+ waitForUrlStartsWith(expectedString, driver, TIMEOUT);
+ }
+
+ /**
+ * Wait for the URL in the browser to start with a specified String.
+ * Please see the startsWith method from the String class for details on how this method determines whether a
+ * String starts with another one.
+ * Wait for the specifiedTimeout number of seconds.
+ *
+ * @param expectedString - the expected String to be found at the start of the URL loaded in the browser
+ * @param driver - the WebDriver instance
+ * @param specifiedTimeout - amount of seconds you want to wait for
+ */
+ public void waitForUrlStartsWith(String expectedString, WebDriver driver, int specifiedTimeout) {
+ WebDriverWait wait = new WebDriverWait(driver, specifiedTimeout);
+ ExpectedCondition urlIsCorrect = arg0 -> driver.getCurrentUrl().startsWith(expectedString);
+ wait.until(urlIsCorrect);
+ waitForPageLoadComplete(driver, specifiedTimeout);
+ }
+
+ // CLICK AND WAIT METHODS
+
+ /**
+ * Click on a WebElement and than wait for a specified URL to load in the browser.
+ * Wait for TIMEOUT number of seconds.
+ *
+ * @param element - the WebElement to click on
+ * @param url - the URL you need are waiting to load
+ * @param driver - the WebDriver instance
+ */
+ public void clickElementAndWaitForUrl(WebElement element, String url, WebDriver driver) {
+ clickElementAndWaitForUrl(element, url, driver, TIMEOUT);
+ }
+
+ /**
+ * Click on a WebElement and than wait for a specified URL to load in the browser.
+ * Wait for the specifiedTimeout number of seconds.
+ *
+ * @param element - the WebElement to click on
+ * @param url - the URL you need are waiting to load
+ * @param driver - the WebDriver instance
+ * @param specifiedTimeout - amount of seconds you want to wait for
+ */
+ public void clickElementAndWaitForUrl(WebElement element, String url, WebDriver driver, int specifiedTimeout) {
+ click(element, driver);
+ waitForUrl(url, driver, specifiedTimeout);
+ }
+
+ /**
+ * Click on a WebElement and than wait for the URL that loads in the browser to contain a specified String.
+ * Wait for the TIMEOUT number of seconds.
+ *
+ * @param element - the WebElement to click on
+ * @param expectedStringInUrl - the String you expect to be contained in the URL that loads after clicking the
+ * WebElement
+ * @param driver - the WebDriver instance
+ */
+ public void clickElementAndWaitForUrlContains(WebElement element, String expectedStringInUrl, WebDriver driver) {
+ clickElementAndWaitForUrlContains(element, expectedStringInUrl, driver, TIMEOUT);
+
+ }
+
+ /**
+ * Click on a WebElement and than wait for the URL that loads in the browser to contain a specified String.
+ * Wait for the specifiedTimeout number of seconds.
+ *
+ * @param element - the WebElement to click on
+ * @param expectedStringInUrl - the String you expect to be contained in the URL that loads after clicking the
+ * WebElement
+ * @param driver - the WebDriver instance
+ * @param specifiedTimeout - amount of seconds you want to wait for
+ */
+ public void clickElementAndWaitForUrlContains(WebElement element, String expectedStringInUrl, WebDriver driver, int
+ specifiedTimeout) {
+ click(element, driver);
+ waitForUrlContains(expectedStringInUrl, driver, specifiedTimeout);
+ }
+
+ /**
+ * Click on a WebElement and than wait for a specified URL to load in the browser, ignoring the case.
+ * Wait for TIMEOUT number of seconds.
+ *
+ * @param element - the WebElement to click on
+ * @param url - the URL you need are waiting to load
+ * @param driver - the WebDriver instance
+ */
+ public void clickElementAndWaitForUrl_IgnoreCase(WebElement element, String url, WebDriver driver) {
+ clickElementAndWaitForUrl_IgnoreCase(element, url, driver, TIMEOUT);
+ }
+
+ /**
+ * Click on a WebElement and than wait for a specified URL to load in the browser, ignoring the case.
+ * Wait for the specifiedTimeout number of seconds.
+ *
+ * @param element - the WebElement to click on
+ * @param url - the URL you need are waiting to load
+ * @param driver - the WebDriver instance
+ * @param specifiedTimeout - amount of seconds you want to wait for
+ */
+ public void clickElementAndWaitForUrl_IgnoreCase(WebElement element, String url, WebDriver driver, int
+ specifiedTimeout) {
+ click(element, driver);
+ waitForUrl_IgnoreCase(url, driver, specifiedTimeout);
+ }
+
+ /**
+ * Click on a WebElement and than wait for the URL that loads in the browser to contain a specified String,
+ * ignoring the case.
+ * Wait for the TIMEOUT number of seconds.
+ *
+ * @param element - the WebElement to click on
+ * @param expectedStringInUrl - the String you expect to be contained in the URL that loads after clicking the
+ * WebElement
+ * @param driver - the WebDriver instance
+ */
+ public void clickElementAndWaitForUrlContains_IgnoreCase(WebElement element, String expectedStringInUrl, WebDriver
+ driver) {
+ clickElementAndWaitForUrlContains_IgnoreCase(element, expectedStringInUrl, driver, TIMEOUT);
+
+ }
+
+ /**
+ * Click on a WebElement and than wait for the URL that loads in the browser to contain a specified String,
+ * ignoring the case.
+ * Wait for the specifiedTimeout number of seconds.
+ *
+ * @param element - the WebElement to click on
+ * @param expectedStringInUrl - the String you expect to be contained in the URL that loads after clicking the
+ * WebElement
+ * @param driver - the WebDriver instance
+ * @param specifiedTimeout - amount of seconds you want to wait for
+ */
+ public void clickElementAndWaitForUrlContains_IgnoreCase(WebElement element, String expectedStringInUrl, WebDriver
+ driver, int specifiedTimeout) {
+ click(element, driver);
+ waitForUrlContains_IgnoreCase(expectedStringInUrl, driver, specifiedTimeout);
+ }
+
+ /**
+ * Click on a WebElement and wait for the URL in the browser to start with an expected String.
+ * Wait for the TIMEOUT number of seconds.
+ *
+ * @param element - the WebElement to click on
+ * @param expectedString - the String you expected the URL in the browser to start with
+ * @param driver - the WebDriver instance
+ */
+ public void clickElementAndWaitForUrlStartsWith(WebElement element, String expectedString, WebDriver
+ driver) {
+ clickElementAndWaitForUrlStartsWith(element, expectedString, driver, TIMEOUT);
+ }
+
+ /**
+ * Click on a WebElement and wait for the URL in the browser to start with an expected String.
+ * Wait for the specifiedTimeout number of seconds.
+ *
+ * @param element - the WebElement to click on
+ * @param expectedString - the String you expected the URL in the browser to start with
+ * @param driver - the WebDriver instance
+ * @param specifiedTimeout - amount of seconds you want to wait for
+ */
+ public void clickElementAndWaitForUrlStartsWith(WebElement element, String expectedString, WebDriver
+ driver, int specifiedTimeout) {
+ click(element, driver);
+ waitForUrlStartsWith(expectedString, driver, specifiedTimeout);
+ }
+
+ /**
+ * Click on an element and wait for a page refresh. To be used when you want the same page to reload after
+ * clicking an element. For redirect to other pages, use wait for url methods.
+ * Wait for the TIMEOUT number of seconds.
+ *
+ * @param element - the WebElement to click on
+ * @param driver - the WebDriver instance
+ */
+ public void clickElementAndWaitForPageLoadComplete(WebElement element, WebDriver driver) {
+ clickElementAndWaitForPageLoadComplete(element, driver, TIMEOUT);
+ }
+
+ /**
+ * Click on an element and wait for a page refresh. To be used when you want the same page to reload after
+ * clicking an element. For redirect to other pages, use wait for url methods.
+ * Wait for the specifiedTimeout number of seconds.
+ *
+ * @param element - the WebElement to click on
+ * @param driver - the WebDriver instance
+ * @param specifiedTimeout - amount of seconds you want to wait for
+ */
+ public void clickElementAndWaitForPageLoadComplete(WebElement element, WebDriver driver, int specifiedTimeout) {
+ click(element, driver, specifiedTimeout);
+ waitForPageLoadComplete(driver, specifiedTimeout);
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/resources/forFrameAsWebElement.html b/src/main/resources/forFrameAsWebElement.html
new file mode 100644
index 0000000..2dc6bfa
--- /dev/null
+++ b/src/main/resources/forFrameAsWebElement.html
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/resources/forFrameWithId.html b/src/main/resources/forFrameWithId.html
new file mode 100644
index 0000000..2d1fa79
--- /dev/null
+++ b/src/main/resources/forFrameWithId.html
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/resources/forFrameWithIndex.html b/src/main/resources/forFrameWithIndex.html
new file mode 100644
index 0000000..b0969ed
--- /dev/null
+++ b/src/main/resources/forFrameWithIndex.html
@@ -0,0 +1,8 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/resources/fullPage.html b/src/main/resources/fullPage.html
index 58694cc..4b56718 100644
--- a/src/main/resources/fullPage.html
+++ b/src/main/resources/fullPage.html
@@ -6,13 +6,6 @@
@@ -100,6 +93,11 @@
Sibling
Level 2 siblings with tags identical to ALPHA item