1、What projects are suitable for automation testing?
Keywords: invariant, repetitive, normative
1) Task testing is clear and requirements do not change frequently
2) The project cycle should be long enough
3) Automated test scripts can be reused, e.g.: more frequent regression testing
(4) The development of the software system under test is relatively standardized and can ensure the testability of the system
(5) Stable software system interface with few changes
6) Less pressure on the project schedule
2、What is PO mode?
It means that a specific page is transformed into an object in the programming language, page characteristics are transformed into object properties, and page operations are transformed into object methods.
(1) in layman's terms, treat each page as an object, the page layer to write the positioning of the element methods and page operation methods
2) The use case layer calls the operation method from the page layer and writes it as a use case
3) It is possible to do the separation of positioning elements and scripts
4) Mainly used to achieve a separation of page operations and test logic
3、What are the encapsulation principles of the PO model?
1) To encapsulate the function or service in the page, such as clicking on the page element, you can go to a new page, then you can encapsulate the method "Go to new page" for this service.
2) encapsulate the details, only provide the method name or interface to the outside world, try not to expose the page's internal
3) Don't use assertions in the details of encapsulated operations, put assertions in a separate module that
4) Click a button will open a new page, you can use the return method to jump, such as return MainPage () that jumps to the home page
5) The entire PO you do not need to encapsulate the behavior of the entire page, use what logic to encapsulate what
(6) an action may produce different results, such as clicking the button, may be successful, may also fail, for the two results encapsulated in two methods: click_success and click_error
4. What are the roles of *args and **kwargs in Python?
All of them are variable length parameters, to solve the problem of parameter not fixed.
args is a non-keyword argument for tuples; kwargs is a keyword argument (dictionary)
That is, args represents any number of unnamed arguments, whereas kwags represents a keyword argument with a corresponding relationship.
When using it, you need to be careful that *args comes before **kwags, otherwise a syntax error will occur.
5. What is the garbage collection mechanism in Python?
Garbage Collection, or GC for short, is a mechanism that comes with the Python interpreter and is specifically designed for garbage collection.
When defining a variable, memory space is requested, and when the variable is used up, the memory space occupied by the variable should also be released, and Python reclaims it by the GC mechanism.
Regardless of the garbage collection mechanism, it is generally divided into two phases: garbage detection and garbage collection.
Garbage detection is the process of distinguishing between "reclaimable" and "non-reclaimable" memory in allocated memory.
Garbage collection, on the other hand, enables the operating system to regain control of the recoverable memory blocks identified during the garbage detection phase.
The so-called garbage collection does not directly empty this block of memory of data directly, but gives the right to use it back to the operating system, and will not be hijacked by the application program.
What's garbage?
1) A variable is garbage when it has been called and is no longer needed.
2) When the variable name pointing to the address of the variable points to another address, the original variable memory address cannot be accessed, and the variable is then also garbage.
6、How to position hidden elements in selenium?
First of all, selenium is not able to manipulate the hidden elements (but can be positioned normally), itself this framework is designed so that if you have to go to operate the hidden elements, then the js method to operate, selenium provides an entry point can be executed js script.
The attributes of an element are hidden and displayed, mainly controlled by the type="hidden" and style="display: none;" attributes.
7. Close the difference between quit and close in the browser
Simply put, both can be implemented to exit the browser session function.
Close only closes the browser, whereas quit closes all browsers and also kills the driver process.
8, give examples of those exceptions you have encountered
- ElementNotSelectableException : ElementNotSelectableException
- ElementNotVisibleException : ElementNotVisibleException
- NoSuchAttributeException :No Such AttributeException
- NoSuchElementException: No Such Element Exception
- NoSuchFrameException :should notframeexceptions
- TimeoutException : Timeout Exception
- Element not visible at this point :Not visible at the current point element
9, how to deal with alert pop-up window?
1) First switch to the alert popup box using the switch_to_alert() method
(2) you can use the text method to get the pop-up text information
3) Click the confirm button via accept()
4) Cancel the popup box by clicking the cancel button via dismiss()
5) through the text () to get the text of the pop-up window
10、How to handle multiple windows in selenium?
Handle: a unique identifier for the window
1) First get the handle of the current window driver.current_window_handle
2) then get all the window handles driver.window_handle
3) Loop to determine whether it is the window you want to operate, if so, you can operate on the window; if not, use driver.switch_to_window method to jump to a new window.
11、How to determine whether an element exists in selenium?
Selenium does not provide a native way to determine whether an element exists or not, generally we can determine this by locating the element + exception catching.
12. What are the three types of waiting in automation? What are their characteristics?
1) Thread waiting (forced wait) as in (2): thread forced to sleep for 2 seconds, after 2 seconds, then execute the subsequent code. It is recommended to use less.
(2) imlicitlyWait (implicit wait) will continue to look for elements in the specified time frame until the element is found or timeout, characterized by having to wait for the entire page to finish loading.
(3) WebDriverWait (explicit wait) is usually a function of our custom code, this code is used to wait for an element to finish loading, and then continue to execute the subsequent code.
13、How to ensure the success rate of operating elements in selenium? That is to say, how to ensure that the clicked element must be clickable?
1) Use WebDriverWait() to explicitly wait for the element to load out and then perform the element operation.
(2) minimize unnecessary operations: you can directly access the page, do not access by clicking on the operation
3) Some pages take too long to load, consider interrupting the load
4) Developers standardize development habits, such as adding unique names, ids, etc. to page elements.
14、How to improve the execution speed of selenium script?
1) Use explicit waiting and reduce the use of forced or implicit waiting.
2) Reduce unnecessary operational steps.
3) If the page loads too much content, set a timeout to interrupt the page loading.
15、Use cases are often unstable in the running process, that is to say, this time it can be passed, the next time there is no way to pass, how to improve the stability of the use case?
1) Try to add an explicit wait time before the element that often fails detection, and wait for the element to be operated on to appear before performing the following operation.
2) Use try to catch and handle exceptions.
3) Try to use a test-specific environment to avoid other types of testing at the same time, causing interference with the data
16. What is your execution strategy for automation use cases?
The execution strategy for automated test cases is dependent on the purpose of the automated test, and there are usually several strategies as follows:
1) Automated test cases are used for monitoring, in this purpose, you can set the automated test cases to be executed on a timed basis, if they are executed every five minutes or an hour, just create a timed task on jenkins.
2) Use cases that must be regressed. Set the test cases as triggered execution and bind the automated test task to the developer's build task on jenkins. When the developer goes up to the code in the simulation environment, the automation test case will be triggered for execution.
3) Test cases that don't need to be executed often. Like the full amount of test cases, there is no need to always return to the execution, some non-major lines of business also do not need to return to the time. This type of test cases using manual execution, create a task in jenkins, need to be executed when manually to build can be.
17. What is continuous integration?
Continuous integration is a software development practice in which team development members frequently integrate code into trunk, meaning that integration may occur multiple times per day.
It has two main benefits:
1) Quickly find errors. Every bit of update completed, it is integrated into the trunk, which allows you to quickly find errors and locate them more easily.
2) Prevent branches from deviating significantly from the trunk. If it's not integrated often and the trunk is constantly being updated, it can make future integrations more difficult or even difficult to integrate.
Purpose:
The purpose of continuous integration is to allow products to iterate quickly while still maintaining high quality. Its core measure is that code must pass automated tests before it is integrated into the trunk. As soon as one test case fails, it cannot be integrated.
18, automated testing is not required to connect to the database to do data validation?
Required for interface testing, not for UI automation
19, there are several elements commonly used positioning methods, respectively? Which one do you favor the most and why?
8 types, namely: id, name, class name, tag name, link text, partial link text, xpath, css
The one I use most often is xpath (or CssSelector)
Because in many cases, the attributes of html tags are not standardized enough to be positioned by a single attribute, this time you can only use xpath to reimplement the positioning of a unique element.
In fact the fastest to locate is the Id because ids are unique, however most devs don't set ids.
20、How to locate dynamically loaded elements on the page?
Dynamic attribute change means that the element does not have a fixed attribute value, so it can only be located by relative position, such as through the axis of xpath, to find the element's parent or child nodes, etc.
21、After clicking the link, will selenium automatically wait for the page to finish loading?
It won't.
So sometimes, when selenium doesn't finish loading a page, requesting a page resource will incorrectly report that the element doesn't exist.
So first we should consider to determine, whether selenium has finished loading this page or not. Secondly, we can use a function to find the element. (Use display wait to wait for the page to load before manipulating the element)
22、What is the principle of webdriver client?
After selenium starts, the driver acts as a server and communicates with the client and the browser. client sends a request to the driver according to the webdriver protocol. driver parses the request and performs the corresponding operation on the browser and returns the result to the client.
23、What is the protocol of webdriver?
The WebDriver Wire Protocol
24、Which webdriver protocol is used to start the browser?
http protocol
25、How do I go about selecting an OPTION with value = xx in a dropdown box?
1) Methods provided inside the select class: select_by_value("xxx")
2) The syntax of xpath can also locate the
26、What are the common variable parameter types and immutable parameter types in Python?
Immutable data types include: integers, floats, negative numbers, booleans, strings, tuples
Variable parameter types include: dictionary, list, collection
27. How to highlight elements after positioning them (for debugging purposes)?
Reset element properties, add background, border to positioned elements
28. What are assertions?
assert, to determine whether the test result is consistent with the expected result
The purpose is to represent and verify the results expected by the software developer - when the program is executed to the position of an assertion, the corresponding assertion should be true. If the assertion is not true, the program aborts execution and gives an error message.
29/ What problems did you encounter during automated testing and how did you solve them?
1) Frequent changes to the page, often to modify the code inside the page object class
2) Automated tests have had occasional false positives
3) Automated test results appear to be covered: Jenkins creates folders based on time
4) Automated test code maintenance is more troublesome
5) Automated testing for database comparison data
30, how to simulate the browser forward, backward, refresh operation
- driver.navigate().forward() //forward
- ().back() // backward
- driver.() //refresh
summarize
To this point this article on the 30 python automation testing interview questions and answers summary of the article is introduced to this, more related python automation testing interview questions content, please search for my previous posts or continue to browse the following related articles I hope you will support me in the future more!