当前位置:网站首页>Selenium - by changing the window size, the width, height and length of different models will be different
Selenium - by changing the window size, the width, height and length of different models will be different
2022-07-03 06:23:00 【wumingxiaoyao】
introduction
I've been in contact with UI test , It involves such a scenario , Change page size , The default prompt of an input box on the verification page will be different . for example : The page width is set to be less than or equal to 1024, A short prompt should be displayed , Greater than 1204 Show long prompt .Case It is passed locally , But everyday Jenkins Running on the Remote VM On , It is completely inconsistent with expectations .1024 The width shows the prompt of growth . Come to the conclusion , Perform tests on different models , Set the same page width , But the expected results are actually inconsistent . This article is to solve this puzzle .
Summary :
- Solve the mystery Selenium Window Size
- Pixels ,PPI The concept of
- The problem is solved
Solve the mystery Selenium Window Size
Usually UI Automation Will Selenium The underlying method is encapsulated , Maybe you set the size in a way similar to the following .
Driver.ResizeWindow(width, height);
among width,height It's all integers , I will list some common display resolution settings . These resolution settings on the display distinguish the number of pixels representing the width and height of the display .
that Selenium The bottom one width and height What unit , Let's continue to dig further .
public void ResizeWindow(int width, int height)
{
_driver.Manage().Window.Size = new Size(width, height);
}
Window.Size yes Size structure 
Size Structure :
System.Drawing Provide right GDI+ Access to graphic functions . among width and height It represents the number of pixels .
Point Structure :
So pass Selenium Set the page size to be consistent with the resolution set on the display , Both indicate the number of pixels displayed in width and height .
Pixels ,PPI The concept of
that , What is the relationship between the number of pixels and the width and height we can perceive . We need to understand a few concepts .
Pixels
Pixel is the abbreviation of image element , It is the smallest unit of all digital images . We use it 100% Or lower zoom level to view the image, you can't see the pixels . When you enlarge a picture , We can see a pile of small squares . These squares are pixels .

PPI
PPI (Pixels Per Inch) Is the pixel density , The number of pixels per unit length on the screen : This unit length is defined as "1 Inch ". such as 1 There are two pixels in inches ,PPI Namely 2.1 Within inches 10 Pixels ,PPI Namely 10. therefore PPI The higher the value , That is to say, the higher the density of the display screen, the higher the image density . Of course , The higher the density of the display , The higher the fidelity , The more expensive the monitor is .
Refer to the previous picture to explain the connection of several concepts .
The popular science 2K 4K
We often hear movie theater points 2K, 4K Screen concept .
2K Resolution refers to a level of screen resolution , Refers to the horizontal pixel of the screen reaching 2000 above . It is the mainstream projection resolution of domestic digital cinema .2K There are many kinds of resolutions , The most common cinemas 2K Refer to 2048×1152, Other 2048×1536(QXGA)2560×1600(WQXGA),2560×1440(Quad HD) Also known as different annotations 2K.
4K The name comes from its horizontal resolution of about 4000 Pixels (pixel), Common in the film industry 4K Resolution includes Full Aperture 4K(4096 x 3112)、Academy 4K(3656 × 2664) And so on . For mainstream home appliance manufacturers , They are more inclined to make close 4K Of Quad Full HD(3840×2160) equipment , Because the display scale of this resolution standard is 16:9, It is close to the viewing proportion currently accepted by consumers .
The problem is solved
Usually each model PPI The pixel density is fixed , So a certain number of pixels , Different PPI, The length is different ,PPI The lower the , The longer it is , On the contrary, the lower the length . Back to our original question , Set up 1024 The width of the number of pixels , Because of the local PPI Than remote PPI high , So remote VM The display page width will be wider than the local display . The solution is to set window size Reduce the width by pixels . The original 1024 Change to 1000 That's all right. .
边栏推荐
- Push box games C #
- Decision tree of machine learning
- Local rviz call and display of remote rostopic
- ThreadLocal的简单理解
- Scripy learning
- [set theory] equivalence relation (concept of equivalence relation | examples of equivalence relation | equivalence relation and closure)
- Virtual memory technology sharing
- SSH link remote server and local display of remote graphical interface
- 技术管理进阶——你了解成长的全貌吗?
- 深入解析kubernetes controller-runtime
猜你喜欢

Use abp Zero builds a third-party login module (I): Principles

SSH link remote server and local display of remote graphical interface

YOLOV3学习笔记

Chapter 8. MapReduce production experience

How to scan when Canon c3120l is a network shared printer

Kubesphere - set up redis cluster

ssh链接远程服务器 及 远程图形化界面的本地显示

Kubernetes notes (10) kubernetes Monitoring & debugging

Support vector machine for machine learning

有意思的鼠标指针交互探究
随机推荐
arcgis创建postgre企业级数据库
Es remote cluster configuration and cross cluster search
Oauth2.0 - Introduction and use and explanation of authorization code mode
Common interview questions
Oauth2.0 - use database to store client information and authorization code
MySQL帶二進制的庫錶導出導入
Print time Hahahahahaha
POI dealing with Excel learning
冒泡排序的简单理解
远端rostopic的本地rviz调用及显示
YOLOV1学习笔记
使用conda创建自己的深度学习环境
Une exploration intéressante de l'interaction souris - pointeur
【系统设计】邻近服务
tabbar的设置
Migrate data from Amazon aurora to tidb
opencv
ruoyi接口权限校验
Advanced technology management - do you know the whole picture of growth?
有意思的鼠標指針交互探究