https://github.com/webbestmaster/web-driver
https://github.com/webbestmaster/web-driver
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/webbestmaster/web-driver
- Owner: webbestmaster
- Created: 2016-06-17T16:10:25.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2016-09-13T14:00:40.000Z (almost 10 years ago)
- Last Synced: 2025-01-14T23:46:21.189Z (over 1 year ago)
- Language: JavaScript
- Size: 42.7 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
add options for all browsers - chrome = require('selenium-webdriver/chrome')
urlPostfix - add postfix after url (default: '') - f.e. urlPostfix=?tablet=1
url - push custom url instead default url (default: 'http://gala-bingo/') - f.e. url=http://m.galabingo.com
browser - set browser (default: chrome) - f.e. browser=firefox
list - list of test (default: false, e.g. all tests) - f.e. list=login,logout
host - run on mobile device (default: ''), if use '+host' or 'host=true' - will be run om mobile device
tablet - use tablet mode (default: false), f.e. +tablet of tablet=true
ua - set user agent, f.e. ua=io7iPad
log - set logging (default: true), f.e. +log
// package.json has dependency "nodemailer" it will be used in future
how to run test on mobile device
1 - download and install: android-server-2.21.0.apk
1.1 - if needed install KiesSetup.exe or Kies_3.2.14113_3.exe
2 - download android SDK
3 - connect device and PC
4 - go to ~sdk/platform-tools/, there you will see 'adb.exe' file
5 - run from cmd 'adb devices' or '$./adb devices' to see list of connected devices, if list is empty install Keis (see 1.1)
6 - run from cmd 'adb forward tcp:8080 tcp:8080' to listen :8080 (use the same port for webdriver host f.e 'http://localhost:8080/wd/hub' )
run webdriver on device and run test with follow constructor
var webDriver = require('selenium-webdriver');
var driver = new webDriver
.Builder()
.usingServer('http://localhost:8080/wd/hub') // leave empty ( .usingServer() or with '' ) to use regular port
.withCapabilities({ browserName: args.browser })
.build();
done
Appendix
Path to node interpreter /usr/local/bin/node
Install apk to device from pc
$./adb -s \ -e install -r android-server.apk
Start the Android WebDriver application through the UI of the device or by running this command:
$./adb -s \ shell am start -a android.intent.action.MAIN -n org.openqa.selenium.android.app/.MainActivity
You can start the application in debug mode, which has more verbose logs by doing:
$./adb -s \ shell am start -a android.intent.action.MAIN -n org.openqa.selenium.android.app/.MainActivity -e debug true
You can close the application:
$./adb shell am force-stop org.openqa.selenium.android.app
Finally, we need to expose this server to the Selenium clients running the tests adding a port forward. Identify a PC local port that is not in use and execute this command:
adb -s \ forward tcp:\ tcp:8080
// here is java
// \ - you can use just 'localhost'
DesiredCapabilities browser = DesiredCapabilities.android();
WebDriver driver = new RemoteWebDriver(new URL("http://\:\/wd/hub"), browser);