美文网首页我爱编程
selenium检查页面文本元素是否出现

selenium检查页面文本元素是否出现

作者: 红木杉2018 | 来源:发表于2017-04-18 17:05 被阅读0次

package LianXi;

import junit.framework.Assert;

import org.openqa.selenium.chrome.ChromeOptions;

import org.openqa.selenium.By;

import org.openqa.selenium.chrome.ChromeDriver;

public class IsElementTextParent {

public static void main(String[] args) {

// TODO Auto-generated method stub

ChromeOptions options=new ChromeOptions();

options.addArguments("--start-maximized","allow-running-insecure-content","--test-type");

ChromeDriver driver=new ChromeDriver(options);

driver.get("https://www.baidu.com");

String elementText=driver.findElement(By.xpath("//div[@id='ftConw']/p/a[1]")).getText();

Assert.assertEquals("把百度设为主页", elementText);

}

}

相关文章

网友评论

    本文标题:selenium检查页面文本元素是否出现

    本文链接:https://www.haomeiwen.com/subject/rocqzttx.html