The WebDriverConnection SUT API provides classes and interfaces to enable using Selenium WebDriver Java API
inside a 'SUT script'. With this kind of bridge you can use your existing Selenium WebDriver
scripts inside a 'SUT script' of QF-Test. You can even combine the Pseudo DOM API
(section 53.11) with Selenium WebDriver based scripts.
NoteThis API is only usable if the browser is connected to QF-Test using connection mode "WebDriver".
Calls on the returned WebDriver-object are automatically synchronized and guarded by a time-out.
| from webdriver import WebDriverConnection
from org.openqa.selenium import By
wdc = WebDriverConnection(rc)
driver = wdc.getDriver()
# driver now of type org.openqa.selenium.WebDriver
element = driver.findElement(By.cssSelector(".myClass"))
# element is now of type org.openqa.selenium.WebElement
# You can call WebDriver-Methods directly on the element
element.click()
# Objects of type WebElement can be mapped to the QF-Test Pseudo DOM API
node = wdc.getComponent(element)
# and assigned to a component in the component tree
rc.overrideElement("Your-QF-Test-Id",node)
# Also, a QF-Test component can be translated to a WebElement object
node = rc.getComponent("QF-Test-Id-Of-Some-Textfield")
element = wdc.getElement(node)
# and interacted using WebDriver-methods
element.clear() |
|
| | Example 53.43: WebDriver-Usage in a Jython SUT Script | |
NoteThe WebDriver-Object is extended by methods to control the automatic timeout.
| import de.qfs.WebDriverConnection
def wdc = new WebDriverConnection(rc)
def driver = wdc.getDriver()
print sprintf("Current timeout: %d ms", driver.getCallTimeout())
driver.setCallTimeout(30000) # 30 sec
driver.get("http://www.slowpage.com") # Slow WebDriver-Action
driver.resetCallTimeout()
|
|
| | Example 53.44: WebDriver-Timeout Control (Groovy Script) | |
Following is a list of the methods of the WebDriverConnection
class in alphabetical order. The syntax used is a bit of a
mixture of Java and Python. Python doesn't support static
typing, but the parameters are passed on to Java, so they must be
of the correct type to avoid triggering exceptions.
If a parameter is followed by an '=' character and a value, that
value is the default and the parameter is optional.
|
| | Object getComponent(WebElement element, String windowname=None) | |
Parameters | element | The WebDriver WebElement. | windowname | The windowname of the Browser of which the WebElement is requested. | Returns |
The corresponding QF-Test component.
| | WebDriver getDriver(String windowname=None) | |
Parameters | windowname | The windowname of the Browser of which the WebDriver is requested. | Returns |
The WebDriver instance.
| | WebElement getElement(Object componentOrId) | |
Parameters | componentOrId | The QF-Test component or its QF-Test component id. | Returns |
The WebDriver WebElement object of the component.
| | WebDriver getUnmanagedDriver(String browserType=None, DesiredCapabilities desiredCapabilities=None) | |
Parameters | browserType | The type of browser to be tested (see 'Browser type').
Is this parameter empty or unset, the browserName capability of the
desiredCapabilities is inspected. If this is also not set, the value of the
'Browser type' attribute of the 'Start web engine' step starting the SUT
is used. | desiredCapabilities | The DesiredCapabilities, which should be handed over to
the WebDriver instance. | Returns |
The WebDriver instance.
| |
|
|