WebDriver Actions
When writing SenseTalk scripts for testing based on Selenium WebDriver connections, you use WebDriver actions to connect to web browsers or mobile devices, navigate through the pages or mobile apps included in your tests, and perform actions on these pages or apps. SenseTalk includes several commands and functions that let you perform such actions on the web pages being tested.
WebDriver Connections
To use WebDriver actions, you must create an active connection to a web browser. The type of the connection depends on whether you plan to self-host your browsers on your IT infrastructure or whether you plan to use Sauce Labs browser-as-a-service infrastructure.
If you plan to self-host your browsers, you need to use Eggplant Functional's explicit WebDriver connection. A WebDriver connection is similar to the VNC or RDP connection you use for image-based scripting with Eggplant Functional. There are several ways to create a WebDriver connection:
- Use the WebConnect Command.
- Use the WebDriver Function.
- Configure a WebDriver connection through the Connection List in Eggplant Functional.
If you plan to utilize Sauce Labs connections, you should understand that a single Sauce Labs connection logically exposes both a VNC connection and a WebDriver connection. The WebDriver connection is created automatically when the Sauce Labs connection is created and it cannot be managed independently of the VNC connection. Hence, the WebConnect command cannot be used to manage a Sauce Labs connection.
There are several ways to create a Sauce Labs connection:
- Use the Connect Command.
- Configure a the connection through the Connection List in Eggplant Functional.
Once you have a Sauce Labs connection, you can send the Sauce Labs connection WebDriver commands using the exact same syntax as you would for an explicit WebDriver connection.
WebDriverConnection Object Properties
When you create a connection to a web browser by using one of the above approaches, SenseTalk creates a WebDriverConnection object that has a number of properties that provide information about the connection. The following list shows the WebDriverConnection object properties:
-
url: The URL of the page that is currently displayed in the browser. Setting the URL property of a WebDriverConnection object tells the browser to navigate to the specified URL.
-
title: The title (i.e., the value of the Title tag) of the page that is currently displayed in the browser. You cannot change this property.
-
pageSource: The entire HTML source of the page that is currently displayed in the browser. You cannot change this property.
-
alertText: The text of an alert message, if any, that is currently displayed in the browser. You cannot change this property.
-
activeElement: This property is a WebElement object for the active element in the browser. For information about the properties that might be returned, see WebElement Objects. You cannot change this property.
-
cookies: A list of all the cookies associated with the page that is currently displayed in the browser. Each cookie is a property list that includes
name
,value
, and other properties associated with the cookie.You can review the cookies contained in the property:
put the webdriver's cookies // Displays all the cookies
put each item of the webdriver's cookies whose domain is ".testplant.com" // Displays only the specified cookies