Selenium (Webdriver) Automated testing Frequently asked Questions answered (turn from: 0318)

Source: Internet
Author: User

Today, my friend asked me a few questions about the Selenium automation test, I looked at the feeling is more typical. Combined with my previous experience in automated testing, give some of the superficial answers, hope to help everyone, if you have any good views, hope to communicate with each other, learn from each other!

(1) 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?
A: Selenium to ensure that element success rate is through the positioning of elements, of course, its positioning methods are many, must be suitable. However, in the implementation of automation engineering, high-quality automated testing is not the only Test personnel guarantee. Developers are required to standardize development practices, such as adding unique name,id to page elements, which can greatly improve the accuracy of element positioning. Of course, if developers develop non-standard, we try to use relative address positioning when locating elements, which can reduce the influence of element positioning by page changes. As long as our elements are positioned accurately, it will ensure that every operation I make is consistent with my expectations.

(2) How to improve the execution speed of selenium scripts ?
A: The execution speed of the selenium script is affected by many factors, such as the speed of the network, the complexity of the operation steps, the rate of page loading, the waiting time we set in the script, the number of threads running the script, etc. Therefore, we can not pursue the speed of the unilateral, to ensure stability, to achieve a stable regression test is the key.

We can improve the speed in the following ways:

One, reduce the operation steps, such as after three or four steps to open the page we want to test, we can directly through the URL to open, reduce unnecessary operations.

Second, interrupt page loading, if the page loading too much content, we can see the reason for the slow loading, if the loaded content does not affect our testing, set the time-out period, interrupt page loading.

Third, in setting the waiting time, you can sleep fixed time, you can also detect an element after the occurrence of an interrupt wait can also increase the speed.

Four, configure TESTNG implementation multithreading. When writing test cases, be sure to achieve loose coupling, and then the server allows to set up multi-threaded operation, improve execution speed.


(3) 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?
A: At this point we have to analyze the causes of instability, and then targeted to solve the problem. There are several main aspects:
One, the network speed problem: Sometimes the page load is relatively slow, in the execution of the program to operate the elements are not displayed. This situation is more common, run a good time to pass the network, and then run again, the page is not open, will not pass. In order to improve stability, we can only sacrifice the elapsed time, before the element that often detects the failure, plus the wait time, and so on, and then perform the following operation.
Second, the reason for Selelnium: Selenium1.0 and 2.0 are still different, some of the functions in the 2.0 run does have sometimes effective, when the surface is invalid. If the mouseover () function, which is the case, we need to avoid the use of such functions.
Three, multi-threaded, test cases between the interaction. Although multi-threading time is faster, if the coupling between use cases is not well designed, it will affect the use case B when it is executed before use case B, and vice versa. In this case, if your automated test project is intended to be multithreaded, it is necessary to compare the test case test with the coupling degree, as far as possible, because the order of execution of multithreading is not controlled.


(4) What is the execution strategy for your automation use case?
A: The execution strategy for automated test cases is to look at the purpose of automated testing, usually with the following strategies:
First, automated test cases are used to monitor, and in this case, we set up automated test cases to execute on a timed basis, and if executed every five minutes or one hours, create a timed task on Jenkins.
Two, the use case must return. Some of the test cases, such as BVT test cases, we need to return to execution before any changes to the company's products go live. Then we set the test case to trigger execution and bind our automated test task to the development build task on Jenkins. Our automated test cases are triggered when the developer is in the upper code of the simulation environment.
Third, test cases that do not need to be executed frequently. Like a full-scale test case, we do not have to go back to the execution, there will be time consumption, some non-main lines of business do not need to always return. This kind of test case we use manual execution, in Jenkins to create a task, need to execute when the human to build.

Selenium (Webdriver) Automated testing Frequently asked Questions answered (turn from: 0318)

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.