Skip to content

Latest commit

 

History

History
212 lines (166 loc) · 4.96 KB

client.md

File metadata and controls

212 lines (166 loc) · 4.96 KB

Browser

Key

	const {seleniumWD} = require('promod');
	const {browser} = seleniumWD

	browser.Key // getter - returns keyboard keys

baseUrl

	const {seleniumWD} = require('promod');
	const {browser} = seleniumWD

	browser.baseUrl = 'https://your.app.com' // setter
	const currnetBaseUrl = browser.baseUrl // getter - returns current base url
	await browser.get('/test') // browser will open https://your.app.com/test

getCurrentUrl

	const {seleniumWD} = require('promod');
	const {browser} = seleniumWD

	const url = await browser.getCurrentUrl() // current browser line url

takeScreenshot

	const {seleniumWD} = require('promod');
	const {browser} = seleniumWD

	const screen = await browser.takeScreenshot()

refresh

	const {seleniumWD} = require('promod');
	const {browser} = seleniumWD

	await browser.refresh() // refresh page

getTabs

	const {seleniumWD} = require('promod');
	const {browser} = seleniumWD

	const tabs = await browser.getTabs() // current browser opened tabs

get

	const {seleniumWD} = require('promod');
	const {browser} = seleniumWD

	await browser.get('https://www.npmjs.com/package/promod') // open https://www.npmjs.com/package/promod

setWindowSize

	const {seleniumWD} = require('promod');
	const {browser} = seleniumWD

	await browser.setWindowSize(200, 600) // set window size to width 200, height 600

sleep

	const {seleniumWD} = require('promod');
	const {browser} = seleniumWD

	await browser.sleep(2500) // sleep 2.5 seconds

executeScript

	const {seleniumWD} = require('promod');
	const {browser} = seleniumWD

	await browser.executeScript(() => document.querySelector('a').innerText) // returns result of the script

executeAsyncScript

	const {seleniumWD} = require('promod');
	const {browser} = seleniumWD

	await browser.executeAsyncScript((done) => {
		setTimeout(() => {
			done(document.querySelector('a').innerText)
		}, 2500)
	}) // returns result of the async script

quit

	const {seleniumWD} = require('promod');
	const {browser} = seleniumWD

	await browser.quit() // close session

actions

	const {seleniumWD} = require('promod');
	const {browser} = seleniumWD

	const actionsObj = browser.actions() // returns selenium actions interface

switchTo

	const {seleniumWD} = require('promod');
	const {browser} = seleniumWD

	const switchToObj = browser.switchTo() // returns selenium switchTo interface

navigate

	const {seleniumWD} = require('promod');
	const {browser} = seleniumWD

	const navigateToObj = browser.navigate() // returns selenium navigate interface

getCurrentTab

	const {seleniumWD} = require('promod');
	const {browser} = seleniumWD

	const CurrentTabObj = await browser.getCurrentTab() // returns current browser tab item

getCurrentTab

	const {seleniumWD} = require('promod');
	const {browser} = seleniumWD

	await browser.close() // close current browser tab (if one close window)

getTitle

	const {seleniumWD} = require('promod');
	const {browser} = seleniumWD

	const browserWindowTabTitle = await browser.getTitle();

switchToTab

	const {seleniumWD} = require('promod');
	const {browser} = seleniumWD

	await browser.switchToTab({index: 2}); // will switch context to third browser tab (second tab in tabs array)
	await browser.switchToTab({title: 'Some title'}); // will switch context to browser tab where tab title equals 'Some title'

returnToInitialTab

	const {seleniumWD} = require('promod');
	const {browser} = seleniumWD

	await browser.switchToTab({index: 2}); // will switch context to third browser tab (second tab in tabs array)
	await browser.returnToInitialTab(); // will switch first opened tab and close all other tabs

runNewBrowser

	const {seleniumWD} = require('promod');
	const {browser} = seleniumWD

	await browser.runNewBrowser(); // will runNewBrowser new browser

switchToBrowser

	const {seleniumWD} = require('promod');
	const {browser} = seleniumWD

	await browser.switchToBrowser({index: 0}); // will switch to browser (not tab) which was started first
	await browser.switchToBrowser({title: 'Simple-Automation-Testing/promod: Library for browser manipulation'});
	// will switch to browser (not tab) which has "Simple-Automation-Testing/promod: Library for browser manipulation" title