public final class WebDriverFX extends Object implements WebDriver, Executor
private staticWebDriverFXdriver; private static TestModel testModel; @org.junit.BeforeClasspublic static void test() throwsInterruptedException,Exception{ finalURLurl = FindsByTest.class.getResource("testWithModel.html"); driver = newWebDriverFX(url); driver.executeAndWait(newRunnable() { @Overridepublic void run() { testModel = new TestModel("Hello", "World"); testModel.applyBindings(); } }); } @org.junit.Testpublic void withModel() { // please note that this method is not executed in BrwsrCtx // to allow seeing updates in the Browser while debugging a testWebElementelement = driver.findElement(By.id("target"));org.junit.Assert.assertEquals("Hello", element.getText());WebElementbutton = driver.findElement(By.id("button")); button.click();org.junit.Assert.assertEquals("World", element.getText());WebElementinput = driver.findElement(By.id("input")); input.clear(); input.sendKeys("DukeScript"); button.click();org.junit.Assert.assertEquals("DukeScript", element.getText());WebElementfindElement = driver.findElement(By.cssSelector(".bla"));org.junit.Assert.assertNotNull(findElement);org.junit.Assert.assertEquals("DukeScript", findElement.getText()); }
WebDriver.ImeHandler, WebDriver.Navigation, WebDriver.Options, WebDriver.TargetLocator, WebDriver.Timeouts, WebDriver.Window| Constructor and Description |
|---|
WebDriverFX(URL url)
Opens URL in a 800 * 600 Stage.
|
WebDriverFX(URL url,
double width,
double height)
Constructor that allows you to set a size for the browser window.
|
WebDriverFX(javafx.scene.web.WebView view)
Use this constructor only if you need to initialize your webview.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
void |
execute(Runnable command) |
void |
executeAndWait(Runnable command)
Executes a Runnable in BrwsrCtx and waits for it to finish.
|
WebElement |
findElement(By by) |
List<WebElement> |
findElements(By by) |
void |
get(String string) |
String |
getCurrentUrl() |
String |
getPageSource() |
String |
getTitle() |
String |
getWindowHandle() |
Set<String> |
getWindowHandles() |
WebDriver.Options |
manage() |
WebDriver.Navigation |
navigate() |
void |
quit() |
WebDriver.TargetLocator |
switchTo() |
public WebDriverFX(javafx.scene.web.WebView view)
throws Exception
WebDriverFX(URL, double, double)view - an existing webviewException - Might throw InterruptedException or AWTException (uses
Robot)public WebDriverFX(URL url, double width, double height) throws Exception
url - The URL of the page to be loadedwidth - width of the Stageheight - height of the StageException - Might throw InterruptedException or AWTException (uses
Robot)public String getCurrentUrl()
getCurrentUrl in interface WebDriverpublic List<WebElement> findElements(By by)
findElements in interface SearchContextfindElements in interface WebDriverpublic WebElement findElement(By by)
findElement in interface SearchContextfindElement in interface WebDriverpublic String getPageSource()
getPageSource in interface WebDriverpublic Set<String> getWindowHandles()
getWindowHandles in interface WebDriverpublic String getWindowHandle()
getWindowHandle in interface WebDriverpublic WebDriver.TargetLocator switchTo()
public WebDriver.Navigation navigate()
public WebDriver.Options manage()
public void executeAndWait(Runnable command) throws InterruptedException
command - The command to executeInterruptedException - (uses CountDownLatch)Copyright © 2017. All rights reserved.