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

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

}

}

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 135,442评论 19 139
  • package com.selenium.gen; import org.openqa.selenium.By; ...
    红木杉2018阅读 4,095评论 0 2
  • 1. Java基础部分 基础部分的顺序:基本语法,类相关的语法,内部类的语法,继承相关的语法,异常的语法,线程的语...
    子非鱼_t_阅读 31,952评论 18 399
  • 这是一个棒棒的小伙儿,有着一股韧劲,做什么事都能坚持下去。 二十天的练字计划他完成了,一年多的暮省日...
    静心_静语阅读 2,047评论 0 1
  • 语义分析的任务: 负责检查抽象语法树的上下文相关属性: 变量使用前,需要事先定义 变量运算时,类型需要匹配 变量的...
    拉丁吴阅读 9,728评论 0 3