mojotech / pioneer

Integration Testing

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

pioneer this.driver.executeScript always returns an object {then: fn, cancel: fn, isPending: fn} instead of what is requested

bitplanets opened this issue · comments

I have this script that looks like this:

this.When(/^I should be logged in$/, function(value){
    console.log('> ', this.driver.executeScript('return "test"'));
});

And the output of console.log is

>  { then: [Function: then],
  cancel: [Function: cancel],
  isPending: [Function: isPending] }

Instead of

"> test"

In the docs says that you receive a string for any other value. Why not?

Well this is the solution

    var result = this.driver.executeScript('return "test"');
    result.then(function(value){
        console.log(value)
    })

Because I think it uses async in order to communicate with the driver.

Almost everything the driver does is promise-based, and the promise object is what you're seeing when you console.log it. This is not something that pioneer can change as it's deferring to webdriver.

Also, you're looking at the wrong docs. You should be looking here: http://selenium.googlecode.com/git/docs/api/javascript/class_webdriver_WebDriver.html#executeScript

👍
thats correct @tomhicks-bsf this is a proxy to webdriver

thanks for the help @tomhicks-bsf, appreciate it!

Thanks