Design your own selenium-Based Automated Testing Framework-Java (1)-Why does selenium still need a testing framework?

Source: Internet
Author: User
Tags testng

I am not responsible for any misleading information that has been exposed to automated testing for a short time.

Now that we have selenium, an open-source automated tool, why should we write another framework on our own?

Selenium is an automated tool and can certainly be used in testing, but it is not tailored for testing. Of course, we do not need any framework when writing simple scripts. Over time, or when there are more scripts, we find that there are many repeated codes, at this time, we can extract the repeated code to form a so-called framework.

 

First, a common test case, such as an Excel file, is used as an example. Each row represents a test step. Each step contains three parts (Step name, description, and expected result.

Testng + selenium I think there are also many people on the Internet using these two.

We customize a testcaseclass (test case class) to define a test case ). Let the class continue selenesetestbase, selenesetestcase, or selenesetestnghelper in selenium. Use a method (method) of testcaseclass to correspond to a test
Step. method name corresponds to step name,

Operation (selenium. * some actions) in the method corresponds to description, and assertions (such as assertequal) in the method correspond
Expected result.

Add the code to start selenium and disable selenium, so that a testcaseclass can run.

At this time, if we want to write 10 cases, the problem will come.

1) each time you run testcase, selenium needs to be instantiated, start, and close. Can I extract all the duplicates?

2) Can you design your own actions or assertions)

3) Can I save some environment information (such as OS, browser, server, and port) that selenium runs to the configuration file?

4) Can you split the test object and save it (for example, save it to an XML file )?

5) Can I separate the test data and save it (for example, save it to an XML or Excel file )?, Can we implement data iteration, not just duplicate copy code to implement different data tests.

6) Can I execute 10 cases at a time? Yes, of course. testng has its own configuration file. You can define N classes. However, I have a fixed mind that class files cannot be associated with test cases.

7) Exception Handling: If a test step fails, will it perform the following steps or skip this case directly.

8) If a testcase fails, can the following case be executed? Is there any dependency between cases?

9) Is there any detailed log output? When the execution fails, the error can be accurately located. Because automated testing requires no one to watch, log is also crucial.

10) Is there any detailed test result output? Can I customize the output content in multiple formats (XML, HTML, Excel, etc.

11) including working with other test tools, such as autoit, Hudson, and QC. How to Use
How does Hudson schedule jobs to execute a set of test cases? How can I upload the test result to a test management tool such as QC? And how to make autoit and deal with jobs that selenium cannot do.

 

The above problems are some problems I encountered in my work. testng cannot solve all the above problems. We can add some issues on the basis of testng to achieve these goals. You can write a set of methods to handle these problems.

Maybe we don't need such a function during the testing process, and we may encounter more problems. The most suitable principle is the best principle.

I hope to record my work and organize the above content step by step.

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.