[英]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: 这是我的环境:
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: 浏览器快照:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.