当前位置:网站首页>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. .
边栏推荐
- Merge and migrate data from small data volume, sub database and sub table Mysql to tidb
- Chapter 8. MapReduce production experience
- Virtual memory technology sharing
- Exportation et importation de tables de bibliothèque avec binaires MySQL
- Shell conditional statement
- 【无标题】8 简易版通讯录
- IE browser flash back, automatically open edge browser
- Kubernetes notes (10) kubernetes Monitoring & debugging
- 【系统设计】邻近服务
- Oauth2.0 - using JWT to replace token and JWT content enhancement
猜你喜欢

JMeter linked database

Read blog type data from mysql, Chinese garbled code - solved

Project summary --2 (basic use of jsup)

Oauth2.0 - Introduction and use and explanation of authorization code mode

Oauth2.0 - user defined mode authorization - SMS verification code login

Fluentd is easy to use. Combined with the rainbow plug-in market, log collection is faster

arcgis创建postgre企业级数据库

Kubernetes notes (10) kubernetes Monitoring & debugging

Kubernetes notes (IV) kubernetes network

Oauth2.0 - using JWT to replace token and JWT content enhancement
随机推荐
Oauth2.0 - explanation of simplified mode, password mode and client mode
Example of joint use of ros+pytoch (semantic segmentation)
Migrate data from Mysql to tidb from a small amount of data
2022 CISP-PTE(三)命令执行
Leetcode solution - 02 Add Two Numbers
Advanced technology management - do you know the whole picture of growth?
代码管理工具
Oracle Database Introduction
方差迭代公式推导
YOLOV2学习与总结
JMeter linked database
Exportation et importation de tables de bibliothèque avec binaires MySQL
Kubernetes notes (IV) kubernetes network
剖析虚幻渲染体系(16)- 图形驱动的秘密
Docker advanced learning (container data volume, MySQL installation, dockerfile)
MySQL帶二進制的庫錶導出導入
conda和pip的区别
Migrate data from Amazon aurora to tidb
[set theory] equivalence relation (concept of equivalence relation | examples of equivalence relation | equivalence relation and closure)
Mysql database table export and import with binary