from selenium import webdriver driver = webdriver.Chrome() driver.get('https://selenium.dev') driver.quit() |
from selenium import webdriver driver = webdriver.Firefox() driver.get('https://selenium.dev') driver.quit() |
在运行这个浏览器时,在Script配置了驱动,但运行时还是报错,系统环境变量path配置了也报错 最后把msedgedriver.exe驱动放在浏览器的默认安装文件中,代码中使用了浏览器路径,执行后成功 |
当然这种也是官网推荐的: Edge(executable_path='/path/to/MicrosoftWebDriver.exe') |
from selenium import webdriver driver = webdriver.Edge(r'C:\Program Files (x86)\Microsoft\Edge\Application\msedgedriver.exe') driver.get('https://selenium.dev') driver.quit() |
from selenium import webdriver driver = webdriver.Opera() driver.get('https://selenium.dev') driver.quit() |
from selenium import webdriver # 使用上下文管理器 with webdriver.Chrome() as driver: # 此处方缩进代码 driver.get('https://selenium.dev') driver.quit() |
欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) | Powered by Discuz! X3.2 |