美文网首页
centos8通过docker安装selenium-firefo

centos8通过docker安装selenium-firefo

作者: mutang | 来源:发表于2024-01-09 12:58 被阅读0次

docker 安装 selenium/standalone-firefox

  1. 使用下面的命令启动一个 Firefoxdocker 容器
docker run --name firefox -d -p 4444:4444 -p 7900:7900 --shm-size="2g" selenium/standalone-firefox:3.141
  1. 访问 http://localhost:4444 测试 webDriver

python代码

from selenium import webdriver
from selenium.webdriver.firefox.options import Options

options = Options()
options.add_argument('-headless')
options.add_argument('--no-sandbox')

driver = webdriver.Remote(
        # 指定远程浏览器的地址
        command_executor='http://localhost:4444/wd/hub',
        options=options
    )
driver.get("https://www.baidu.com")
print(driver.title)
driver.quit()

原文

相关文章

网友评论

      本文标题:centos8通过docker安装selenium-firefo

      本文链接:https://www.haomeiwen.com/subject/qhfandtx.html