简体   繁体   English

使用Selenium WebDriver,Chrome浏览器无法在信息亭模式下打开

[英]Chrome browser doesn't open in kiosk mode using Selenium WebDriver

I am using Selenium WebDriver with chrome browser and for whatever reason, it doesn't open in kiosk mode. 我将Selenium WebDriver与chrome浏览器一起使用,无论出于何种原因,它都无法在信息亭模式下打开。 This used to work, not sure why it stopped. 这曾经有用,不确定为什么会停止。

This is my code: 这是我的代码:

        private IWebDriver GetChromeDriver(BrowserConfigurationOptions browserConfigOptions)
    {
        var options = new ChromeOptions();
        options.AddArguments("disable-infobars");
        options.AddUserProfilePreference("credentials_enable_service", false);
        if (browserConfigOptions.KioskModeForChrome)
            options.AddArgument("--kiosk"); //options.AddArgument("--enable-kiosk-mode");
        LogChromeOptions(options);

        return new ChromeDriver(options);
    }

This is my environment: 这是我的环境:

  • Chrome 66 铬66
  • Selenium WebDriver v 3.11.2 Selenium WebDriver v 3.11.2
  • Chromedriver version 2.38.0.1 from this Nuget package Nuget软件包中的 Chromedriver版本2.38.0.1

I've tried passing in --kiosk and --enable-kiosk-mode with no success. 我尝试传递--kiosk和--enable-kiosk-mode没有成功。

After seeing that everyone had this working except me, I started digging further. 看到除了我之外每个人都在工作,我开始进一步研究。 After digging into the code I found 深入研究代码后,我发现

Driver.Manage().Window.Maximize(); 。Driver.Manage()Window.Maximize();

being called after initialization of the driver. 在驱动程序初始化后被调用。 After removing this line of code, I was able to open Chrome in kiosk mode with the solution above. 删除此行代码后,我可以使用上述解决方案在信息亭模式下打开Chrome。

Config issue as Chrome 66 is supported by Chromedriver 2.38 and you're using 2.18 Chromedriver 2.38支持Chrome 66配置问题,而您使用的是2.18

Please update from below. 请从下面更新。

http://chromedriver.chromium.org/downloads http://chromedriver.chromium.org/downloads

To initialize the Chrome Browser in Kiosk Mode you need to pass the following argument through an instance of ChromeOptions class: 要在信息亭模式下初始化Chrome浏览器 ,您需要通过ChromeOptions类的实例传递以下参数:

ChromeOptions options = new ChromeOptions();
options.addArguments("--kiosk");
return new ChromeDriver(options);

Note A : As per Java Doc , it is arguments are passed as addArguments() 注A :根据Java Doc ,参数作为addArguments()传递

Note B : As per Peter Beverloo 注释B :根据Peter Beverloo

  • --kiosk : --kiosk

     Enables kiosk mode. Please note this is not Chrome OS kiosk mode. 
  • Sample Code(Java): 示例代码(Java):

     System.setProperty("webdriver.chrome.driver", "C:\\\\Utility\\\\BrowserDrivers\\\\chromedriver.exe"); ChromeOptions options = new ChromeOptions(); options.addArguments("--kiosk"); WebDriver driver = new ChromeDriver(options); driver.get("https://www.google.com/"); 
  • Browser Snapshot: 浏览器快照:

Chrome_Kiosk_Mode

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Selenium Chrome WebDriver 不使用代理 - Selenium Chrome WebDriver doesn't use proxy 有没有办法以编程方式将Chrome浏览器设置为信息亭模式? - Is there a way to programatically put Chrome browser into kiosk mode? chrome devtools,如何在自助服务终端模式下打开 - chrome devtools, how to open when in kiosk mode 无法使用 Selenium Webdriver 打开 Chrome 浏览器。 加载解压的扩展被管理员禁用 - Unable to open chrome browser using Selenium Webdriver. Loading unpacked extensions are disabled by administrator Maven Test无法使用Selenium Webdriver打开Chrome浏览器 - Maven Test does not open Chrome browser with Selenium Webdriver 在Kiosk模式下使用Chrome命令API - Using the Chrome commands API in Kiosk Mode 如何在 Selenium webdriver 中打开 chrome? - How to open chrome in Selenium webdriver? 如何使用 selenium webdriver 和 python 关闭 chrome 浏览器弹出对话框 - how to close chrome browser popup dialog using selenium webdriver and python 无法使用 selenium webdriver 启动 chrome 浏览器 - Could not able to launch chrome browser using the selenium webdriver Alert Python Selenium、Chrome WebDriver:切换到警报不起作用 - Alert Python Selenium, Chrome WebDriver: switch to alert doesn't work
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM