1. How do you automate
In the requirements analysis stage, communicate with the front-end, standardize the front-end code, to avoid causing problems that can not be carried out in the later automation work.
During the use case design phase, pick out the use cases that are suitable for automation and organize them into a separate file to be saved.
Later in the project, after stabilization, you can start designing automation scripts.
Language python + automation testing tools selenium + unit testing framework unittest (here you can pick their own familiar say, such as pytest, etc.) + hierarchical model PO + test reporting HTMLTestRunner
What it is, the tools that need to be included in the test
selenium is a UI-based simulation of user behavior of a web automation testing toolkit , commonly used in web automation testing .
Required tools: webdriver, i.e. browser driver (different browser drivers are different, and related to the browser version).
codebase, the selenium library in python.
3. Talk about the basic way of positioning elements
name id classname tagname
link_text partial_link_next (fuzzy text positioning) css xpath
4. how many test cases were written for automation
The answer here will likely be followed by a question about how many total use cases were written, suggesting a return to automated test cases being about 15% of all use cases (no more than 20%).
5. automated test scripts did you encounter any problems while writing them?
1. Check whether you have positioned yourself in the wrong way?
2. Program loads too fast for the page to react? -- Element wait
3. Some input boxes must be clicked before typing
4. The element to be manipulated is in a new window? -- switch to new window (handle)
5. The element to be manipulated is inside a frame/iframe tag? -- Toggle form
6. Is the element you want to work on blocked by another element? -- Change the value of display to none.
7. Is the element to be manipulated a read-only element? -- Change the value. Or delete the readonly attribute.
8. the element to be manipulated is at the bottom of the page? -- manipulate scrollbars
6. How to improve the speed and efficiency of automation operations
- Use less sleep and more element waiting.
- In the case layer, the code for connecting to the database is written in setUpClass.
- If more than one elif is involved, write the most likely condition first.
- Minimize file IO (input/output) operations if you don't have a lot of test data.
- For some pages. For some pages, which must be loaded before execution can continue, you can use the display wait, which will continue to execute after an element is found, without waiting for all elements to be loaded successfully.
- Improve the stability of the scripts to avoid unstable scripts affecting the efficiency.
What are the decorators of the What are some of them?
Make the code do more without changing it
@classmethod @staticmethod @ddt @data @
8. how to improve the stability of automation scripts
1. Absolute path without xpath. Relative paths, don't jump too many levels to find the parent tag.
2. Unstable due to network. Use implicit wait.
3. Unstable due to some randomly occurring elements. Use try
4. Instability due to test data. Delete it in teardown.
9. what kind of project is suitable for automation (why did you do automated testing for your previous xx project)
The project is more stable with a long cycle, fewer changes in requirements, and fewer changes in the UI.
Repeated testing or regression testing more
10. A word about element waiting
Implicit waiting:
Implicit wait is global and once set, it will take effect for all elements in the test script.
It tells the WebDriver how long to wait before throwing a not found element exception.
Implicit wait applies to the find operation for all elements on the page.
If the element is found within the set time, WebDriver will continue execution; if it times out, it throws a NoSuchElementException.
Implicit wait is usually set once at the beginning of the test script.
Display Waiting:
Explicit waiting is localized; it only works for specific element lookup operations.
It allows you to wait for a specific condition to hold, such as waiting for an element to appear.
Explicit waits are more flexible, allowing you to wait for specific elements or conditions rather than blindly waiting for a fixed amount of time.
Explicit waiting is usually implemented using the WebDriverWait and ExpectedConditions classes.
An explicit wait does not suspend the execution of the test script; it periodically checks to see if the conditions are met.
11. Commonly used libraries
Standard libraries: os, csv, sys.... etc.
Third-party libraries: pandas, PyYAML, Pytest..... etc.
12. What are the possibilities that an element cannot be positioned
1. Internet speed problem, the element didn't load out
2. Code writing errors
3. Nested in frame/iframe tags
4. New element in a new window, switch window switch_to code
5. At the bottom of the page, you need to operate the scroll bar
6. Element readonly readonly
13. Difference between deep copy and shallow copy
a = [1,3,[4,5]]
# Shallow copy: the address of the memory space being copied. It's the same as pointing to the same object. If the source data is modified, the copy is modified as well.
b = () # Shallow copy
print(b)
a[2][0] = 99 # Change the value of 4 in a's nested list to 99.
print(a)
print(b) # b is changed as well.
# Deep copy: creates a separate space in memory to hold values. Changes to the source data do not affect the modified data.
from copy import deepcopy
a = [1, 3, [4, 5]]
b = deepcopy(a)
print(b)
a[2][0] = 99
print(a)
print(b)
14. Bubble Sort
The first number is compared to the second, the smaller one comes first, and so on.
a = [6,4,2,65,1,7]
# ()
# print(a)
for i in range(len(a)): # range(0,6) outer loop, control number of loops.
for j in range(0,len(a)-1): # Inner loop, compare all numbers once. if a[j] > a[j] > a[j] >
if a[j] > a[j+1].
a[j],a[j+1] = a[j+1],a[j] # Just swap places.
print(a)