ironmantis7x
ironmantis7x

Reputation: 827

how do a click on a link in webdriverIO

I am trying to click on a link in a web page with webdriverIO. I can navigate to google.com page and then I enter a search term.

But when I try to click on a link containing the text I want, it doesn't click the link.

What am I doing wrong:

Here is my code:

var webdriverio = require('webdriverio');
var options = {
    desiredCapabilities: {
        //browserName: 'phantomjs'
        browserName: 'chrome'
    }
};
webdriverio
    .remote(options)
    .init()
    .url('http://www.google.com')
    .setValue('*[name="q"]','webdriverio')
    .click('*[name="btnG"]')
    .pause(1000)
    .getTitle().then(function(title) {
        console.log('Title was: ' + title)
    })
    .getText('=webdriver.io').then(function(text) {
        console.log('Title was: ' + text); // outputs: "WebdriverIO"
    })
    .end(); 

I am running webdriverIO with node.js v6.9.2 and selenium stand alone server 3.0.1.

Thanks.

Upvotes: 0

Views: 3497

Answers (2)

ironmantis7x
ironmantis7x

Reputation: 827

Found it!!!

use:

.click('[href="http://webdriver.io/"]')

this format worked for me.

Upvotes: 1

Kevin Lamping
Kevin Lamping

Reputation: 2269

Looks like they changed the name of the "google search" button to be 'btnK'. Try replacing 'btnG' with 'btnK' in your click command and see if it works.

<input value="Google Search" aria-label="Google Search" name="btnK" type="submit" jsaction="sf.chk">

Upvotes: 0

Related Questions