Awesome
Silk AppDriver
Silk AppDriver is an implementation of the W3C WebDriver protocol for native (Windows) and mobile (Android and iOS) applications, built on top of Silk Test. The purpose of this project is to enable users of Silk Test to write tests for all kinds of applications using the WebDriver API in addition to the existing Silk Test APIs.
Prerequisites
- Silk Test 18.0 has to be installed with a valid license. If you don't have Silk Test, download the evaluation version from https://www.microfocus.com/de-de/products/silk-portfolio/silk-test/trial/
- Java (at least 1.8) has to be installed
Running
- Download the latest Silk AppDriver release from GitHub
- Run the Silk AppDriver server from the command line:
java -jar silk-appdriver.jar
- Run your tests against a RemoteWebDriver pointed to that server (http://localhost:8080 by default)
- To use a different port than 8080 run Silk AppDriver with the
server.port
system property, for examplejava -Dserver.port=8123 -jar silk-appdriver.jar
Examples
Here's a minimal example written in Python that automates notepad.exe using Silk AppDriver:
from selenium import webdriver
driver = webdriver.Remote(
command_executor='http://127.0.0.1:8080',
desired_capabilities={'app': '%WINDIR%\\notepad.exe'})
textfield = driver.find_element_by_xpath("//TextField")
textfield.clear()
textfield.send_keys("hello from python!")
driver.find_element_by_xpath("//Menu[@caption='File']").click()
driver.find_element_by_xpath("//MenuItem[@caption='Exit']").click()
driver.find_element_by_xpath("//PushButton[@caption=\"Don't Save\"]").click()
driver.quit()
Further examples can be found here:
- Java (notepad.exe): NotepadDemoTest.java
- Java (mobile app on Android): MobileTests.java
- Python (notepad.exe): notepad.py
- JavaScript (notepad.exe): notepad.js
Building
To build Silk AppDriver on the command line:
- Make sure you have silktest.jtf:18.0 in your local maven repository (See "Adding the JTF to your local Maven repository" in our "Embracing Open Source" blog post.)
- Build the project with maven (
mvn clean install
) - Run the Silk AppDriver server from the command line:
java -jar target/silk-appdriver.jar
To build Silk WebDriver in the IDE:
- Import the Silk AppDriver project into Eclipse (at least 4.6.0) and build with maven.
Architecture
Noteworthy
The controller stub was auto-generated based on the "List of Endpoints" in the WebDriver standard using a simple Silk4J script. That can be found here: appdriver-generate
Current status
Silk AppDriver is still in an early stage and needs your help and contributions to get better!
Locator strategies
Only xpath is currently supported as a locator strategy. Ony "Silk Test xpath" locators will work.
API
The following table lists all methods listed in the W3C spec and the current status of the implementation in Silk AppDriver.
Command | Status | Comment |
---|---|---|
New Session | Done | |
Delete Session | Done | |
Status | Done | |
Get Timeouts | TODO | |
Set Timeouts | TODO | |
Go | Done | Not supported (yields "unknown command") |
Get Current URL | Done | Not supported (yields "unknown command") |
Back | Done | Not supported (yields "unknown command") |
Forward | Done | Not supported (yields "unknown command") |
Refresh | Done | Not supported (yields "unknown command") |
Get Title | Done | |
Get Window Handle | Done | |
Close Window | Done | |
Switch To Window | Done | |
Get Window Handles | Done | |
Switch To Frame | Done | Not supported (yields "unknown command") |
Switch To Parent Frame | Done | Not supported (yields "unknown command") |
Get Window Rect | Done | |
Set Window Rect | Done | |
Maximize Window | Done | |
Minimize Window | Done | |
Fullscreen Window | Done | |
Get Active Element | TODO | |
Find Element | Done | |
Find Elements | Done | |
Find Element From Element | Done | |
Find Elements From Element | Done | |
Is Element Selected | TODO | |
Get Element Attribute | TODO | |
Get Element Property | Done | |
Get Element CSS Value | Done | Not supported (yields "unknown command") |
Get Element Text | Done | |
Get Element Tag Name | Done | Yields the class name |
Get Element Rect | Done | |
Is Element Enabled | Done | |
Element Click | Done | |
Element Clear | Done | |
Element Send Keys | Partly done | Missing: Handling of special keys |
Get Page Source | Done | Not supported (yields "unknown command") |
Execute Script | Done | Not supported (yields "unknown command") |
Execute Async Script | Done | Not supported (yields "unknown command") |
Get All Cookies | Done | Not supported (yields "unknown command") |
Get Named Cookie | Done | Not supported (yields "unknown command") |
Add Cookie | Done | Not supported (yields "unknown command") |
Delete Cookie | Done | Not supported (yields "unknown command") |
Delete All Cookies | Done | Not supported (yields "unknown command") |
Perform Actions | TODO | |
Release Actions | TODO | |
Dismiss Alert | TODO | |
Accept Alert | TODO | |
Get Alert Text | TODO | |
Send Alert Text | TODO | |
Take Screenshot | Done | Takes a screenshot of the entire desktop |
Take Element Screenshot | Done |
TODOs
The biggest TODOs currently are:
- Add more tests!
- Add tests in other Selenium languages!
- Implement the ability to specify more of the Silk Test BaseState options (through capabilities?)
- Implement attribute/property retrieval. Do we need to distinguish between the two?
- Implement handling special keys in
sendKeys
(map to Silk Test keys!) - Implement screenshot API
- Implement customizable timeouts and other options
- Implement window handling and switching between multiple windows
- Add a possibility to get TrueLog files. Maybe we can use
executeScript
with a custom command to start/stop TrueLog? - Implement other locator strategies (by Id, by className, ... should be easy to map to XPath)
- Implement alert handling
- Implement action API
- Add support for mobile and web apps
- The Java client bindings (among others) support a Select helper method. Internally this relies on a couple of specifics (tag name has to be "select", children have to be "options", ...). Can we make that work with our combo boxes as well?
License
Code provided in this repository is licensed under the Apache 2.0.
Contribution
You want to contribute to Silk AppDriver? Great!
Changes may be contributed after signing the Micro Focus Individual Contributor License Agreement 1.0. Signed contributor agreements are to be sent, via PDF, to licensing@microfocus.com. You will be notified via email when the agreement has been accepted by Micro Focus.