const myAdress = (`My Address = +${'//android.widget.TextView[@index="1"]'}`);
console.log(myAdress);
想在此特定的XPath上打印文本,但它照原样打印。
您可以在xpath中使用部分文本,而不是附加诸如]之类的文本>
String address = "//*[contains(@text,'replace your address')]"
String printAddress= driver.findElementByXPath(address).getText();
log.info(printAddress);
const getText = async (ele) =>{
let e = await browser.$(ele);
let text = await e.getText()
return text;
}
getText('//your locator')
const myAdress = (`My Address is ${$('//android.widget.TextView[@index="1"]').getText()}`);
console.log(myAdress);