splinter操作ie浏览器

splinter 是在selenium上的封装,很多操作更方便,但是默认似乎不能直接操作ie,通过修改browser.py文件,splinter\driver\webdriver下增加ie.py文件,可以直接操作ie浏览器。

环境:py3.7,win7,实测基本操作没问题,点击、查找元素、选择切换frames等。

  • 修改browser.py文件,添加两行:

from splinter.driver.webdriver.ie import WebDriver as IeWebDriver #添加
from splinter.exceptions import DriverNotFoundError


_DRIVERS = {
"firefox": FirefoxWebDriver,
"remote": RemoteWebDriver,
"chrome": ChromeWebDriver,
"ie": IeWebDriver, # 添加
}

  • splinter\driver\webdriver下增加ie.py,在chrome.py基础上修改

github链接:https://github.com/chengair/SplinterforIe

猜你喜欢

转载自www.cnblogs.com/chengair/p/11224812.html