public class WebDriverSessionHandler extends Object
By default the WebDriver Session will get timed out based on the value of timeout configuration for the hub. In some cases, test cases need more time to do a non UI task before coming back to UI related operations. If the non UI task takes more time than the configured timeout value, a RuntimeException with message "Session timed out" occurs.
WebDriverSessionHandler
is used to hold WebDriver session while performing non UI operations.
Code Sample :
Grid.driver().get(https://www.paypal.com); Grid.driver().findElementById("login_email").sendKeys("exampleUser@paypal.com"); Grid.driver().findElementById("login_password").sendKeys("123Abcdef"); Grid.driver().findElementByName("submit.x").click(); WebDriverSessionHandler m = new WebDriverSessionHandler(Grid.driver()); m.start(); //<> m.stop(); Grid.driver().findElementByLinkText("Send Money").click(); assertTrue(Grid.driver().getTitle().equals("Send Money - PayPal"));
Constructor and Description |
---|
WebDriverSessionHandler(org.openqa.selenium.remote.RemoteWebDriver driver)
This constructor creates WebDriverSessionHandler instance.
|
Modifier and Type | Method and Description |
---|---|
void |
start()
start() will start a child thread that will keep pooling the title of the page so
the the web session will not get timeout. |
void |
stop()
stop() will stop the polling child thread. |
public WebDriverSessionHandler(org.openqa.selenium.remote.RemoteWebDriver driver)
driver
- need to pass RemoteWebDriver instance [Grid.driver()]public void start()
start()
will start a child thread that will keep pooling the title of the page so
the the web session will not get timeout.public void stop() throws ExecutionException
stop()
will stop the polling child thread.ExecutionException
- thrown when exceptions occur in the child thread while polling.Copyright © 2016 PayPal Open Source. All rights reserved.