Search code examples
javascriptnode.jsappiumwebdriver-ioappium-android

Want to Print the text on the XPath


const myAdress = (`My Address = +${'//android.widget.TextView[@index="1"]'}`);
console.log(myAdress);

Want to print the text on this specific XPath but it prints this as it is.


Solution

  • const myAdress = (`My Address is ${$('//android.widget.TextView[@index="1"]').getText()}`);
    console.log(myAdress);
    

    You have problems with brackets.

    This is clearer:

    const element = $('//android.widget.TextView[@index="1"]') 
    const text = element.getText()
    console.log(`My address is ${text}`)