是否可以在没有驱动程序的情况下使用 Selenium?

Is it possible to use Senenium without driver?

我想在spyder/Jupyter-notebook中使用selenium,但是我无法下载驱动程序。是否可以在不下载驱动程序的情况下以某种方式使用 selenium,就像在 collab 版本中一样

Selenium 是一个主要启用和支持 Web 浏览器自动化的工具。因此,它确实需要后端的网络驱动程序。来自 docs:

To use Selenium in your automation project you need to install the language bindings libraries for your language of choice. In addition you will need WebDriver binaries for the browsers you want to automate and run test on.

此外,查看 repo 您会发现它确实需要驱动程序,具体取决于您计划使用的浏览器。

如果您由于政策限制而无法安装驱动程序,请与您的管理员联系并说明您需要它的原因;他们也许可以为您安装它。

如果您不想在本地 运行 驱动程序,您可以使用 Remote 驱动程序。例如,您可以 运行 在 aws 设备上 farm.Here 是一个关于如何在 aws 设备农场上进行操作的示例:

https://docs.aws.amazon.com/devicefarm/latest/testgrid/testing-frameworks-python.html

import boto3
from selenium.webdriver import DesiredCapabilities
from selenium.webdriver import Remote
class MyPytestTests():
  def setup_method(self, method):
    devicefarm_client = boto3.client("devicefarm")
        testgrid_url_response = devicefarm_client.create_test_grid_url(
        projectArn= "arn:aws:devicefarm:us-west-2:111122223333:testgrid-project:123e4567-e89b-12d3-a456-426655440000",
      expiresInSeconds=300
      )
     desired_capabilities = DesiredCapabilities.FIREFOX
     desired_capabilities["platform"] = "windows"
     self.driver = Remote(testgrid_url_response['url'], desired_capabilities)

拆解:

   def teardown_method(self, method):
    self.driver.quit()

(AWS 文档摘录)

您可以对 运行 selenium 使用无头方法。 https://dev.to/googlecloud/using-headless-chrome-with-cloud-run-3fdp