专栏名称: 51Testing软件测试网
51Testing软件测试网,人气最旺的软件测试技术门户,提供软件测试社区交流,软件测试博客,人才服务,测试沙龙,测试杂志,测试资料下载等全方位信息服务,是国内最专业的软件测试就业培训、企业服务供应商...
目录
相关文章推荐
51好读  ›  专栏  ›  51Testing软件测试网

UI自动化测试中的页面定位问题,终于有人替他们想到了!

51Testing软件测试网  · 公众号  · 测试  · 2020-01-06 17:30

正文

请到「今天看啥」查看全文



实例代码


WebElement.ini

[sogou]

queryBox=id:query

queryBtn=id:stb

GetElement.py

1 from selenium.webdriver.support.ui import WebDriverWait

2 import configparser

3 import os

4 from selenium import webdriver

5 class getElement():

6     '''

7     从配置文件中来获取定位信息

8     '''

9     def __init__(self):

10         self.elementIni = os.path.dirname(os.path.abspath(__file__))\

11                           +r'\WebElement.ini' # 配置文件所在目录

12     def getElement(self, driver, sogouSection, sogouOption):

13         try:

14             f = configparser.ConfigParser()

15             f.read(self.elementIni) # 读配置文件内容到内存中

16             locators = f.get(sogouSection, sogouOption).split(':')

17             # 获取定位方式

18             locaMethod = locators[0]

19             # 获取定位表达式







请到「今天看啥」查看全文


推荐文章
大数据实验室  ·  美国:2016-2045新科技趋势报告
7 年前
程序员技术  ·  编程语言撕X大战
7 年前