如何在Ui automator的图像视图字段中获取文本

问题描述 投票:0回答:1

XML

嗨,我正在尝试验证发送和接收的消息的结果,有没有办法我可以在图像视图字段中获取文本并验证相同的文本。

appium uiautomator
1个回答
0
投票

您可以使用以下代码行来验证图像上的消息。

        driver.findElement(By.name("id of text in image"));
        String text = driver.findElement(By.name("id of text in image")).getText();
        if (text.equalsIgnoreCase("Message that is to be checked")) {
            System.out.println("Existing Message is correct.");
        } else {
            System.out.println("Existing Message is wrong.");

        }
© www.soinside.com 2019 - 2024. All rights reserved.