UI automated testing framework powered by Node.js. Uses the Selenium WebDriver API. Uses the ChromeDriver API
Base: lazy elements, chrome driver dirrect connection, own standalone server and chrome driver installer
Install Node.js and install framework
Improvement plan
- Run selenium server from a client instance method
- Add possibility find element by xpath (done)
- Develop error handler system
- Develop and improve enviroment installer for every OS
$ npm i --SD wd-interface
Drivers installation
$ wd-interface standalone chrome gecko
Run driver selenium-standalone-server or chrome driver
$ wd-interface start standalone #for standalone $ wd-interface start chrome #for chromedriver $ wd-interface start gecko #for geckdriver
or postinstall, will install gecko chrome drivers and selenium standalone server
"postinstall": "wd-interface standalone gecko chrome"
Simple as a library
Use with mocha or other test runner
Api
Base exampleconst expect = const client element =
Api
- Browser
- Elements
- Element
Browser
const client = const browserChrome = // for chrome browser const browserFirefox = //for firefox browser /* return browser api instance * args directConnect bool true to chrome or gecko driver , false for connect to standalone server * timeouts = { * 'script': 5000, // Sets the amount of time to wait for an asynchronous script to finish execution before throwing an error. * 'implicit': 5000, // Specifies the amount of time the driver should wait when searching for an element if it is not immediately present. * 'page load': 5000, // Sets the amount of time to wait for a page load to complete before throwing an error. * 'request': 1000 // Sets the amount of time to wait for a response from driver. * } * * any, false , undefined - conncect to standalone server port 4444 * */
chrome
const chromeWithDirrectConnectToChromeDriverAndScriptWaitTenSeconds = const defaultChrome =
firefox
const fireFoxWithPageLoadNineSecondsAndConnectToStandalone = const defaultFireFox =
goTo
const browser = client await browser /* args url * type string * /
Keys
const browser = client const el = await el // for submit
localStorage
const browser = client const localStorage = browserlocalStorage //getter // return browser localStorage api
get
const token = await localStorage/* args key = string return value*/
set
await localStorage/* args: key = string, value = string*/
clear
await localStorageclear /* clear all localStorage data */
getAll
const data = await localStorage /* return all localStorage data */
sessionStorage
const browser = client const sessionStorage = browsersessionStorage //getter // return browser sessionStorage api
get
const token = await sessionStorage/* args key = string return value*/
set
await sessionStorage/* args: key = string, value = string*/
clear
await sessionStorageclear /* clear all sessionStorage data */
getAll
const data = await sessionStorage /* return all sessionStorage data */
startSelenium
const browser = client await browser /* * it will start selenium process * if selenium standalone chromedriver geckdriver was install * /
stopSelenium
const browser = client await browser /* * it will stop selenium process * if it was runned by previous command * /
closeCurrentTab
const browser = client await browser /* * will close current tab * if opened tabs length more than 1 * /
waitForUrlIncludes
const browser = client await browser /* * will wait 1000ms for url includes test * /
switchToFrame
const browser = client await browser /* * arg css selector (id , class or some atribute) * /
refresh
const browser = client await browser /* * refresh browser current page * /
back
const browser = client await browser /* * browser histor go back * /
forward
const browser = client await browser /* * browser histor go forward * /
getTitle
const browser = client const currentTitle = await browser /* * will return tab title * /
executeScript
const browser = client const currentTitle = await browser /* first arg is function or string function ,for example 'return arguments[0]' * if function return value it will be returned * /
executeScriptAsync
const browser = client const currentTitle = await browser /* first arg is function or string function ,for example 'return arguments[0]' * if function return value it will be returned * /
switchToTab
const browser = client await browser /* for example if was opened link with _blank * will switch to opened tab * /
closeBrowser
const browser = client await browser /* for example if was focused tab from switchToTab example * this will close current tab and focus you to previous * /
getCurrentBrowserTab
const browser = client const tabId = await browser /* return selenium tab id * /
getBrowserTabs
const browser = client const tabIdS = await browser /* * return array with selenium tab ids */
sleep
const browser = client await browser /* args number timeout * will wait until timeout end */
getUrl
const browser = client const currentUrl = await browser /* return current tab url*/
Element
ConstructorElement
const elementDiv = /* * args css selector for example '#id', '[name="name"]', '.class' */
sendKeys
const elementInput = await elementInput /* * args string or array string */
clear
const elementInput = await elementInputclear /* * clear value inside input */
getElementHTML
const elementInput = const inputHTML = await elementInput /* * return outerHTML of current element , return string * <input value="a"/> for example */
getText
const elementDiv = const divText = await elementDiv /* * return all text inside element , return string */
waitForElement
const elementDiv = /* * will wait for element mount to DOM node */
waitForElementPresent
const elementDiv = /* * will wait for element mount to DOM node */
waitForClicable
const elementDiv = /* * will wait for element mount to DOM node */
waitForElementVisible
const elementDiv = /* * will wait for element visible in DOM node */
getElement
const elementSpan = /* * return element instanse */
getElements
const elementsSpan = /* * return Elements instance */
getAttribute
const elementSpan = const style = await elementSpan /* * args strin , value name , for example 'value', 'href', 'style' etc * return string of attribute value */
click
const elementSpan = await elementSpan /* * triger click */
isPresent
const elementSpan = const present = await elementSpan /* * return true if element mounted to DOM * return false if element didn`t mount to DOM */
isDisplayed
const elementSpan = const display = await elementSpan /* * return true if visible and in view port * return false if doesn`t visible, for example display: none */
toElement
const elementSpan = await elementSpan /* * will scroll view port to element */
mouseDownAndMove
const elementSpan = await elementSpan /* * args object with x and y * will mouse down mouse move from x and y from arg */
Elements
Constructor elements
const elementDiv = const elements = // by css selector const elementsSpan = // by xpath const elementsDiv = /* * args css selector for example '#id', '[name="name"]', '.class' or xpath format xpath: /html/body/div (for example) * return array Element instaces */
waitForElements
const elementDiv = /* * will wait for first element with selector mount to DOM node */
map
// by css selector const elementsSpan = const textArr = await elementsSpan /* * args async call back * return array */
forEach
//by css selector const elementsSpan = const textArr = await elementsSpan /* * args async call back * call async funcs with await * does not return * /
filter
const elementsSpan = const textArr = await elementsSpan /* * args async call back * call async funcs with await * return new elements array * /
get
const elementsSpan = const textArr = await elementsSpan /* * args index number * return Element instance * /