glance-webdriver

0.8.7 • Public • Published

For a step by step guide to setting up selenium:

http://educate.quasimatic.com/installation/setting-up-selenium

For a guide to run your first selenium glance script:

http://educate.quasimatic.com/selenium/glance-from-scratch

Methods

setLogLevel(level)

		Determine log level :

		error, warning, debug, info, trace

url(address):

		Navigate to specified URL

end():

		End the session and close the browser

find(selector):

		Find the element(s) given selector

type(text)

		Replace element text with specified text

click(selector) :

		Click element

doubleClick(selector)

		Double click element

middleClick(selector)

		Middle click element

rightClick(selector)

		Right click element

mouseDown()

		Press mouse button

mouseUp()

		Lift mouse button

moveMouseTo(selector, [xOffset, yOffset])

		Move mouse to center of element. optional - X,Y offsets from the top left corner of element

dragAndDrop(sourceSelector, targetSelector, [xOffset, yOffset])

		Drag the specified source element to the center of the specified target element. 
        optional - X,Y offsets from the top left corner of  target element

save(selector)

		Performs a get on the specified selector and keeps the results in memory 
        (results will vary depending on selector and projection use)
		example usage: save the number of items in a grid, so we can compare to after a new item is added.

waitForChange(selector)

		Wait for a change to previously saved selector's results 

getHistory(selector)

		Return the values from previously used save

execute(func, ...args)

		Execute browserside javascript

executeAsync(func, ...args)

		Execute browserside javascript Asynchroniously 

pause(delay)

		Add a pause in milliseconds

saveScreenshot(filename)

		Save a screenshot of the browser to the filename given
		example: saveScreenshot("/screenshot/mypic.jpg")

scroll(selector)

		Scroll to make element visible on screen

waitFor(selector)

		Wait for the given element to appear

Getting and setting values

get(selector)

		Get the given selector value

set(selector, value)

		Set the value of current selector

cast(state)

		Use Json to set state for multiple elements on page. multiple gets, example:
		.cast({
			'username': "myuser",
			'password': "mypass"
		})

Special projections:


These are added to end of selector to project the results.

browser:url
return the current URL
browser:title
return the page's current title
:text
return the elements innertext
:html
return the elements outerHTML
:value
return the elements value
:attribute-<attribute name$gt;
return the specified attribute value
:count
returns a count of the elements

Options:


These options are added to end of a Glance label to allow us to change how the object is found or filtered

#attribute-<attribute name>
limit the search to the specified attribute name

Example Code: https://codepen.io/quasimatic/pen/zwQVEL
#class
limit the selector to class attribute

Example Code: https://codepen.io/quasimatic/pen/OmebeK
#closest
visibly closest element to the scope

Example Code: https://codepen.io/quasimatic/pen/YVoEYo
#contains-text
selector given can be part of a longer text string

Example Code: https://codepen.io/quasimatic/pen/bWPwjK
#css
applies selector as a css query

Example Code: http://codepen.io/quasimatic/pen/xdJKJP
#exact-text
find only elements that are an exact textual match

Example Code: https://codepen.io/quasimatic/pen/qmzVJv
#hidden
limit the search to hidden elements
#id
limit the search to the specified id (fastest way to search)
#<index>
return element number <index>

Example Code: https://codepen.io/quasimatic/pen/BROxEm
#node-type
look only for elements that match this node-type

Example Code: https://codepen.io/quasimatic/pen/rmEWQy
#value
look for the selector in the value attribute
#visible
default behavior - return only visible elements

Example Code: https://codepen.io/quasimatic/pen/MmqGGq

Package Sidebar

Install

npm i glance-webdriver

Weekly Downloads

9

Version

0.8.7

License

MIT

Last publish

Collaborators

  • quasimatic