它将下载一个WebDriver,然后自动设置基本配置。
pwdriver的Python项目详细描述
PWDriver(PyWebDriver)
动机
简化每个不同版本和浏览器的自动化设置。在
支持:
铬铁
在壁虎
在边缘驱动器(铬)
在驾驶员
在
之前:
您必须检查本地浏览器的版本
在你必须在每个网站上下载驱动程序
在必须按如下方式设置此驱动程序的路径:
在
fromseleniumimportwebdriverwebdriver.Chrome('YOUR_CHROMEDRIVER_PATH')
使用
1。安装:
^{pr2}$2。制造配置.ini'文件并在项目目录中找到。
在配置.ini的内容是这样的。在
[automation];automation.browser: chrome, gecko, edge, ie, safariautomation.browser=chrome;automation.local: true, falseautomation.local=trueautomation.url=http://localhost:4444/wd/hub
3。导入WebDriverFactory。
现在,我们可以启动webdriver了。在
'自动化.browser'将创建您设置的。在
frompwdriver.coreimportWebDriverFactorydriver=WebDriverFactory().launch()
不同用途(使用硒)
与Chrome配合使用:
fromseleniumimportwebdriverfrompwdriver.coreimportWebDriverFactoryWebDriverFactory().setup_chromedriver()driver=webdriver.Chrome()
与FireFox一起使用:
fromseleniumimportwebdriverfrompwdriver.coreimportWebDriverFactoryWebDriverFactory().setup_geckodriver()driver=webdriver.firefox()
与边一起使用
frommsedge.selenium_toolsimportEdge,EdgeOptionsfrompwdriver.coreimportWebDriverFactoryWebDriverFactory().setup_edgedriver()options=EdgeOptions()options.use_chromium=Truedriver=Edge(options=options)
与IE一起使用
fromseleniumimportwebdriverfrompwdriver.coreimportWebDriverFactoryWebDriverFactory().setup_iedriver()driver=webdriver.Ie()
- 项目
标签: