click

Click on an element based on given selector.

Usage

1
browser.click(selector);

Parameters

Param Type Details
selector String element to click on. If it matches with more than one DOM-element it automatically clicks on the first element

Example

example.html
1
2
<button id="myButton" onclick="document.getElementById('someText').innerHTML='I was clicked'">Click me</button>
<div id="someText">I was not clicked</div>
click.js
1
2
3
4
5
6
7
8
9
it('should demonstrate the click command', function () {
var myButton = $('#myButton')
myButton.click()
// or
browser.click('#myButton')

var text = browser.getText('#someText');
assert(text === 'I was clicked'); // true
})
example.js
1
2
3
4
5
6
7
it('should fetch menu links and visit each page', function () {
links = $$('#menu a');

menu.forEach(function (link) {
link.click();
});
});

Uses