直接进入主题:
解决selenium webdriver 启动IE失败的方案:
IE: IEDriverServer.exe
一般常用的驱动,selenium 官网上都支持,这些都是浏览器厂家提供。
火狐:geckodriver.exe
谷歌:chromedriver.exe
一般推荐使用chrome驱动,一来是方便调试,二来是出错少。
步骤如下:
1.IE ---->工具 -----> Internet 选项
2.Internet 选项 — 安全 — 下面有四个部分可供点击选择
3.在红色标注的 4个部分 :Internet 本地 Intranet 受信任的站点 受限制的站点;逐渐选择对应下面的 保护模式 勾选框,这4个地方 要么全勾选,要么全不勾选,一般建议全选见下图:
4.此时重启执行程序:
我们看到IE 可以正常启动了。
附加一段代码效果图:
import os
proj_path = os.path.dirname(os.path.dirname(os.path.abspath(file)))
conf_path = os.path.join(proj_path,“config”,“Logger.conf”)
ie_driver_path = “e:\IEDriverServer”
chrome_driver_path = “e:\chromeDriver”
firefox_driver_path = “e:\geckoDriver”
test_data_file = os.path.join(proj_path,“TestData”,
“测试用例.xlsx”)
test_case_sheet = “测试用例”
test_case_test_step_sheet_name_col_no = 3
test_case_is_executed_col_no = 4
test_case_executed_time_col_no = 5
test_case_executed_result_col_no = 6
test_step_executed_exception_info_col_no = 8
test_step_executed_capture_pic_path_col_no = 9
test_step_action_col_no = 2
test_step_locate_type_col_no = 3
test_step_locate_expression_col_no = 4
test_step_value_col_no = 5
test_step_executed_time_col_no = 6
test_step_executed_result_col_no = 7
object_map_file_path = os.path.join(proj_path,“testdata”,“ObjectDeposit.ini”)
if name ==“main”:
print(conf_path)