Python自动化测试中多种浏览器跑Case
from selenium import webdriver
class RegisterFunction(object):
def __init__(self, url, i):
self.driver = self.get_driver(url, i)
# 获取driver并打开url
def get_driver(self, url, i):
if i == 1:
driver = webdriver.Firefox()
elif i == 2:
driver = webdriver.Chrome()
else:
driver = webdriver.Ie()
driver.get(url)
driver.maximize_window()
return driver
if __name__ == '__main__':
for i in range(3):
register_function = RegisterFunction("https://passport.baidu.com", i)
register_function.run_main()
- 致谢
若对大家有用,感谢点赞或评论;若有不足或补充之处,也感谢大家评论进行指正,后期我将对本文进行补充完善。相信这是互相进步的开始!