当前位置:网站首页>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. .
边栏推荐
- Important knowledge points of redis
- 轻松上手Fluentd,结合 Rainbond 插件市场,日志收集更快捷
- What's the difference between using the Service Worker Cache API and regular browser cache?
- Es remote cluster configuration and cross cluster search
- Oracle database synonym creation
- PMP笔记记录
- 【5G NR】UE注册流程
- The mechanical hard disk is connected to the computer through USB and cannot be displayed
- Support vector machine for machine learning
- Numerical method for solving optimal control problem (I) -- gradient method
猜你喜欢

Kubernetes notes (III) controller

Selenium ide installation recording and local project maintenance

Kubesphere - set up redis cluster

Creating postgre enterprise database by ArcGIS

Method of converting GPS coordinates to Baidu map coordinates

从小数据量 MySQL 迁移数据到 TiDB

SSH link remote server and local display of remote graphical interface

Project summary --2 (basic use of jsup)

Project summary --04

GPS坐标转百度地图坐标的方法
随机推荐
Fluentd facile à utiliser avec le marché des plug - ins rainbond pour une collecte de journaux plus rapide
輕松上手Fluentd,結合 Rainbond 插件市場,日志收集更快捷
Characteristics and isolation level of database
Fluentd is easy to use. Combined with the rainbow plug-in market, log collection is faster
表达式的动态解析和计算,Flee用起来真香
论文笔记 VSALM 文献综述《A Comprehensive Survey of Visual SLAM Algorithms》
Example of joint use of ros+pytoch (semantic segmentation)
简易密码锁
ThreadLocal的简单理解
剖析虚幻渲染体系(16)- 图形驱动的秘密
Interesting research on mouse pointer interaction
Oauth2.0 - Introduction and use and explanation of authorization code mode
Push box games C #
Oauth2.0 - using JWT to replace token and JWT content enhancement
Print time Hahahahahaha
[system design] proximity service
Decision tree of machine learning
Es remote cluster configuration and cross cluster search
Click cesium to obtain three-dimensional coordinates (longitude, latitude and elevation)
Learning notes -- principles and comparison of k-d tree and IKD tree