Steps

A comprehensive list of EasyTesting steps

Navigation

I am on page

Opens a web page in a browser. Requires relative or absolute url.

Always start your test with I am on page

If url starts with `/`, opens a web page of a site defined in `url` config parameter.

// opens main page of website
I am on page '/'
// opens github
I am on page 'https://github.com'
// opens a login page
I am on page '/login'

I open new tab

Open new browser tab and switch to it.

I open new tab

I switch to

Switches between iframes on the page. Provide a name or CSS/XPath locator of iframe to switch into it. To switch back to main page call `I switch to` with no parameters

I switch to '#left' // switch to iframe with id=left
I switch to // switch back to main window

Mouse

I click

Perform a click on a link or a button, given by a locator.

If a text is given, the page will be searched for a button, link, or image matching the locator string. For buttons, the "value" attribute, "name" attribute, and inner text are searched. For links, the link text is searched. For images, the "alt" attribute and inner text of any parent links are searched.

The second parameter is a context (CSS or XPath locator) to narrow the search.

// simple link
I click 'Logout'
// button of form
I click 'Submit'
// CSS button
I click '#form input[type=submit]'
// XPath
I click '//form/*[@type=submit]'
// link in context
I click 'Logout', '#nav'

I double click

Performs a double-click on an element matched by link|button|label|CSS or XPath. Context can be specified as second parameter to narrow search.

I double click 'Edit'
I double click 'Edit', '.actions'
I double click '.btn.edit'

I right click

Performs right click on an element matched by CSS or XPath.

I right click '#button'

I move cursor to

Moves cursor to element matched by locator. Extra shift can be set with offsetX and offsetY options.

I move cursor to '.tooltip'
I move cursor to '#submit', 5, 5

I scroll to

Scrolls to element matched by locator. Extra shift can be set with offsetX and offsetY options.

I scroll to 'footer'
I scroll to '#submit', 5, 5

Parameters

  • locator located by CSS|XPath locator.

  • offsetX (optional) X-axis offset.

  • offsetY (optional) Y-axis offset.

Advanced Control

I execute script

Executes JavaScript on a page.

// set value inside client
I execute script 'document.querySelector("#input").value = "123"'
// set value using jQuery
I execute script '$("#input").value("123")'
// change date of jQuery DatePicker
I execute script '$("date").datetimepicker("setDate", new Date())'

Forms

I fill field

Fills a text field or textarea, after clearing its value, with the given string. Field is located by name, label, CSS, or XPath.

// by label
I fill field 'Email', 'hello@world.com'
// by name
I fill field 'password', '123456'
// by CSS
I fill field 'form#login input[name=username]', 'John'

I press key

Presses a key on a focused element. Special keys like 'Enter', 'Control', etc will be replaced with corresponding unicode. If modifier key is used (Control, Command, Alt, Shift) in array, it will be released afterwards.

I press key 'Enter'
I press key 'Tab'
I press key 'some-text'

Allowed keys:

  • 'Alt',

  • 'ArrowDown' or 'Down arrow',

  • 'ArrowLeft' or 'Left arrow',

  • 'ArrowRight' or 'Right arrow',

  • 'ArrowUp' or 'Up arrow',

  • 'Backspace',

  • 'Command',

  • 'Control',

  • 'Del',

  • 'Divide',

  • 'End',

  • 'Enter',

  • 'Equals',

  • 'Escape',

  • 'F1 to F12',

  • 'Home',

  • 'Insert',

  • 'Meta',

  • 'Multiply',

  • 'Numpad 0' to 'Numpad 9',

  • 'Pagedown' or 'PageDown',

  • 'Pageup' or 'PageUp',

  • 'Pause',

  • 'Semicolon',

  • 'Shift',

  • 'Space',

  • 'Subtract',

  • 'Tab'

I check option

Selects a checkbox or radio button.

Element is located by label or name or CSS or XPath. The second parameter is a context (CSS or XPath locator) to narrow the search.

I check option '#agree'
I check option 'I Agree to Terms and Conditions'
I check option 'agree', '//form'

I select option

Selects an option in a drop-down select.

Works only with native <select> elements. For customized drop-downs use click to open the dropdown and click to select an element inside it. ​

Field is searched by label | name | CSS | XPath. Option is selected by visible text or by value.

I select option 'Choose Plan', 'Monthly' // select by label
I select option 'subscription', 'Monthly' // match option by text
I select option 'subscription', '0' // or by value
I select option '//form/select[@name=account]','Premium'
I select option 'form select[name=account]', 'Premium'

Assertions

I see

Checks that a page contains a visible text. Use context parameter to narrow down the search.

I see 'Welcome' // text welcome on a page
I see 'Welcome', '.content' // text inside .content div

I see element

Checks that a given Element is visible.

Element is located by CSS or XPath.

I see element '#modal'

I don`t see

Opposite to see. Checks that a text is not present on a page. Use context parameter to narrow down the search.

I dont see 'Login' // assume we are already logged in

I don`t see element

Opposite to see element Checks that element is not visible (or in DOM)

I see in field

Checks that the given input field or textarea equals to given value. Fields are matched by label text, the "name" attribute, CSS, and XPath.

I see in field 'Username', 'davert'
I see in field 'form input[type=hidden]','hidden_value'
I see in field('#searchform input','Search'

Parameters

  • field located by label|name|CSS|XPath

  • value value to check

I see in current url

Checks that current url contains a provided fragment.

I see in current url '/register' // we are on registration page

Parameters

  • url value to check.

I see in title

Checks that title of a page contains text.

I see in title "My WebSite - Edit"

I see number of elements

Check the exact quantity of elements matched by locator to be on the page

I see number of elements '#submitBtn', 1

Parameters

  • locator element located by CSS|XPath locator.

  • num number of elements.

I see text equals

Checks that text inside an element is equal to provided one.

I.see text equals 'Hello', 'h1'

Parameters

  • text element value to check.

  • context element located by CSS|XPath locator.

Wait for actions

I wait

Pauses execution for a number of seconds.

I wait 2 // wait 2 secs

I wait for element

Waits for element to be present on page (by default waits for 1 sec). Element can be located by CSS or XPath.

I wait for element '.btn.continue'
I wait for element '.btn.continue', 5 // wait for 5 secs

I wait for text

Waits for a text to appear (by default waits for 1sec).

Context element can be provided as third parameter.

I wait for text 'Thank you, form has been submitted'
I wait for text 'Thank you, form has been submitted', 10 // wait for 10 seconds
// wait for 5 seconds for text inside #modal
I wait for text 'Thank you, form has been submitted', 5, '#modal'

Parameters

  • text to wait for.

  • sec (optional) time in seconds to wait.

  • context (optional) element located by CSS|XPath locator.

I wait for value

Waits for the specified value to be in value attribute.

I wait for value '//input', "GoodValue"

Parameters

  • field input field.

  • value expected value.

  • sec (optional) time in seconds to wait, 1 sec by default.

I wait in url

Waiting for the part of the URL to match the expected. Can be used in single page applications to understand that the page has been changed.

I wait in url '/info', 2

Parameters

  • urlPart value to check.

  • sec (optional) time in seconds to wait.