Support & information center

Common Nightwatch/Selenium commands

testRTC uses the popular Nightwatch/Selenium scripting language.

For a complete reference of the Nightwatch API reference, please refer to http://nightwatchjs.org/api. For a good overview of CSS selectors see here.

Here are several common commands that you are bound to find and use with testRTC.

.click()

Simulates a click event on the given DOM element.

This is usually used to click on buttons or links on your web page.

Arguments

NameTypeDescription
selectorstringThe CSS selector used to locate the element.

Examples

Using DOM Element ID –

client.click('#btn-login');

DOM Element Class –

client.click('.btn-danger');

DOM Element attribute property –

client.click('a[href="/dashboard"]');

DOM Element Xpath –

client.click('xpath', '//*[@id="uncontained_main_content"]/div[2]/a');

.setValue()

Sends some text to an element. Can be used to set the value of a form element or to send a sequence of key strokes to an element. Any UTF-8 character may be specified.

Arguments

NameTypeDescription
selectorstringThe CSS/Xpath selector used to locate the element.
valuestring|arrayThe text to send to the element or key strokes.

.pause()

Suspends the test for the given time in milliseconds. If the milliseconds argument is missing it will suspend the test indefinitely.

When you pause, the browser keeps running and any action taking place in the background continues – you can use the .pause() command for example to wait for the media in the call to run its course, giving it 30, 60 or any other number of seconds to play.

Arguments

NameTypeDescription
msnumberThe number of milliseconds to wait.

.url()

Retrieve the URL of the current page or navigate to a new URL.

Arguments

NameTypeDescription
urlstringURL to navigate to.

Was this article helpful?

Related Articles