如何使用Helium从页面中读取文本?

时间:2015-06-01 05:41:01

标签: java testing automation qa helium

enter image description here

我想阅读图片中显示的文字,并希望使用Helium打印该文本。我尝试了以下代码

import org.openqa.selenium.WebDriver;

//import com.heliumhq.selenium_wrappers.WebDriverWrapper;

import static com.heliumhq.API.*;


public class MainClass {

    public static void main(String[] args) {
        WebDriver ff = startFirefox("http://172.16.0.200:8001/");
        waitUntil(Text("Streams Tech, Inc.").exists);

        streamstech lg = new streamstech();
        lg.login(ff);
         if (getDriver().getValue().contains("You have not purchased any product yet. Please visit our product list to try out different products!"))
                System.out.println("You have not purchased any product yet. Please visit our product list to try out different products!");
            else
                System.out.println("Test failed :(");
        //String text = getValue("You have not purchased any product yet. Please visit our product list to try out different products!");
        killBrowser();
    }
}

但是对于getValue()我收到错误"方法getValue()未定义类型WebDriver" 感谢您的帮助。提前致谢。

1 个答案:

答案 0 :(得分:0)

解决了问题

Text("My desire text").getValue(); 

此命令正在读取字符串