1.建立目录结构:
2.config.ini文件:
[browserType] browserName= Chrome [testServer] URL = https://www.baidu.com
3.baidu_engine文件,浏览器引擎类封装:
# -*- coding:utf-8 -*- import configparser import os.path from selenium import webdriver from framework.logger import Logger logger = Logger(logger="BrowserEngine").getlog() class BrowserEngine(object): #dir = os.path.dirname(os.path.abspath('.')) # 注意相对路径获取方法 chrome_driver_path = "C:\Program Files (x86)\Google\Chrome\Application\chromedriver.exe" #ie_driver_path = dir + '/tools/IEDriverServer.exe' def __init__(self, driver): self.driver = driver # read the browser type from config.ini file, return the driver def open_browser(self, driver): config = con