一、yaml源文件编写

python_selenium 之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_selenium 之yaml文件读取(以读取元素信息为例)

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-06-02
  • 2021-05-24
  • 2021-12-28
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案