In my opinion, the construction of an automated test platform is a good way to understand the development language, Unit Test framework, automated test drive, design pattern and so on. Therefore, in the next selection of the topic of automated testing to share with you my understanding of software development and automated testing. Just opened the blog, from the beginning of the most basic, is to write a beginner's programming notes, but also to the automation completely do not understand the small partners open. Time permitting will persist in renewing ... Follow-up article plans to talk to some enterprise-level automated test platform construction (hopefully time to finish ha ~ ~).
On the framework of automated testing, there are a lot of relevant comparisons on the Web, I am not commenting and comparing here. I am going to introduce selenium (follow-up will also have some other frameworks to introduce). If you don't yet know what the automated test framework and selenium are, please check out the relevant knowledge introduction, and I will not repeat it here.
Why do you choose selenium? There are a lot of related articles on the internet about his advantages, such as: open source, free, support a variety of development languages, support multi-browser ... Wait, wait. I chose this framework primarily from the extensibility of the framework itself, as well as the effectiveness of the team building automation platform.
- The extensibility of the framework: whether it is the design of the selenium itself (for the interface of the Automation Framework designer), or the extension of the powerful other features that you use to provide the programming language itself. The feeling is very good ~ ~ ~
- The construction of the automation platform: Because selenium itself supports many mainstream development languages C#,java,ruby ...
So whether you're a seasoned tester or a developer who wants to know about automation. To test the application of B/s structure, selenium is undoubtedly a good choice.
Do not say nonsense, the general start is from the environment to build, so ... In the first article, I also briefly talk about these little nutritional content, the purpose is to help the first contact with this thing of the small partners first to get the environment up.
Tools: VS2013, Nuget (vs will bring this tool), GitHub account (this article does not use, follow-up I will send code on GitHub for everyone to communicate)
Frame: Selenium (browser driver), Xunit.net (Unit test framework) [for why this unit test framework is selected, will be introduced in other articles later, in short I feel very useful]
Browser: Firefox, Chrome, IE all line.
Step 01: Open Your VS2013 and select "Extensions and Updates" to search for and install the Xunit.net project template
Step 02: Create a new xunit.net unit test Project (demo.seleniumtest) and click "OK".
Step 03: Right-click on the project's references and select Manager NuGet Packages ... to download the latest version of Xunit.net. , as well as the selenium driver package.
Search for and install the latest version of Xunit.net.
Search for and install the latest version of Selenium Driver.
Step 04: Finally can start to write code, here first made a simple example (visit Blog Park himself blog, just opened the blog plus click ~ ~ hehe). I'll introduce you to the article behind the principle.
Create a new test Class (Unittescase) and type the following code, which completes several operations:
- Start the Firefox browser.
- Type the blog address of the blog in the navigation bar.
- Click on the "Automated test" link in the category.
1 usingOpenqa.selenium;2 usingOpenQA.Selenium.Firefox;3 usingSystem;4 usingSystem.Linq;5 usingXunit;6 7 namespacedemo.seleniumtest8 {9 Public classUnittescaseTen { One /// <summary> A ///Visit the Blog Park - /// </summary> -[Fact (DisplayName ="Visit.cnblogs")] the Public voidvisit_cnblogs () - { -Iwebdriver Driver =Newfirefoxdriver (); - +Driver. URL ="Http://www.cnblogs.com/NorthAlan"; - varLnkautomation = driver. Findelement (By.xpath (".//div[@id = ' sidebar_postcategory ']/ul/li/a[text () = ' automated test ']")); + Lnkautomation.click (); A } at } -}
Step 05: Compile your project (Ctrl + Shift + B) and right-click on "Run Tests" on the test method to see a series of actions after starting Firefox. The browser was deliberately not closed in the code.
Summary: In fact, there is nothing to summarize, this piece is to everyone to an appetizer, no nutrition. Mainly to build the environment.
As for the Selenium for C # series, I plan to introduce you to some of the basics of Selenium driver and the extensibility points of the framework. Of course, there will be more articles on test framing and software building later. May my Lord bless me with the time to do these things ...
PS: That what, suggest beginner's small partner don't take what recording tool to record a script. Personally feel that there is no help for your technology ... Many will not say, I understand ha ~ ~ ~
[Small North de programming notes]: Lesson 01-selenium for C # Environment construction