Python+selenium Automated Software Testing (13th): Selenium face Test

Source: Internet
Author: User
Tags xpath

Objective
Recently saw a group of small partners posted a set of interview questions, and recently job-hopping gold season, small series can not help but take a moment to summarize the next

How do I determine if an element exists in selenium?
The Expected_conditions module provides 16 ways to determine the existence of an element in the DOM:
presence_of_element_located
"" "an expectation for checking this an element was present on the DOM of a page. This does not necessarily mean, the element is visible.
The judgment element exists in the DOM, and the presence does not mean that it is visible (that is, it can be hidden, and presence does not mean that it can be clicked)

"""

Second, selenium in the hidden or display = None of the elements can be located?
Positioning is can be located, but cannot operate, can judge the element is_displayed ()
If you want to click, you can use JS to remove the Dispalay=none properties

Third, how to ensure the success rate of operating elements in selenium? So how do I ensure that the element I clicked on must be clickable?
Webdriverwait () and Expected_conditions judgment method encapsulation, cyclic judgment page elements appear after the operation, this can greatly improve the success rate of the operating elements.

Iv. How to improve the execution speed of selenium scripts?
1. Use sleep less, try not to implicitly_wait
2. Multi-use explicit wait method
3. Get a computer with good performance
Five, use cases in the operation of the process often appear unstable situation, that is, this can pass, the next time there is no way to pass, how to improve the stability of use cases?
As with the third question, the package displays the wait and judgment method

Vi. What is the execution strategy for your automation use case?
1. Integrated into the Jenkins one-click execution, can be executed manually, or timed execution

Vii. What is continuous integration?
1. Continuous integration is a software development practice in which team development members often integrate their work, with each member being integrated at least once a day, which means that multiple integrations may occur on a daily basis.
Each integration is validated through automated builds, including compilation, release, and automated testing, to identify integration errors early.
Eight, automated testing is not the need to connect to the database to do data validation?
1 UI Automation does not require
2 Interface testing will require

Nine, Id,name,class,xpath, CSS selector these attributes, which one do you prefer, and why?
1.CSS, CSS syntax concise, fast positioning (XPath syntax long, positioning slow, not stable)

X. How to locate dynamically loaded elements on a page?
1. The webdriverwait () method loops through the query to see if the element is loaded.

Xi. How to locate elements with dynamic changes in attributes?
1. First find the invariant properties of the element, if all change, then find the same parent element, with hierarchical positioning (status quo)

12. After clicking on the link, will selenium automatically wait for the page to load?
1. This will not wait, not finished loading can also be done next


13. What is the principle of webdriver client?

[Webdriver Implementation principle] (http://www.cnblogs.com/timsheng/archive/2012/06/12/2546957.html)
By studying the source code of Selenium-webdriver, I found that the principle of webdriver is not inscrutable speculate. Here is an example of the firefox-webdriver implementation of Webdriver Ruby binding, which briefly describes how Webdriver works.
When the test script starts Firefox, Selenium-webdriver will start the Firefox browser in the new thread first. If the test script specifies Firefox profile, then start with the profile, otherwise City 1 profiles and start Firefox;

Firefox is generally started by-no-remote method, Selenium-webdriver will bind Firefox to a specific port after the completion of the binding, the Firefox instance as Webdriver remote server exists;

The client (that is, the test script) creates 1 sessions in which a restful request is sent to the remote server through an HTTP request, and the remote server resolves the request, completes the operation and returns response;

The client accepts response and parses its return value to determine whether to go to the 3rd or end script;
This is Webdriver's workflow, and it looks complicated. In fact, when we understand the principle of webdriver implementation, it should be simpler to understand the above problems.

Webdriver is designed according to the classic design pattern of server–client.
The server side is remote server, which can be any browser. When our script launches the browser, the browser is the remote server, its role is to wait for the client to send the request and make the corresponding;
The client side is simply our test code, and we test some of the behavior in the code, such as opening the browser, jumping to a specific URL, and so on, in the form of an HTTP request sent to the test browser, which is the remote Server;remote
The server accepts the request, performs the action, and returns information such as execution status, return value, and so on in the response;

14. What is the Webdriver agreement?

What Webdriver protocol is used to launch the browser?

16. What is Page object design mode?

1. In popular terms, each page as a Page object, page-level write positioning element method and page operation method
2. Use case layers invoke action methods from the page layer, written as use cases
3. The separation of positioning elements from the script can be achieved


17. What is page factory design mode?
Create a BasePage class to create multiple page classes that inherit the BasePage use case layer calling the page class

18, how to choose a drop-down box in the VALUE=XX option?
1.select class inside the method provided: Select_by_value ("xxx")
2.xpath syntax can also be located in the


19, how to highlight elements after positioning elements (for debugging purposes)?
1.js method that directly lets the element be pinned
2. If not highlighted after clicking, use JS to modify the attribute bar (Universal JS)

20. What is an assertion?
1.assert to determine if the test results are consistent with the expected results

21. If you choose the automated test scheme, which language would you prefer, Java,js,python or ruby?
1. Big Python Mighty, JS also a synopsis understand

22. In the Page object setting mode, is it necessary to add assertions to the method that is positioned in the page?
1. Do not need, page page only do element fetching and operation method


23, Page object design mode, how to implement the jump?
1. Initialize driver parameter, page class pass driver parameter

24. Where are the automated test cases coming from?
1. Write for yourself
2. Written by others
(It's a bit of a brain problem, it's not falling from the sky anyway)


25. What do you think is the biggest flaw in automated testing?
1. High maintenance costs when changes in demand are high

26. What is a layered test?

1. Data layer
2. Interface Layer
3.UI Layer
Be free to play.

27, Webdriver can be used to do interface testing?
1. No, Webdriver is a web-specific UI Automation parameter

Summary: From the whole face of the question, the difficulty is still quite large, especially the optimization of the script performance, if only a few elements of a simple positioning is completely unable to start optimization.
The interviewer who can raise these questions also has a certain strength.

Python+selenium Automated Software Testing (13th): Selenium face Test

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.