Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/326.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Selenium Grid:在会话上安装chrome扩展_Python_Selenium_Google Chrome Extension_Selenium Grid - Fatal编程技术网

Python Selenium Grid:在会话上安装chrome扩展

Python Selenium Grid:在会话上安装chrome扩展,python,selenium,google-chrome-extension,selenium-grid,Python,Selenium,Google Chrome Extension,Selenium Grid,在chrome浏览器中的Selenium Grid测试中,我需要使用chrome Store中的一个chrome扩展,但我遇到了一些问题:( 我试图在浏览器(.)中转到扩展URL并按键安装,但无法在弹出的浏览器窗口中确认安装 我试图下载crx扩展名文件,但后来我在浏览器中打开它,我看到了确认窗口,不知道如何确认安装 我尝试过使用这种方法——添加JSON文件并运行浏览器——不起作用,但我在Mac上尝试过,而不是在Linux上 webdriver.remote只能使用FireFox选项(seleni

在chrome浏览器中的Selenium Grid测试中,我需要使用chrome Store中的一个chrome扩展,但我遇到了一些问题:(

  • 我试图在浏览器(.)中转到扩展URL并按键安装,但无法在弹出的浏览器窗口中确认安装
  • 我试图下载crx扩展名文件,但后来我在浏览器中打开它,我看到了确认窗口,不知道如何确认安装
  • 我尝试过使用这种方法——添加JSON文件并运行浏览器——不起作用,但我在Mac上尝试过,而不是在Linux上
  • webdriver.remote只能使用FireFox选项(seleniumhq.github.io/selenium/docs/api/py/webdriver\u remote/selenium.webdriver.remote.webdriver.html)
  • 如果使用Selenium Grid,则无法更改Chrome浏览器的启动设置,也无法添加任何键:(

    也许您知道在Selenium Grid browser会话上安装扩展的另一种方法?

    您可以使用

    或者,您可以将选项添加到已存在的DesiredCapabilities对象

    // Add ChromeDriver-specific capabilities through ChromeOptions.
    ChromeOptions options = new ChromeOptions();
    options.addExtensions(new File("/path/to/extension.crx"));
    capabilities.setCapability(ChromeOptions.CAPABILITY, options);
    ChromeDriver driver = new ChromeDriver(capabilities);
    
    您还可以使用远程web驱动程序:

    DesiredCapabilities capability = DesiredCapabilities.chrome();
    // above code goes here...
    WebDriver driver = new RemoteWebDriver(new URL(hubUrl), capability);
    

    我无法将Chrome选项用于webdriverRemote。只有FirefoxOptions:(请参阅:当我使用SeleniumGrid时,我需要使用webdriverRemote。只有这样才能更新远程web驱动程序的答案。
    DesiredCapabilities capability = DesiredCapabilities.chrome();
    // above code goes here...
    WebDriver driver = new RemoteWebDriver(new URL(hubUrl), capability);