首页 > 解决方案 > 如何使用 selenium 中的 chrome 进行自动 wifi 强制门户登录?

问题描述

我正在尝试使用 selenium 自动化 wifi 强制门户登录。为此,我在无头模式下使用了 chrome 驱动程序,如下面的代码所示。

从 selenium 导入 webdriver 从 selenium.webdriver.chrome.options 导入选项导入操作系统

chrome_options = Options()
chrome_options.add_argument("--headless")
chrome_options.add_argument("--window-size=1920x1080")

driver = webdriver.Chrome(options=chrome_options)
driver.get("https://www.google.com")

# capture the screen
driver.get_screenshot_as_file("capture.png")
driver.quit()

但是一些博客说在没有 --no-sandbox 的情况下运行无头模式可能会导致 chrome 出现问题。那是对的吗?

如果我将 chrome 与沙箱一起使用会怎样?

我将为不同的客户端使用脚本,因此对于不同的客户端,强制门户会有所不同。我只需要知道在沙盒的任何情况下,chrome 是否会崩溃?

标签: seleniumgoogle-chromepython-3.7sandbox

解决方案


推荐阅读