webdriverio Set getText string to variable
问题 I'm currently trying to instantiate a variable with the contents of the getText method using webdriverio. a = String(browser.getText('.field_notice')); When I attempt to print the variable this is the output: [object Object] Thanks for the help! 回答1: browser.getText() is an asynchronous call so you will need to provide a callback to instantiate your variable. Try this : browser .getText('.field_notice').then(function(text) { a = text; }); A similar example can be found on the Webdriverio