当前位置:网站首页>Common interview questions in automated testing

Common interview questions in automated testing

2022-06-23 04:36:00 fish_ study_ csdn

1、 What projects are suitable for automated testing ?


keyword : constant 、 Repetitive 、 canonical

The first point , Demand should not change too frequently ;

Second point , The project cycle should be long enough , If the automation code is not finished , The company went out of business , There's no need for Automation

The third point , Scripts can be reused : In some typical scenes , for instance “ Smoke testing 、 regression testing ” What's important is that automated testing is often used ;

Fourth, , Is the software being tested standard : For example, whether there are requirements documents 、 Standard interface documentation 、 Is there a prototype 、 Is your interface design standard ;

The first five , Manual testing is impossible ; For example, a performance test , You can't have... At the same time A thousand hands keep doing a little bit , The cost of automated testing is not particularly high

2、 What is? PO Pattern ?


PO Pattern : Full name :Page Object Model ( translate : Match only . AOBO pick can t. edamame ) abbreviation POM, It's called a page object , For the page 、UI Interface ;

PO Thought mainly comes from Martin Fowler (marktin Flowwer) stay 2004 At the beginning of an article published in, he didn't call PO , It is called window driver , later selenium Followed this idea , So it's changed to PO;

Main uses : Is to convert a specific page into an object in the programming language , Page properties are converted into object properties , Convert page operations into object methods ;

In automated testing , It is mainly used to separate page operation and test logic ;

3、PO What are the encapsulation principles of patterns ?


selenium In official wiki The above provides us with six principles , It can be understood in the actual test process :

The first principle is , The public method represents a service provided by the page , For example, we can put The login is encapsulated into a logo Methods , Encapsulate the search method into a facility method , Encapsulate the registration operation into a register Methods ;

The second principle is , Try not to expose the inside of the page ; Like a HTML There is also a top-down structure of the page ;

The third principle is , stay PO Generally, no assertion is made , Can achieve the separation of page logic and test logic

The fourth principle is ,PO Generally, the method inside returns self Or something else Page Object It can also be an element attribute

The fifth principle is , Whole PO You don't need to encapsulate the behavior of the entire page , Encapsulate whatever logic is used

The sixth principle is , For unified operation , If there are different results , Can be expressed in different ways , For example, a successful login has a jump , There is an error when the login fails ,

If you log in, you will be authorized , Then it can be encapsulated into three separate methods :login success、login error、login invalid
 

4、 Python in *args and **kwargs The role of ?

It's all variable length , It can solve the problem that the parameters in the function are not fixed ,*args The position parameters can be transformed into Yuanzu ;**kwargs You can put Convert keyword parameters into dictionaries ;

5、Python What is the garbage collection mechanism in ?

That we use a lot Python Interpreter CPython Three garbage collection mechanisms are mainly used to recover the invalid data and release the memory , Namely : Reference count 、 Mark clear also Generational recycling

6、Web Automated element positioning

Selenium in hidden Or is it display = none Whether the element of can be positioned to ?
You can't , Can write JavaScript Put... In the label hidden First change to 0, Repositioning elements

7、 Close the browser quit and close The difference between

Simply speaking , Both can be implemented to exit the browser session function ,close Is to close your current focus tab page , and quit Close all browsers tab page , And exit the browser session. You know the two differences , We knew quit Usually used before the end of the test operation ,close Used to close a page during the execution of a use case .
 

8、 Give an example of the exceptions you've encountered

stay selenium Automated testing process
Through this question , I know how many scripts you've written . The most common exception to the scripting process is this , This element cannot be found .
common selenium There are these :

ElementNotSelectableException : The element cannot select an exception
ElementNotVisibleException : The element does not see an exception
NoSuchAttributeException : There is no such attribute exception
NoSuchElementException: There is no exception for this element
NoSuchFrameException : There is no the frame abnormal
TimeoutException : Timeout exception
Element not visible at this point : The element is not visible at the current point

9 、 Close the browser quit and close The difference between

Simply speaking , Both can be implemented to exit the browser session function ,close Is to close your current focus tab page , and quit Close all browsers tab page , And exit the browser session. You know the two differences , We knew quit Usually used before the end of the test operation ,close Used to close a page during the execution of a use case .

10 、 How to deal with it alert Popup ,  stay selenium How to handle multiple Windows ?

webdriver Is able to deal with alert The popup window ,Selenium Provides Alert This interface . The relevant operation code is as follows :
// Switch to Alert
Alert alert = driver.switchTo().alert();

You click on a link , This link will be in a new one tab open , And then you're going to look for the element in the new tab Open page , So we need to use it here swithTo Method .
You need to get the current browser multi-window handle , Then jump to the new or old handle based on the determination

原网站

版权声明
本文为[fish_ study_ csdn]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/174/202206222314181864.html