Automated testing interview questions and answers (with resume interview template)

1. Will you encapsulate the automated testing framework?

This is the most frequently asked question, and many companies even write it directly in the recruitment requirements!

Of course, the main core framework of the automation framework is the layered + PO mode: respectively: the base encapsulation layer BasePage, the PO page object layer, and the TestCase test case layer. Then add the log processing module, the ini configuration file reading module, the unittest+ddt data driver module, and the jenkins continuous integration mode.

2. How to implement and promote automated testing in the company?

1. The project team researches and selects automation tools and holds a meeting to demonstrate demo cases. We mainly demonstrate selenium and robotframework;

2. Build an automated testing framework and gradually implement automation in the project;

3. Solidify the automation process and framework of the project into documents;

4. Promote the application to other project groups of the company.

Automated testing interview video tutorial: A must-see for a job interview, how to do an automated testing resume? Teach you to harvest 7 offes in 3 days_哔哩哔哩_bilibili icon-default.png?t=N6B9https://www.bilibili.com/video/BV1kY4y1X7LQ/?spm_id_from=333.999.0.0

 

3. Please describe the automated testing process?

1. Write an automated test plan;

2. Design automated test cases;

3. Write automated test frameworks and scripts;

4. Debug and maintain the script;

5. Unattended testing;

6. Later script maintenance (adding use cases, developing updated versions).

4. How to write automated test cases? Choose one of the following answers:

1. The use case is designed by the automation test engineer himself. Generally, the basic business process is the main one at the beginning (login-complete a business-exit);

2. Screened from system test cases or provided by business engineers.

5. What was the execution strategy of automated testing in the previous project?

In the previous project, it was executed regularly, and the set execution time was 12 o'clock in the evening. After the execution was completed, an email notification would be sent automatically

6. Are there many bugs found in automated testing?

Not many, because the project team used to write automated scripts for the basic functions that have been tested and execute automated tests in subsequent versions. It mainly ensures that the functions that have passed the test will have no problems after the new version is updated.

7. What do you think is the value of automated testing? Why does your company need automated testing?

After the introduction of automated testing, it can replace a large number of tedious regression testing tasks, liberate business testers, and allow business testers to concentrate on complex business function modules. Automated testing generally automates stabilized functions to ensure that no bugs will occur in previously stabilized functions due to product updates.

8. Has automated testing ever falsely reported bugs? What about false positives?

There have been false positives. Sometimes the automated test report shows that a bug has been found, but the actual bug does not exist through manual testing.

Common reasons for false positives are:

1. Element positioning is unstable, and the stability of the script needs to be improved as much as possible;

2. The development updated the page but the test did not update and maintain in time!

9. During the automated testing process, what problems did you encounter and how did you solve them?

1. Change the page frequently, and often need to modify the code in the page object class;

2. There have been occasional false positives in automated testing;

3. Coverage of automated test results: Jenkins creates folders according to time;

4. Automated test code maintenance is more troublesome;

5. Automated testing for database comparison data.

10. What framework did you use for automated testing in the previous company?

You can name one of the following:

1.python+selenium+unittest+htmltestrunner

2.python+selenium+pytest+allure

3. robotframework+Selenium2Library

12. In selenium automated testing, what type of testing do you generally complete? Automated coverage?

Mainly smoke testing and regression testing. The regression test mainly writes some scenarios with stable functions, which are realized by automated means to save test time. Because the automated test cases are constantly updated and iterated, there is no deliberate statistics, about 30%-40%!

13. How to highlight the current element during script execution?

This is actually using javaScript to modify the border style of the current element to achieve the highlighting effect.

14. If an element cannot be positioned, what reasons do you generally consider?

1. Page loading elements are too slow, adding waiting time;

2. The page has a frame page, you need to jump into the frame frame before positioning;

3. The element may be a dynamic element, and the positioning method needs to be optimized. Some elements can be used for positioning or positioning through parent nodes or sibling nodes;

4. The element may be recognized, but it cannot be operated, such as the element is unavailable, unwritable, etc. You need to use js to complete the pre-operations first.

15. What element positioning methods are you familiar with?

id name classname link_text css xpath

16. How to deal with the frame page?

First use driver.switch_to.frame() to jump into the frame,

Then operate the page elements,

Use driver.swith_to.default_content() to jump out after the operation.

17. How to deal with the alert pop-up window?

Use the driver.switch_to.alert method to jump to the alert pop-up window first,

Then click the OK button through accept, click the cancel button through dismiss, and get the text of the pop-up window through text().

18. How to deal with multiple windows in selenium?

