前言

Text关键字的作用是识别网页上的文字,在一般UI查找中使用率非常高,但是需要注意,如果网页上有相同的文字,那么只能识别到第一个

入参介绍

以下是Text的源码

有5个如参:后面4个参数是上下左右的定位辅助,后面举例中详细介绍

text=None, below=None, to_right_of=None, above=None, to_left_of=Noneclass Text(HTMLElement):    """    Lets you identify any text or label on a web page. This is most useful for

    checking whether a particular text exists::

        if Text("Do you want to proceed?").exists():
click("Yes") ``Text`` also makes it possible to read plain text data from a web page. For
example, suppose you have a table of people's email addresses. Then you
can read John's email addresses as follows:: Text(below="Email", to_right_of="John").value Similarly to ``below`` and ``to_right_of``, the keyword parameters ``above``
and ``to_left_of`` can be used to search for texts above and to the left of
other web elements.
weitungblog
"""
def __init__(
self, text=None, below=None, to_right_of=None, above=None,
to_left_of=None
):
super(Text, self).__init__(
below=below, to_right_of=to_right_of, above=above,
to_left_of=to_left_of
)
self._args.append(text)
@property
def value(self):
"""
Returns the current value of this Text object.
"""
return self._impl.value

举例说明

1、查找文字Text("Java教程")

from helium import *
import time def gaokao10():
start_chrome(url)
time.sleep(2)
wait_until(Text("推荐教程").exists)
highlight(Text("Java教程"))
time.sleep(5)
kill_browser()
gaokao10()

2、Text("Java教程", below="推荐教程")

from helium import *
import time def gaokao10():
start_chrome(url)
time.sleep(2)
wait_until(Text("推荐教程").exists)
highlight(Text("Java教程", below="推荐教程"))
time.sleep(5)
kill_browser() gaokao10()

欢迎交流

310678696

最新文章

  1. css样式大全
  2. SQL GROUP BY 中的TOP N
  3. arcgis将图片转成shp地图
  4. Unity3D热更新全书-何谓热更新,为何热更新,如何热更新
  5. 错题802-java
  6. props验证
  7. 20151225jquery学习笔记---编辑器插件
  8. Longtail Hedgehog(DP)
  9. Erlang Resources 资讯小站
  10. 如何将excel导入到数据库中并在gridview中显示
  11. Bootstrap快速入门
  12. 指针变量的*p,p以及&p的区别
  13. springMVC 使用ajax 出现No serializer found for class异常
  14. SRILM的使用及平滑方法说明
  15. ubuntu 16.04 下安装动态链接库方法
  16. Java用户名登录学生信息管理系统并对其进行增删改查操作
  17. bzoj4152 The Captain (dijkstra)
  18. 通过jdbc获取数据库中的表结构 主键 各个表字段类型及应用生成实体类
  19. How to disable a plugin when Jenkins is down?
  20. 今天犯了一个StringBuilder构造函数引起的二逼问题。

热门文章

  1. python文件的相关操作
  2. 运行netcore2.2程序是报错
  3. 学习 | mockjs入门
  4. 安装Linux的CentOS操作系统 - 初学者系列 - 学习者系列文章
  5. hystrix熔断器之HystrixRequestLog
  6. Laravel Exception结合自定义Log服务的使用
  7. .netcore+vue 实现压缩文件下载
  8. C++实现职工管理系统(中)
  9. 国际化的实现i18n--错误码国际化以及在springboot项目中使用
  10. 【CF1425H】Huge Boxes of Animal Toys 题解