Selenium IDE(转)

上一篇 / 下一篇  2007-11-12 13:46:47

The IDE used to record scrīpts is currently only available in Firefox.

1.1 Installing the IDE

 

The Selenium IDE is an extension that needs to be installed before use.

To install the IDE follow the steps outlined below:

Step 1:Launch Firefox.

 

 

 

 

 

 

 

 

 

 

 


Step 2:Drag and drop the Selenium IDE xpi file into the browser window

Step 3:Wait until theInstall Nowbutton is activated on theSoftware Installationdialog that appears

Step 4:ClickInstall Now. The extension will be installed by the browser

Step 5:In order to activate the extension, you need to restart Firefox

 

The Selenium IDE should now be installed


1.2 Starting the IDE

 

By clicking Tools => Selenium IDE.

This will start the IDE in a new window.

1.3 AQuick Overview of the Selenium IDE

 

The main features of the IDE are outlined below:

a.     Base URL

The base URL is the starting point for your scrīpts.

 

b.     Record & Player Toolbar

Allows you toplay,pause andrecord scrīpts. You can also step through a scrīpt one command at a time using the Step button.

 

c.     Mode Selection Bar

Three modes are available and control the speed at which the scrīpt is played back.

 

d.     Command Window

Hold a list of commands that have been recorded or are to be played back.

 

1.4 Recording a scrīpt

 

Recording a new scrīpt using the IDE is fairly straight forward.

The basic steps involved when recording a scrīpt are:

1.      Start the IDE

2.      Make sure the record button is activated

3.      Enter the web site address into the web browser

4.      Perform required tasks

5.      Stop scrīpt

6.      Playback

 

A Newly Recorded Selenium scrīpt

 

 

1.5 Saving Your scrīpts

 

You can save your scrīpt by going to File => Save Test in the menu bar or by pressing CTRL + S.

 

1.6 Breakpoints

 

Breakpoints are points in your scrīpt where execution will stop. You will need to manually restart the test in order to continue. Breakpoints are helpful when debugging scrīpts and when writing complex scrīpts that require a lot of attention to detail.

To set a breakpoint, you can do one of two things:

One:

·   Select the command on which you like to set the breakpoint

·   Right click and select Toggle Breakpoint

Two:

·   Select the command on which you like to set the breakpoint

·   Press B to set the breakpoint

 

To remove a breakpoint, simply repeat the process used to set the breakpoint. With breakpoints set in your scrīpt, you will need to manually step over these points using either thepause/resumebutton or thestepbutton. Both are located on the Record & Playback Toolbar.

 

1.7 Using Variables

 

Variables can be set for use within your scrīpts. You would normally declare your variable list at the beginning of your scrīpt to allow them to be used everywhere throughout the scrīpt. Variables need to follow a basic format.

 

Variable Examples:

store

tasec

siteURL

store

wbxadmin

siteAdmin

store

pass

sa_password

 

Thestorecommand notifies Selenium that you intend to declare a variable for use within your scrīpt. The next item is the value that will be stored in the variable. The final item is the name you wish to give the variable. All variables must follow this format in order to be declared correctly.

 

You can then access the variables above using the following values within your scrīpt:

${siteURL}

${siteAdmin}

${sa_password}

 

1.8 Set Assertions

We need to set assertions in the scrīpts to check current status. There are two modules: Assert and Verify. When Assert fails, it will exit the test. When Verify fails, test will be continued.


TAG:

 

评分:0

我来说两句

Open Toolbar