This multi-window jump processing is often encountered in projects. That is, when you click a link, the link will be opened in a new tab, and then you need to find elements on the page opened in the new tab,

1. We use driver.current_window_handle to get the current window handle before clicking the link;

2. Click the link again. After clicking, get the handles of all windows through driver.window_handles;

3. Then loop to find the handle of the new window, and then jump to the new window through the driver.switch_to.window() method.

19. How to verify that the element is enabled/disabled/checked?

After locating the element: judge by three methods: isEnabled(), isSelected(), and isDisplayed() respectively.

20. How to handle the drop-down menu?

There is a class called Select in Selenium, which supports the operation of drop-down menus. The method of use is as follows:

1. Positioning elements

2. Convert the positioned element into a Select object.

sel = Select(positioned element object)

3. Select the drop-down box by subscript or value or text.
sel.select_by_index(index);
sel.select_by_value(value);
sel.select_by_visible_text(text);

21. How do you deal with web forms like calendars?

First of all, analyze the front-end code of the calendar plug-in on the current web page to see if it can be realized by element positioning and clicking on the date. If not, you may need to use javascript. There are also some calendar controls that have a text input box, and the sendKeys() method can be used to directly pass in a time data.

22. Give an example to explain the abnormalities you have encountered

Common selenium exceptions are:

NoSuchElementException: No such element exception
TimeoutException: Timeout exception

ElementNotVisibleException: The element is not visible exception
NoSuchAttributeException: No such attribute exception
NoSuchFrameException: No such frame exception

23. Close the difference between quit and close in the browser

To put it simply, both can realize the function of exiting the browser session, close is to close the tab page you are currently focusing on, and quit is to close all browser tab pages and exit the browser session. Knowing these two differences, we know that quit is generally used before the end of the test, and close is used to close a certain page during the execution of the use case.

24. How to implement screenshots in Selenium, and how to implement screenshots only when use case execution fails?

In Selenium, a get_screenshot_as_file() method is provided to take screenshots. It is generally used in conjunction with try/except to capture exceptions to take screenshots of errors.

                 

 Automated testing interview video tutorial: A must-see for a job interview, how to do an automated testing resume? Teach you to harvest 7 offes in 3 days_哔哩哔哩_bilibili icon-default.png?t=N6B9https://www.bilibili.com/video/BV1kY4y1X7LQ/?spm_id_from=333.999.0.0

 

25. How to upload files?

After locating the element, just use the send_keys() method to set it directly, and the parameter is the path of the file to be uploaded.

26. What are the three types of waiting in automation? What are their characteristics?

1. Thread waiting (forced waiting) such as time.sleep(2): The thread is forced to sleep for 2 seconds, and after 2 seconds, the subsequent code is executed. It is recommended to use less.

2. ImplicitlyWait (implicit wait) will continue to search for elements within the specified time range until the element is found or timed out. The characteristic is that it must wait for the entire page to load.

3. WebDriverWait (explicit wait) is usually a function code that we customize. This code is used to wait for an element to be loaded before continuing to execute subsequent codes.

27. Can the test script you write run on different browsers?

Of course, the use cases I wrote can run on the three browsers of IE, Firefox and Google. The idea of ​​implementation is to encapsulate a method and pass in a browser string respectively. If IE is passed in, IE is used, if FireFox is passed in, FireFox is used, and if Chrome is passed in, Chrome browser is used, and the browser to be used can be configured in the general ini configuration file. It should be noted that the drivers used by each browser are different.

28. What is PO mode and why should it be used?

PO is the abbreviation of Page Object mode. It is a design idea, which means that a page is regarded as an object, and the operation method between the elements of the page and the elements is the attribute and behavior of the page object. The PO mode generally uses a three-layer architecture, namely: the base encapsulation layer BasePage, the PO page object layer, and the TestCase test case layer.

29. How to implement drag and drop scroll bar in Selenium?

In Selenium, element positioning will automatically help you drag and drop to the corresponding position, so there is no built-in scoll method. But this has limitations. For example, the height of the current page is too long, the default is the upper half of the page, and the element you locate is at the end of the page. At this time, an exception that the element is not visible may be reported. We need to use javaScript to drag and drop the page scroll bar.

Generally, we can drag and drop in two ways, one is based on dragging coordinates (pixel unit), and the other is based on dragging to a reference element attachment.

Code example (drag and drop according to element coordinates):
JavascriptExecutor jse= (JavascriptExecutor)driver;
jse.executeScript(“window.scrollBy(0,250)”, “”);

30. How to implement mouse hover, keyboard events and drag and drop actions?

In Webdriver, to handle keyboard events and mouse events, generally use the methods provided by the Actions class, including mouse hovering, dragging and key combination input.

Here are a few methods:

Method: clickAndHold()
Usage scenario: find an element, click the left mouse button, and don't let go. You can try this scene by clicking the mouse without releasing it.

Method: contentClick()
Usage Scenario: Simulate right mouse click, usually the right button will bring up the menu.

Method: doubleClick()
Usage scenario: Simulate double-clicking of the mouse

Method: dragAndDrop(source, target)
Scenario: Simulate dragging an element from source to target position

Keyboard event method: keyDown(keys.ALT), keyUp(keys.SHIFT)
usage scenario: click the keyboard event, divided into two actions, one clicks the keyboard, and the second action is to release the click (release)

31. How to get the page title, floating text and error text, and verify?

Title, we can get a string through the driver.getTitle() method, and then use the containsts method or equals method of the string to make an assertion.

Floating text (tooltip), generally use the Actions class, then the mouse hover method, and then get the tooltip string through the getText() method.

For error information, directly locate the error field first, and then get the error text through the getText() method. The main assertions include include, equal, not equal, not included, and what to start with.

32. How do you manage your test cases and execute them?

To write use cases and manage and execute use cases, we need to use the unit test framework to achieve. If it is Java language, there are generally junit and TestNG. If it is python, the common one is unittest.
Tell me about your actual situation. For example, I use TestNG a lot, and I need to configure the testng.xml file to execute test cases. Sometimes it is necessary to configure multiple testng.xml to implement different task scenarios. To expand, I may ask you about the knowledge points of the testng framework. For example, method dependencies, use case execution priorities, data source drivers, etc.

33. About automated test report generation?

Personally, I generally use TestNG's native test report, and there is also a third-party plug-in called reportNG, but I have not actually used it.

34. What is a Data Driven Framework? How is it different from Keyword Driven Framework?

Data-driven framework.
In this framework, test case logic resides in test scripts. Test data is separated and kept outside of test scripts. Test data is read from an external file (Excel file) and loaded into variables in the test script. Variables are used to enter values ​​and validate values.
Keyword driven.
Keyword/table driven frameworks need to develop data tables and keywords. They are independent of the test automation tool that executes them. Tests can be designed with or without the application. In keyword-driven testing, the functionality of the application being tested is documented in a table, along with step-by-step instructions for each test.

35. Explain the benefits of using TestNG instead of JUnit framework?

Advantages of TestNG over Junit:
In JUnit, we have to declare @BeforeClass and @AfterClass, which is a constraint in JUnit, while in TestNG there is no constraint like this.
TestNG provides more setUp/tearDown levels. 1.@Before/AfterSuite 2.@Before/AfterTest 3.@Before/AfterGroup
No need to extend any class in TestNG.
There are no method name constraints in TestNG, like JUnit.
In TestNG, we can tell the test that a method depends on another method, which is not possible in JUnit.

Grouping of test cases is available in TestNG but not in JUnit. Execution can be done on a group basis. For example, if you have defined many cases and segregated them by defining 2 groups as "departure" and "return". If you just want to enforce "sane" cases, then tell TestNG to enforce "sane". TestNG will automatically execute cases belonging to the "departure" group. Additionally, TestNG supports parallel test case execution.

36. Can TestNG be used to run a set of test cases?

Yes, TestNG framework supports execution of multiple test cases with the help of test groups.
It provides the following options to run test cases in a specific group.
If you want to execute test cases based on one of the groups such as regression tests or smoke tests, then:
@Test(groups = {"regression-tests", "smoke-tests"})

37. How to increase the execution speed of selenium script?

1. Optimize the waiting time, use WebDriverWait intelligent waiting instead of linear waiting sleep and implicit waiting implicitlyWait

2. Reduce unnecessary operations

3. If the server allows, use multithreading to implement concurrent execution of test cases

Summarize:

Thanks to everyone who read my article carefully! ! !

I personally sorted out some technical materials I have compiled in my software testing career in the past few years, including: e-books, resume modules, various job templates, interview books, self-study projects, etc. Everyone is welcome to click the link below to join the group chat to receive it for free. There are also big guys in the group to help answer questions, don't miss it.

   Python automated testing learning exchange group: a full set of automated testing interview resume learning materials to obtain Click the link to join the group chat [python automated testing exchange]: http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=DhOSZDNS-qzT5QKbFQMsfJ7DsrFfKpOF&authKey=eBt%2BF%2FBK81lVLcsLKaFqnvDAVA 8IdNsGC7J0YV73w8V%2FJpdby66r7vJ1rsPIifg&noverify=0&group_code=198408628

Guess you like

Origin blog.csdn.net/manbskjabgkb/article/details/131859504