Nightwatch.js - Can't figure out how to pass a local variable into a URL parameter

后端 未结 1 1824
春和景丽
春和景丽 2021-01-25 16:29

I have tried both options, but nothing seems to work:

var webNum = browser.getText(\'selector\');
var urlGo = \'https://gotourl.com/\' + webNum;
browser.url(urlG         


        
1条回答
  •  深忆病人
    2021-01-25 16:36

    .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.

    0 讨论(0)
提交回复
热议问题