SeleniumWebdriver
Extends Helper
SeleniumWebdriver helper is based on the official Selenium Webdriver JS library. It implements common web api methods (amOnPage, click, see).
Backends
Selenium Installation
- Download Selenium Server
- For Chrome browser install ChromeDriver, for Firefox browser install GeckoDriver.
- Launch the server:
java -jar selenium-server-standalone-3.xx.xxx.jar
. To locate Chromedriver binary use-Dwebdriver.chrome.driver=./chromedriver
option. For Geckodriver use-Dwebdriver.gecko.driver=
.
PhantomJS Installation
PhantomJS is a headless alternative to Selenium Server that implements the WebDriver protocol. It allows you to run Selenium tests on a server without a GUI installed.
- Download PhantomJS
- Run PhantomJS in WebDriver mode:
phantomjs --webdriver=4444
Configuration
This helper should be configured in codecept.json or codecept.conf.js
url
- base url of website to be testedbrowser
- browser in which perform testingdriver
- which protractor driver to use (local, direct, session, hosted, sauce, browserstack). By default set to 'hosted' which requires selenium server to be started.restart
- restart browser between tests (default: true).smartWait
: (optional) enables SmartWait; wait for additional milliseconds for element to appear. Enable for 5 secs: "smartWait": 5000disableScreenshots
(optional, default: false) - don't save screenshot on failureuniqueScreenshotNames
(optional, default: false) - option to prevent screenshot override if you have scenarios with the same name in different suiteskeepBrowserState
(optional, default: false) - keep browser state between tests whenrestart
set to false.keepCookies
(optional, default: false) - keep cookies between tests whenrestart
set to false.*seleniumAddress
- Selenium address to connect (default: http://localhost:4444/wd/hub)waitForTimeout
: (optional) sets default wait time in ms for allwait*
functions. 1000 by default;scriptTimeout
: (optional) sets default timeout for scripts inexecuteAsync
. 1000 by default.windowSize
: (optional) default window size. Set tomaximize
or a dimension in the format640x480
.manualStart
(optional, default: false) - do not start browser before a test, start it manually inside a helper withthis.helpers["WebDriverIO"]._startBrowser()
capabilities
: {} - list of Desired Capabilities
Example:
{
"helpers": {
"SeleniumWebdriver" : {
"url": "http://localhost",
"browser": "chrome",
"smartWait": 5000,
"restart": false
}
}
}
Access From Helpers
Receive a WebDriverIO client from a custom helper by accessing browser
property:
this.helpers['SeleniumWebdriver'].browser
Parameters
config