クラス WebDriverFormulas
- java.lang.Object
-
- com.kazurayam.inspectus.materialize.selenium.WebDriverFormulas
-
public final class WebDriverFormulas extends java.lang.Object
A collection of WebDriver code snippet that are frequently repeated in UI test cases: 1. wait for an HTML element to be present in a HTML in browser 2. navigate to a URL and wait for the page is completely loaded 3. send click on an HTML element expecting the browser to navigate to a new page, and wait for the new page is comoletely loaded
-
-
コンストラクタの概要
コンストラクタ コンストラクタ 説明 WebDriverFormulas()
-
メソッドの概要
すべてのメソッド インスタンス・メソッド concreteメソッド 修飾子とタイプ メソッド 説明 org.openqa.selenium.support.ui.WebDriverWait
createWebDriverWait(org.openqa.selenium.WebDriver driver, long timeout)
Create an instance of org.openqa.selenium.WebDriverWait.org.openqa.selenium.WebElement
navigateByClick(org.openqa.selenium.WebDriver driver, org.openqa.selenium.By clickThis, org.openqa.selenium.By handleInTheNext, long timeout)
Will assume that we have a web browser is opened with some URL loaded.org.openqa.selenium.WebElement
navigateTo(org.openqa.selenium.WebDriver driver, java.net.URL url, org.openqa.selenium.By handle, long timeout)
will let the browser navigate to the URL specified, wait for the handle element to become present in the new page.org.openqa.selenium.WebElement
waitForElementPresent(org.openqa.selenium.WebDriver driver, org.openqa.selenium.By handle, long timeout)
This will wait for the handle become present in the browser window opened by the driver.
-
-
-
メソッドの詳細
-
navigateByClick
public final org.openqa.selenium.WebElement navigateByClick(org.openqa.selenium.WebDriver driver, org.openqa.selenium.By clickThis, org.openqa.selenium.By handleInTheNext, long timeout) throws org.openqa.selenium.TimeoutException
Will assume that we have a web browser is opened with some URL loaded. Will assume that there is an HTML element to be clicked in the current page. When you invoke this method, it will click the clickThis element. Will assume that the browser will navigate to a new URL by the click. This method will wait for the handleInTheNext element to become present in the new URL. This will wait until the timeout in secods to expire.- パラメータ:
driver
- WebDriver instanceclickThis
- the HTML element in the current web page to clickhandleInTheNext
- will wait for the handle to become in the new pagetimeout
- e.g, 10 seconds- 戻り値:
- If found returns the WebElement pointed by the handleInTheNext By.
- 例外:
org.openqa.selenium.TimeoutException
-
navigateTo
public final org.openqa.selenium.WebElement navigateTo(org.openqa.selenium.WebDriver driver, java.net.URL url, org.openqa.selenium.By handle, long timeout) throws org.openqa.selenium.TimeoutException
will let the browser navigate to the URL specified, wait for the handle element to become present in the new page.- パラメータ:
driver
- WebDriver instanceurl
- the target URL to let browser navigate tohandle
- will wait for the URL is completely loaded and the handle element become present in theretimeout
- e.g, 10 seconds- 戻り値:
- the WebElement that the handle points to
- 例外:
org.openqa.selenium.TimeoutException
-
waitForElementPresent
public final org.openqa.selenium.WebElement waitForElementPresent(org.openqa.selenium.WebDriver driver, org.openqa.selenium.By handle, long timeout) throws org.openqa.selenium.TimeoutException
This will wait for the handle become present in the browser window opened by the driver. will fail if the handle is unpresent after the timeout seconds.- パラメータ:
driver
- WebDriver instancehandle
- By instancetimeout
- e.g, 10 seconds- 戻り値:
- the WebElement that the handle points to
- 例外:
org.openqa.selenium.TimeoutException
-
createWebDriverWait
public final org.openqa.selenium.support.ui.WebDriverWait createWebDriverWait(org.openqa.selenium.WebDriver driver, long timeout)
Create an instance of org.openqa.selenium.WebDriverWait. Please note that Selenium3 and Selenium4 has a difference in the signature of constructor of WebDriverWait. They are incompatible. This createWebDriverWait method absorbs this incompatibility and silently returns an instance of WebDriverWait given with either of Selenium3 or Selenium4 in the CLASSPATH.- パラメータ:
driver
- WebDrivertimeout
- seconds- 戻り値:
- an instance of WebDriverWait
-
-