简体   繁体   中英

How to read a text from a page using Helium?

在此处输入图片说明

I want to read the text showing in the picture and want to print that text using Helium. I tried the following code

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();
    }
}

But for getValue() I am getting an error "The method getValue() is undefined for the type WebDriver" Appreciate your help. Thanks in advance.

Solved the problem

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

This command is reading the string

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM