I have tried both options, but nothing seems to work:
var webNum = browser.getText('selector');
var urlGo = 'https://gotourl.com/' + webNum;
browser.url(urlGo);
or
var webNum = browser.getText('selector');
browser.url('https://gotourl.com/' + webNum);
Any ideas?
.getText() is returning a WebElement JSON Object
rather than string (the documentation on nightwatch api is misleading...)
The text you want is the value of the WebElement JSON Object
, and you can access it by using .value
if you would like to get the text you have to do the following :
var webNum = 'nothing';
browser.getText('selector',function(text){
webNum=text.value;
var urlGo = 'https://gotourl.com/' + webNum;
browser.url(urlGo);
});
This way should works.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.