admin管理员组文章数量:1331538
I'm trying to run Nightwatch script which will open a url, then it will getValue from an Input and will use that value in the next page.
Please see the following code:
var conf = require('../../nightwatch.conf.BASIC.js');
module.exports = {
'nightwatch flow': function (browser) {
var first_name;
browser
.url('http://example:3000')
.getValue('input[name="first_name"]', function(result){
first_name = result.value;
})
.setValue('input[name="amount"]', 101)
.click('input[name=continue]')
.clearValue('input[name="first_name"]')
.setValue('input[name="first_name"]', first_name)
.click('button[name=next]')
.end();
}
};
the setValue('input[name="first_name"]', first_name)
gets "undefined"
first_name parameter is being updated inside a callback function. I need that setValue function will use the updated value. Thanks in advance
I'm trying to run Nightwatch script which will open a url, then it will getValue from an Input and will use that value in the next page.
Please see the following code:
var conf = require('../../nightwatch.conf.BASIC.js');
module.exports = {
'nightwatch flow': function (browser) {
var first_name;
browser
.url('http://example:3000')
.getValue('input[name="first_name"]', function(result){
first_name = result.value;
})
.setValue('input[name="amount"]', 101)
.click('input[name=continue]')
.clearValue('input[name="first_name"]')
.setValue('input[name="first_name"]', first_name)
.click('button[name=next]')
.end();
}
};
the setValue('input[name="first_name"]', first_name)
gets "undefined"
first_name parameter is being updated inside a callback function. I need that setValue function will use the updated value. Thanks in advance
Share Improve this question edited Aug 9, 2017 at 15:36 Oron Bendavid asked Aug 8, 2017 at 13:55 Oron BendavidOron Bendavid 1,5333 gold badges19 silver badges34 bronze badges 2-
It could be related to this issue github./nightwatchjs/nightwatch/issues/1132. Calling
setValue
afterclearValue
seems to cause issues. – Chris Traveis Commented Aug 8, 2017 at 19:15 - Hi thanks, It's not the case, I've found a workaround. Will post a solution in few minutes – Oron Bendavid Commented Aug 9, 2017 at 7:42
1 Answer
Reset to default 5I've found a workaround:
var conf = require('../../nightwatch.conf.BASIC.js');
var first_name;
module.exports = {
'nightwatch flow': function (browser) {
browser
.url('http://example:3000')
.getValue('input[name="first_name"]', function(result){
first_name = result.value;
})
.setValue('input[name="amount"]', 101)
.click('input[name=continue]')
.clearValue('input[name="first_name"]')
.setValue('input[name="first_name"]', "", function(){
browser.setValue('input[name="first_name"]', first_name)
})
.click('button[name=next]')
.end();
}
};
The solution is to use the browser.setValue again inside a callback.
本文标签: javascriptNightwatchjs get value from input and use it in next stepStack Overflow
版权声明:本文标题:javascript - Nightwatch.js get value from input and use it in next step - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742283632a2446544.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论