Selenium WebDriver getText

后端 未结 8 2094
广开言路
广开言路 2021-01-06 21:07

I have a

0
.

I try to write a test that myDiv has 0 text in it. With WebDriver it is:

<
8条回答
  •  抹茶落季
    2021-01-06 21:23

    Try this

    WebDriver driver = new YourBrowserdirver(); //FirefoxDriver or ChromeDriver etc..
    String Text = driver.findElement(By.id("myDiv")).getText();
    System.out.println("The text present in myDiv = "+Text);
    

提交回复
热议问题