Ironruby-write automated test scripts

Source: Internet
Author: User
Tags netbeans
ArticleDirectory
    • Running Environment
    • Find the codedui automation test-related class library
    • Test Cases
    • Compile Functions
    • Complete code
    • Run Test Cases
    • Note:
    • Ironruby blog

InUse codedui of vs2010 to build your own Automated Testing FrameworkI have introduced that I will use ironruby to write automated test scripts. I have encountered some problems in development because I am not familiar with ironruby. I have also shared these questions through a blog. In this article, I will introduce how to use ironruby and codedui to improve the automated test library to compile our own automated test scripts.OpenexpressappIn the topic, I will introduce some processes for compiling opentest. UI. If you are interested, please pay attention to them.

Running Environment

. NET framework 4

Find the codedui automation test-related class library

Codedui automated test libraries are placed inMicrosoft Visual Studio 10.0 \ common7 \ ide \ privateassemblies \Folder.ProgramI am not very clear about the content of the set. If you are interested in Microsoft's automated testing framework, you can check it out. I will not study it if I have not used it yet :)

Let's assume that we put it in the directory.D:/gzj/openexpressapp/tool/opentest/DLL

Test Cases

Here we take a notepad that everyone knows about window for testing. The path is C:/Windows/system32/calc.exe.

Compile Functions

As the search button and other functions can be reused, write several functions:

 
Def window (title) win = winwindow. newwin. searchproperties ["name"] = titlewinenddef button (parent, title) BTN = winbutton. new (parent); BTN. searchproperties ["name"] = titlebtnend
Complete Code
$ Load_path <'d:/gzj/openexpressapp/tool/opentest/DLL 'require "Microsoft. visual Studio. testtools. uitest. extension. DLL "require" Microsoft. visual Studio. testtools. uitest. extension. IE. DLL "require" Microsoft. visual Studio. testtools. uitest. extension. IE. communication. interOP. DLL "require" Microsoft. visual Studio. testtools. uitest. extension. msaa. DLL "require" Microsoft. visual Studio. testtools. uitest. extension. UIA. DLL "require" Microsoft. visual Studio. testtools. uitest. framework. DLL "require" Microsoft. visual Studio. testtools. uitesting. DLL "require" Microsoft. visual Studio. testtools. uitest. playback. DLL "require" Microsoft. visual Studio. testtools. uitesting. DLL "include Microsoft: visualstudio: testtools: uitestinginclude Microsoft: visualstudio: testtools: uitesting: wincontrolsdef window (title) win = winwindow. newwin. searchproperties ["name"] = titlewinenddef button (parent, title) BTN = winbutton. new (parent); BTN. searchproperties ["name"] = titlebtnendplayback. initialize () # note that this sentence must be added. Otherwise, the playback error APP = applicationundertest will be prompted. launch ('C:/Windows/system32/calc.exe ') calc_window = Window ("Calculator") btn_1 = button (calc_window, "1") btn_2 = button (calc_window, "2") btn_add = button (calc_window, "+") btn_equal = button (calc_window, "=") btn_value = winedit. new (calc_window) mouse. click btn_1mouse.click btn_addmouse.click btn_2mouse.click btn_rjputs "1 + 2 = 3: Too high-tech. The computer is right." If btn_value.text.to_ I = 3keyboard. sendkeys ("C"); keyboard. sendkeys ("2"); keyboard. sendkeys ("*"); keyboard. sendkeys ("2"); keyboard. sendkeys (". "); keyboard. sendkeys ("2"); keyboard. sendkeys ("{enter}"); puts "2*2.2 = 4.4: no longer supported, even decimals and multiplication will be" If btn_value.text.to_f = 4.4app.closeplayback.cleanup ()
Run Test Cases

After running, you can see that the Code will open the calculator, and then write the intent and click the button according to the script to output the result.

View the test results under netbeans:

The output in the DOS window is garbled. I wonder who knows how to change the character encoding in this window?

Note:
    1. File in UTF-8 or utf8 without BOM format 
    2. RequiredPlayback. initialize ()
    3. Codeui dll must be referenced completely
Ironruby blog
    • Ironruby-quick learning of basic Ruby knowledge in half an hour
    • Ironruby-file encoding
    • Ironruby-use netbeans to write ironruby code
    • Ironruby-Why is there no good ide ??
    • Ironruby-how to debug ironruby code in vs2010
    • Use codedui of vs2010 to build your own Automated Testing Framework

 

Download the above Code: http://files.cnblogs.com/zhoujg/TestCalc-Ruby.Net4.rar

 

 

Recommended:Online e-books you may need

Agile individual Sina microjournal: http://kan.weibo.com/kan/3483302195814612

 You are welcome to reprint it. Please note: Reprinted fromAgile personal website

 

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.