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!
Please use code something like below,
String textValue=driver.findElement(By.cssSelector("")).getText();
By.cssSelector("") is to find elements, you can use id or name or css based on the element defined in your page
browser.getText()
is an asynchronous call so you will need to provide a callback to instantiate your variable. Try this :A similar example can be found on the Webdriverio Developer Guide : http://webdriver.io/guide.html
Also, there is no need to convert the variable to a string since this method returns a string. See https://github.com/webdriverio/webdriverio/blob/master/lib/commands/getText.js