Testing 如何使用cucumber/pioneer/selenium从浏览器中获取变量?
我的脚本如下所示:Testing 如何使用cucumber/pioneer/selenium从浏览器中获取变量?,testing,cucumber,Testing,Cucumber,我的脚本如下所示: this.When(/^I should be logged in$/, function(value){ console.log('> ', this.driver.executeScript('return "test"')); }); 并且console.log的输出是 > { then: [Function: then], cancel: [Function: cancel], isPending: [Function: isPendi
this.When(/^I should be logged in$/, function(value){
console.log('> ', this.driver.executeScript('return "test"'));
});
并且console.log的输出是
> { then: [Function: then],
cancel: [Function: cancel],
isPending: [Function: isPending] }
而不是
"> test"
尝试:
这就是解决办法
var result = this.driver.executeScript('return "test"');
result.then(function(value){
console.log(value)
})
因为我认为它使用异步来与驱动程序通信。同样的事情。。。无论如何,它不应该基于此改变行为。
var result = this.driver.executeScript('return "test"');
result.then(function(value){
console.log(value)
})