Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

Crosswalk WebDriver

YangangHan edited this page Jan 7, 2015 · 9 revisions

Introduction

WebDriver is an open source tool for automated testing of webapps across many browsers. It provides capabilities for navigating to web pages, user input, JavaScript execution, and more. Crosswalk WebDriver(CrosswalkDriver) is a standalone server which implements WebDriver's wire protocol for Crosswalk. Part of code is ported from ChromeDriver.

Please feel free to send an email to mailto:[email protected] or https://lists.crosswalk-project.org/mailman/listinfo/crosswalk-dev if you have any questions, help with troubleshooting, and general discussion.

All code is currently in the open source crosswalk project. You can build it or download binary direct.This site hosts CrosswalkDriver documentation, issue tracking, and releases.

You can also download binary from https://github.com/crosswalk-project/crosswalk-web-driver/blob/master/bin/xwalkdriver.

For Linux xwalk:

(1) Build XwalkDriver by building the 'xwalkdriver' target and get an executable binary in the build folder named 'xwalkdriver'.

(2) Build 'xwalk' target, install it in "/opt/crosswalk" or working path of 'xwalkdriver'.

(3) Use following python instructions to do a basic test.

$ export PYTHONPATH=~/path/to/xwalkdriver/server:~/path/to/xwalkdriver/client
$ python
>>> import server
>>> import xwalkdriver
>>> cd_server = server.Server('/path/to/xwalkdriver/executable')
>>> driver = xwalkdriver.XwalkDriver(cd_server.GetUrl())
>>> driver.Load('http://www.google.com')
>>> driver.Quit()
>>> cd_server.Kill()

For Android xwalk:

(1) Build XwalkDriver by building the 'xwalkdriver' target and get an executable binary in the build folder named 'xwalkdriver'.(Details referred to ../README.md).

(2) Get Crosswalk for Android from Download page.

(3) Pakage your app by execute command

python make_apk.py --package=`package_name` --manifest=`manifest_file` --arch=`device_architecture` --enable-remote-debugging

(4) Install your apk to device.

(5) Install Selenium package by executing command

pip install selenium

(6) Run xwalkdriver binary.

$./xwalkdriver

(7) Execute following commands to test:

$ python
>>> from selenium import webdriver
>>> capabilities = {
  'xwalkOptions': {
    'androidPackage': 'YOUR_PACKAGE_NAME',
    'androidActivity': '.YOUR_ACTIVITY_NAME',
    'adb-port': 5037(default option if not selected),
  }
}
>>> driver = webdriver.Remote('http://localhost:9515', capabilities)
>>> driver.save_screenshot("screenshot.png")
>>> driver.title
>>> driver.quit()

For Tizen xwalk:

(1) Check status of sdbd_tcp.service on Tizen IVI, start it if necessary:

sh-4.3$ su
sh-4.3# systemctl status sdbd_tcp
sh-4.3# systemctl start sdbd_tcp

(2) Connect Tizen IVI and PC with sdb:

han@hanlab:~$ sdb connect 
han@hanlab:~$ sdb root on
han@hanlab:~$ sdb push webapi.xpk /home/app/

(3) Install and Launcher the xwalk as server mode on Tizen IVI:

sh-4.3# su - app
app@ivi_box:~$ systemctl --user status xwalk
app@ivi_box:~$ pkgcmd -i -t xpk -q -p /home/app/webapi.xpk

(4) Set remote debug port by insert "--remote-debugging-port=9333" into "/usr/lib/systemd/user/xwalk.service" On Tizen IVI.

(5) Restart the xwalk.service on Tizen IVI:

app@ivi_box:~$ systemctl --user daemon-reload
app@ivi_box:~$ systemctl --user restart xwalk   

(6) If Selenium package is not installed on PC. Install it by executing command:

han@hanlab:~$ sudo apt-get install python-pip && pip install selenium

(7) Run xwalkdriver binary on PC.

$./xwalkdriver

(8) Execute following commands to test, before start Python, make sure your PC environment has no proxy for localhost.

$ unset http_proxy
$ unset https_proxy
$ python
>>> from selenium import webdriver
>>> 
capabilities = {
  'xwalkOptions': {
    'tizenDebuggerAddress': '10.238.158.97:9333',
    'tizenAppId': 'xwalk.ihogjblnkegkonaaaddobhoncmdpbomi',
    'sdb-port': 26099(default option if not selected),
  }
}
>>> driver = webdriver.Remote('http://localhost:9515', capabilities)
>>> driver.title
>>> driver.save_screenshot("screenshottest.png")
>>> driver.quit()

Related Links

Clone this wiki locally