当前位置:网站首页>C version selenium operation chrome full screen mode display (F11)
C version selenium operation chrome full screen mode display (F11)
2022-07-06 17:27:00 【Heart blue 168】
Recently developed a classroom intelligent control software , It mainly realizes the control of all electrical equipment in the classroom on the podium , It is mainly based on MQTT Realized , Its control interface uses WEB Page implementation .
The main control computer on the podium starts up and enters Windows Behind the desktop , Automatically run the browser and enter the control page . Because there is no user authentication on the control interface , So you need to hide the address of the control interface , Therefore, verification information is added to the entry address , Then go to the real interface . In order to see the startup more like desktop software , Therefore, the browser is also required to display in full screen ( namely : Auto press F11 Enter full screen mode ).
Method 1 : By creating a Chrome Shortcut to , And add --kiosk Take realizable , As shown in the figure below :

Then add it to Windows In the startup item of .
The only drawback of this method is : You can't really hide the entry address of the control interface , People who know a little about computers can easily get the address . Use other devices to access this address to operate the device , This is what we don't want to see .
Method 2 : Use automated testing tools Selenium Realize to Chrome Browser control . download Selenium Related to the class library , And download the installed with the local computer Chrome Browser version consistent ChromeDriver.exe. Download address is :http://chromedriver.storage.googleapis.com/index.html
The way to control the full screen of the browser is right ChromeOptions Set the properties of . Many people post on the Internet to maximize the browser and write the full screen of the browser , In fact, this is very wrong . The right way to do it is as follows :

ha-ha , I can't see the above picture clearly , I attach the code :
#region Start browsing page
private void StartWebBroswer()
{
try
{
var option = new ChromeOptions();
// Whether to hide the browser
// If commented out , Then it will open Google browser at startup , You can see the operation of filling in the form on the page , If you cancel , Only cmd window , Google browser runs silently
//option.AddArgument("headless"); // Headless mode ( That is, the browser runs hidden )
//option.AddArgument("window-size=1024,768"); // Specify browser size
if (this.ViewKiosk == "1")
{
option.AddArgument("--kiosk"); // Full screen ( But press F11 Unable to exit full screen )
}
else
{
option.AddArgument("--start-fullscreen"); // All ( Press F11 You can exit the full screen )
}
//option.AddArgument("--start-maximized"); // Browser maximization
option.AddExcludedArgument("enable-automation");// No display 【 Under the control of automatic test software 】 word
//option.AddAdditionalCapability("useAutomationExtension", false); //
// Set up cmd The window doesn't pop up
ChromeDriverService service = ChromeDriverService.CreateDefaultService(System.AppDomain.CurrentDomain.BaseDirectory.ToString());
service.HideCommandPromptWindow = true;
this.DriverObj = new ChromeDriver(service, option);
this.DriverObj.Navigate().GoToUrl(this.ViewUrl);//https://www.baidu.com
this.ExecutorObj = (IJavaScriptExecutor)DriverObj;
this.ActionObj = new Actions(DriverObj);
}
catch (Exception xe)
{
this.WriteLogToFile(" Failed to start browser , reason :" + xe.Message);
}
}
#endregionThe code snippet above also includes headless mode to control the browser , Specify the size of the browser 、 Browser maximization 、 No display 【 Under the control of automatic test software 】 Words, etc , You can enjoy it .
The following is a small tool developed in this project , stay Windows It is especially suitable for touch-screen devices , Support setting the starting address at will , Start up and run automatically 、 Kiosk mode and password protection , For your reference .


Download address :
边栏推荐
- 微信防撤回是怎么实现的?
- How does wechat prevent withdrawal come true?
- JVM运行时数据区之程序计数器
- Introduction to spring trick of ByteDance: senior students, senior students, senior students, and the author "brocade bag"
- [VNCTF 2022]ezmath wp
- Final review of information and network security (based on the key points given by the teacher)
- vscode
- SQL tuning notes
- [VNCTF 2022]ezmath wp
- Connect to LAN MySQL
猜你喜欢

04 products and promotion developed by individuals - data push tool

PySpark算子处理空间数据全解析(4): 先说说空间运算

arithmetic operation

Wu Jun's trilogy insight (V) refusing fake workers

【逆向】脱壳后修复IAT并关闭ASLR

华为认证云计算HICA

Flink 解析(一):基础概念解析

Connect to LAN MySQL

C# WinForm系列-Button简单使用

Set up the flutter environment pit collection
随机推荐
学习投资大师的智慧
Akamai 反混淆篇
Application service configurator (regular, database backup, file backup, remote backup)
MySQL advanced (index, view, stored procedure, function, password modification)
Activiti directory (I) highlights
06 products and promotion developed by individuals - code statistical tools
Re signal writeup
07 personal R & D products and promotion - human resources information management system
自动化运维利器-Ansible-Playbook
Flink 解析(四):恢复机制
Total / statistics function of MySQL
EasyRE WriteUp
Resume of a microservice architecture teacher with 10 years of work experience
À propos de l'utilisation intelligente du flux et de la carte
Flink 解析(二):反压机制解析
vscode
03 products and promotion developed by individuals - plan service configurator v3.0
Learn the wisdom of investment Masters
Final review of information and network security (based on the key points given by the teacher)
03个人研发的产品及推广-计划服务配置器V3.0