4.1+52.12
WebDriver SUT API

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 52.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 52.54:  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 52.55:  WebDriver-Timeout Control (Groovy Script)

The WebDriverConnection class

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)
Get the QF-Test component of a given WebDriver WebElement. This component could then be used with the other API's QF-Test provides.(e.g. the Pseudo DOM-API in section 52.11)
Parameters
elementThe WebDriver WebElement.
windownameThe windowname of the Browser of which the WebElement is requested.
Returns The corresponding QF-Test component.
 
WebDriver getDriver(String windowname=None)
Get the WebDriver instance used to interact with a browser in WebDriver mode. Requires, that a web page was opened using a 'Start web engine' step.
Parameters
windownameThe windowname of the Browser of which the WebDriver is requested.
Returns The WebDriver instance.
 
WebElement getElement(Object componentOrId)
Get the WebDriver WebElement of the given QF-Test component or the QF-Test component id.
Parameters
componentOrIdThe 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)
Get a WebDriver instance with the specified browser type. As long as no page has been opened with a 'Start web engine' step, the WebDriver instance is not monitored by QF-Test, so web pages and their components are not automatically detected by QF-Test. Interaction with the web page is only possible by the means of the embedded Selenium API, and checks have to be performed using rc.check and rc.checkEqual (see section 11.1)
Parameters
browserTypeThe 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.
desiredCapabilitiesThe DesiredCapabilities, which should be handed over to the WebDriver instance.
Returns The WebDriver instance.