SkillAgentSearch skills...

Awb

Framework for browser UI automation

Install / Use

/learn @Simple-Automation-Testing/Awb

README

<h1>Another webdriver binding</h1>

UI automated testing framework powered by Node.js. Uses the Selenium WebDriver API. Uses the ChromeDriver API

Contributing guide here

Base: lazy elements, chrome driver dirrect connection, own standalone server, chrome and gecko driver installer

npm downloads Build Status Install Node.js and install framework

$ npm i --SD awb

Drivers installation

$ awb standalone chrome gecko

Run driver selenium-standalone-server or chrome driver

$ awb start standalone  #for standalone
$ awb start chrome  #for chromedriver
$ awb start gecko  #for geckdriver

or postinstall, will install gecko chrome drivers and selenium standalone server

"postinstall": "awb standalone gecko chrome"

Simple as a library

Use with mocha or other test runner </br> </br>

Take a look awb Api

Base example


const awb = require('awb')

const { client, $ } = awb()

async function findInGoogle_potapovDim() {
  const baseURL = 'https://www.google.com.ua/'
  //selectors
  const submitsearch = '[name="btnK"]'
  const inputsearch = '#lst-ib'
  const resultsearch = '#ires .g'
  //elements
  const submitSearch = $(submitsearch).waitForClickable(1000) //lazy element with  expected condition
  const resultSearch = $(resultsearch).waitForElement(1000) //lazy element with  expected condition
  const inputSearch = $(inputsearch)
  // start driver and start driver
  await client.startDriver()
  await client.goTo(baseURL)
  // page activity
  await inputSearch.sendKeys('git hub potapovDim')
  await submitSearch.click()
  const allTextInSelector = await resultSearch.getText()
  console.log(allTextInSelector.includes('potapovDim')) //output: true
  // kill browser and stop driver
  await client.close()
  await client.stopDriver()
}
findInGoogle_potapovDim()

More examples here -> <br> Element util examples here ->

Api

More about DesiredCapabilities

Client

  /*
   * config example, optional, this example config is default config
   */
  const defautlOpts = {
    remote: false, // if remote true startDriver() will not work, default false
    directConnect: false, // if directConnect true directConnect() will run gecko or chrome driver without selenium standalone server, default false
    host: 'localhost', // host, default 'localhost' or '127.0.0.1' or '0.0.0.0'
    port: 4444, // port on what will be runned client driver
    slowTime: 200, // will delay 200 ms every request
    desiredCapabilities: {
      javascriptEnabled: true,
      acceptSslCerts: true,
      platform: 'ANY',
      clientName: 'chrome'
    },
    timeout: 5000 // time what will wait response from driver
  }

  const awb = require('awb')
  const {client, $, $$} = awb(config)
  /*
   * awb() returns element, elements, client instance
   * if run awb without args, will be used default config from example
   */

goTo

  const awb = require('awb')
  const {client} = awb()
  await client.goTo('https://google.com')
  /*
   * args url
   * type string
   */

goToInNewTab

  const awb = require('awb')
  const {client} = awb()
  await client.goTo('https://google.com')
  await client.goToInNewTab('https://facebook.com')
  // will open facebook in new browser tab
  /*
   * args url
   * type string
   */

wait

  const awb = require('awb')
  const {client, $} = awb()
  await client.goTo('https://google.com')
  await client.wait(5000, async () => $('#test').isDisplayed(), 'Test error message')
  /*
   * will wail 5000 ms until appear element with css selector #test
   */

Keys

  const awb = require('awb')
  const { element, client } = awb()
  const el = element('.test.class')
  await el.sendKeys('test name', client.Keys.ENTER) // for submit

getSize

  const awb = require('awb')
  const { element, client } = awb()
  const size = await client.getSize() //{ height: 983, width: 1200 } for example
  /*
   * any args
   * return current window size {height: number, width: number}
   */

dispatchEvent

    const awb = require('awb')
    const { element, client } = awb()
    const div1 = $('.div___1') // event listener mouseenter
    const div2 = $('.div___2') // event listener mouseover
    const div3 = $('.div___3') // event listener mouseleave

    await client.goTo(pathResolver(file))

    await client.dispatchEvent(div1, client.eventsList.mouseEnter)
    await client.dispatchEvent(div2, client.eventsList.mouseOver)
    await client.dispatchEvent(div3, client.eventsList.mouseLeave)
    // will dispatch event

doubleClick

  const awb = require('awb')
  const { element, client } = awb()
  await client.doubleClick($('button')) // will click button element
  await client.doubleClick({x: 100, y: 200}) // will click by coordinates
  /*
   *  args: ElementAWB or object {x: number, y: number}
   */

alert

  const awb = require('awb')
  const { element, client } = awb()
  const alert = client.alert //getter
  // return client alert api

presskeys

  const awb = require('awb')
  const { client } = awb()
  await client.presskeys(client.Keys.F1, client.Keys.F2, client.Keys.F3)
  // will press F1, F2, F3 keys

   /*
   *  args: Keys
   */

accept

await alert.accept()

sendKeys

  const awb = require('awb')
  const { element, client } = awb()
  const prompt = client.alert //getter
  await prompt.sendKeys('test') //set test to prompt box
  await prompt.accept() // accept prompt box

dismiss

 await alert.dismiss()

getText

const alertText =  await alert.getText()
/*
return text from alert
*/

maximizeWindow

  const awb = require('awb')
  const { element, client } = awb()
  await client.maximizeWindow()
  // will maximize browser window

localStorage

  const awb = require('awb')
  const { element, client } = awb()
  const localStorage = client.localStorage //getter
 // return client localStorage api

get

const token = await localStorage.get('token')
/*
  args key = string
  return value
*/

set

 await localStorage.set('token', 'test-token')
/*
  args: key = string, value = string
*/

clear

 await localStorage.clear()
 /*
  clear all localStorage data
 */

getAll

 const data = await localStorage.getAll()
 /*
 return all localStorage data
 */

sessionStorage

  const awb = require('awb')
  const
View on GitHub
GitHub Stars19
CategoryDevelopment
Updated2y ago
Forks11

Languages

HTML

Security Score

80/100

Audited on Jul 13, 2023

No findings