4.1+54.11 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 54.10) 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()
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()
54.11.1 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.
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||