'''
以下为测试步骤,文件存放路径为:e:\\step.txt
open_browser||${browser_name}
visit||${url}
sleep||3
assert_word||${assert_word}
quit
'''
'''
以下为测试数据,文件中必须用双引号,文件存放路径为:e:\\data.txt
{"browser_name":"chrome","url":"https://www.baidu.com","assert_word":"百度"}
{"browser_name":"ie","url":"https://www.souhu.com","assert_word":"搜狐"}
{"browser_name":"firefox","url":"https://www.sougou.com","assert_word":"搜狗"}
'''
from selenium import webdriver
import sys
import time
import json
import re
driver='' #类变量、全局变量,存放获取到的浏览器驱动,以便其他函数使用
def get_test_data(test_data_file_path): #获取测试数据
test_datas=[]
with open(test_data_file_path,'r',encoding='utf-8') as fp:
for data in fp:
test_datas.append(json.loads(data.strip())) #将测试数据中的json串转换为字典存入test_datas
return test_datas
def get_test_step_data(test_step_data_file_path
python selenium自动化,数据驱动+关键字驱动方法
最新推荐文章于 2023-03-27 14:51:29 发布
'''以下为测试步骤,文件存放路径为:e:\\step.txtopen_browser||${browser_name}visit||${url}sleep||3assert_word||${assert_word}quit''''''以下为测试数据,文件中必须用双引号,文件存放路径为:e:\\data.txt{"browser_name":"chrome","url":"https://www.baidu.com","assert_word":"百度"}{"browser_name
摘要由CSDN通过智能技术生成