当前位置:网站首页>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);
}
}
#endregion
The 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 :
边栏推荐
- Only learning C can live up to expectations TOP4 S1E6: data type
- SQL调优小记
- 8086 memory
- EasyRE WriteUp
- Ce n'est qu'en apprenant que c est à la hauteur des attentes Top5 s1e8 | s1e9: caractères et chaînes & opérateurs arithmétiques
- 自动化运维利器-Ansible-Playbook
- Jetpack compose 1.1 release, based on kotlin's Android UI Toolkit
- 關於Stream和Map的巧用
- Logical operation instruction
- mysql高级(索引,视图,存储过程,函数,修改密码)
猜你喜欢
Wu Jun trilogy insight (IV) everyone's wisdom
肖申克的救赎有感
Flink源码解读(三):ExecutionGraph源码解读
1. Introduction to JVM
C#版Selenium操作Chrome全屏模式显示(F11)
轻量级计划服务工具研发与实践
Assembly language segment definition
Models used in data warehouse modeling and layered introduction
自动答题 之 Selenium测试直接运行在浏览器中,就像真正的用户在操作一样。
ByteDance overseas technical team won the championship again: HD video coding has won the first place in 17 items
随机推荐
Brush questions during summer vacation, ouch ouch
Flink 解析(三):内存管理
【逆向】脱壳后修复IAT并关闭ASLR
吴军三部曲见识(四) 大家智慧
[VNCTF 2022]ezmath wp
Resume of a microservice architecture teacher with 10 years of work experience
mysql的列的数据类型详解
EasyRE WriteUp
Learn the wisdom of investment Masters
MySQL advanced (index, view, stored procedure, function, password modification)
Flink源码解读(二):JobGraph源码解读
05 personal R & D products and promotion - data synchronization tool
1. Introduction to JVM
Akamai浅谈风控原理与解决方案
Program counter of JVM runtime data area
EasyRE WriteUp
[reverse intermediate] eager to try
Instructions for Redux
8086 memory
MySQL basic addition, deletion, modification and query of SQL statements