Get URL when using WebdriverIO


#1

Using WebdriverIO for testing an Electron app.

I can get current url with client.url() as below. Thought you cannot navigate to a URL using it since Electron uses BrowserWindow.loadUrl() to do that.

# get current URL
var webdriverio = require('webdriverio');
var client = webdriverio.remote(options);
client.init();

client.url(function(err, res){
    console.log(res.value);
});

But the problem is that if Electron client navigates to a remote URL like https://github.com/ using BrowserWindow.loadUrl(), then the Webdriver client does not proceed to next chained action.

client
  .click('#some_btn_to_load_remote_url')
  .url(function(err, res){
      # Problem! Cannot reach here.
  })

The Electron client uses ipc.send() to handle event and the event handler is as below.


ipc.on('loadUrl', function(event, url){
    mainWindow.loadUrl(url);
});

I didn’t send back ipc reply since the caller window would not get the reply anyway.


#2

After helpful discussion with webdriverio project owner, this issue is likely due to chromedriver and submitted as Issue 1207.