Introduction to selenium-selenium RC

Source: Internet
Author: User
Selenium RC is to use programming languages to write scripts and use the selenium RC Server as a proxy server to access applications for testing. because selenium RC no longer needs to attach Firefox, it can be tested in more browsers, this is also an important issue for us to perform Web Testing (solving the important issue of testing due to browser compatibility concerns ). the RC Script is Program Language writing, so it is more flexible and powerful. it supports a wide range of languages. therefore, RC is the most widely used selenium testing tool. at the same time, it also requires a high level of programming for testers. the following describes selenium RC. selenium RC uses two parts: Server and script. the server can be used after download. Remember to open the server when you start running the script. it is a packaged Java program, run Java-jar selenium-server.jar. to use selenium-RC, it is necessary to start this server. Of course, there are some parameters at startup, which can be referred to on its official website. however, for general tests, no additional parameters are required. the other part is the script. it can be written in multiple languages, such as C #, Ruby, and Java. Here I use Java. it can be applied in multiple testing frameworks, such as JUnit/nunit and testng. Here JUnit is used. throughout the test framework, selenium provides encapsulated selenium interfaces and classes. If you use JUnit, Selenium also provides encapsulated test classes. the following is a simple example of nunit-based testing framework using C # To compile and run scripts on Visual Studio 2008 platform. 1> write a test script. first, create a test project. Remember to reference the nunit package and selenium to the project. then create a class to directly inherit the encapsulated selenium test class

The script is as follows: Code
Using System;
Using System. text;
Using Nunit. Framework;
Using Selenium;

NamespaceSeleniumtests
{
[Testfixture]
Public ClassUntitled
{
PrivateIselenium selenium;
PrivateStringbuilder verificationerrors;

[Setup]
Public   Void Setuptest ()
{
Selenium =   New Defaultselenium ( " Localhost " , 4444 , " * Chrome " , " Http://www.google.cn/ " );
Selenium. Start ();
Verificationerrors =   New Stringbuilder ();
}

[Teardown]
Public   Void Teardowntest ()
{
Try
{
Selenium. Stop ();
}
Catch (Exception)
{
// Ignore errors if unable to close the browser
}
Assert. areequal ( "" , Verificationerrors. tostring ());
}

[Test]
Public   Void Theuntitledtest ()
{
Selenium. Open ( " / " );
Selenium. Type ( " Q " , " Selenium ide " );
Selenium. Click ( " Btng " );
Selenium. waitforpagetoload ( " 30000 " );
Try
{
Assert. istrue (selenium. istextpresent ( " Selenium ide " ));
}
Catch (Assertionexception E)
{
Verificationerrors. append (E. Message );
}
Selenium. Click ( " // Div [@ ID = 'res']/Div [1]/ol/Li [1]/H3/A/em " );
}
}
}
The above is a simple example to test the Google website. compiling the script is of course a trial run. first you have to open the selenium server, use the command Java-jar selenium-server.jar-multiwindow to open. here, a parameter-multiwindow is added to separate the browser where the application runs from the browser of the selenium service at runtime. after opening the server, you can run the script. passed should be the last script.
The above is just a very simple example of selenium RC used for testing. To apply selenium RC to testing well, it takes some time to get familiar with it.
Source: http://dupeng0811.cnblogs.com/
The copyright of this article is shared by the author and the blog Park. You are welcome to reprint it. Please visit Article The original text connection is provided at the bottom of the page.

 

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.