要在XPath上打印文本

问题描述 投票:0回答:3
const myAdress = (`My Address = +${'//android.widget.TextView[@index="1"]'}`);
console.log(myAdress);

想在此特定的XPath上打印文本,但它照原样打印。

javascript node.js appium webdriver-io appium-android
3个回答
0
投票

您可以在xpath中使用部分文本,而不是附加诸如]之类的文本>

String address = "//*[contains(@text,'replace your address')]"


String printAddress= driver.findElementByXPath(address).getText();
log.info(printAddress);

0
投票
const getText = async (ele) =>{
    let e = await browser.$(ele);
    let text = await e.getText()
    return text;
}

getText('//your locator')

0
投票
const myAdress = (`My Address is ${$('//android.widget.TextView[@index="1"]').getText()}`);
console.log(myAdress);
© www.soinside.com 2019 - 2024. All rights reserved.