python_selenium 之yaml文件读取(以读取元素信息为例),,一、yaml源文件编
python_selenium 之yaml文件读取(以读取元素信息为例),,一、yaml源文件编
一、yaml源文件编写
二、对yaml文件内容的读取
#coding=gbk
import os
import yaml
current_path=os.path.dirname(__file__)
yaml_path=os.path.join(current_path,‘../element_info_datas/element_login_infos.yaml‘)
class ElementdataYamlUtils():
def get_yaml_element_info(self,yaml_path):
file = open(yaml_path, ‘r‘, encoding="gbk")
file_data = file.read()
file.close()
# 指定Loader
data = yaml.load(file_data, Loader=yaml.FullLoader)
return data
if __name__ == ‘__main__‘:
current_path = os.path.dirname(__file__)
yaml_path = os.path.join(current_path, ‘../element_info_datas/element_login_infos.yaml‘)
elements=ElementdataYamlUtils().get_yaml_element_info(yaml_path)
for e in elements.values():
print(e)
输出结果:
三、实际读取元素使用:
python_selenium 之yaml文件读取(以读取元素信息为例)
相关内容
- python面试题汇总第06期-正则表达式(内附7题及答案),
- python字典和集合(数组),,字典info = {
- Linux下安装python3.x 与python2 并存,,Linux下安装py
- python学习—turtle库练习,,# coding=u
- Python用积分思想计算圆周率,,[文本出自天外归云的
- python进阶一(函数式编程)【2-6 python中闭包】,,pyth
- docker-compose 安装,,1、安装python
- PYTHON 写函数,检查用户传入的对象(字符串、列表、元
- 搞定pycharm专业版的安装,,学习python也有
- numpy ndarray 杩斿洖 index 闂,,鏍囩锛?a hre
评论关闭