Understanding the use of selenium-selenium ide

Source: Internet
Author: User
Tags selenium grid

 

Selenium IDE is one of the selenium test tools. It is a Firefox-based Web testing and development environment that allows you to record, edit, and debug tests. Selenium ide contains selenium core, so you can easily record and play back tests in your browser.
Selenium IDE is not just a test recording tool, but an ide. It can be used for recording testing, manual editing and testing, and breakpoint setting for debugging, you can save the test to other script formats such as HTML, Ruby, C #, and Java, and then use selenium RC to implement and run more flexible and powerful tests.
Selenium IDE is a firfox plug-in, which is quite convenient for recording and works well. Many of them can be played back without modification after recording. editing is also quite simple. One line is a complete command. it is very suitable for testers with a thin programming base. however, because selenese is an HTML-like scripting language rather than a program language, it is not flexible enough to organize scripts, and its functions are not as powerful as selenium RC, and it is not convenient to organize scripts. more importantly, only the Firefox browser is supported. in general, selenium IDE is used to familiarize themselves with selenium functions. then, use ide to record the script as the script file of selenium core, or use ide to record and save it as the drive script, which is a program language script such as a Java Script. however, selenium IDE is a required course for learning selenium, because later recording scripts require it, that is, Using Selenium RC can also use it to record some scripts and facilitate debugging. the following describes the whole use process of selenium ide.
1 > Selenium ide installation. Download and install from its official website: http: // Selenium-ide.openqa.org/, which is the same as installing the common frifox plug-in (note that the Firefox plug-in is not Ie ..). After the installation is complete, the selenium ide tool is visible on the menu bar of the browser "Tools.
2 > Selenium ide recording script. after installation, the recording script is started. open the IDE tool, similar to a small browser (recording status by default), and enter the website you want to record in the base URL, such as www.google.com. then open the Google website in Firefox and enter " Selenium ide " And then click search. Then click the stop recording button of the IDE tool to stop recording. At this time, you will find " Table " There are some command lines, each of which consists of three parts. command: click a command. Target: the target is the command object. If you click a button (indicated by XPath or other positioning methods), value is set here. in " Sourse " You can see a script similar to HTML. Save the script.
3 > Selenium ide editing script. you can modify the table and click the corresponding command line. The row appears below to facilitate modification. For example, select the corresponding command. of course, you can also modify it in sourece, but you must be familiar with the selenium command. now modify the recorded script and change the value of the second command to selenium.
4 > Run the selenium ide script. After modification, click the run button to run it. Run the modified script. You will find it quickly open Google browser and enter " Selenium " Click "Search". The operation is finished.
5 > Selenium ide scripts are saved. html scripts or other language scripts can be saved during saving. For more information, see save as HTML scripts.
6 > Open the seleniumide script and run it. This is very simple.
At this point, the whole process of recording and modifying selenium IDE is completed. You can easily use selenium ide to record and run the script. however, it still takes time to get familiar with the test. If there are any commands, how to locate them, and how to use assert to verify the verification points, this is also the three main learning points of selenium testing. if you are familiar with all the three accounts, congratulations, you can use selenium for testing.
It is not complex to use selenium IDE, but to get familiar with it and use it for testing. as mentioned above, only selenium ide has too many limitations for testing. Therefore, we recommend that you use selenium ide to learn about and familiarize yourself with the selenium tool, and then use its recording script and other selenium tools for testing, such as selenium core, selenium RC, selenium grid. we recommend that you use selenium RC. of course, it doesn't mean that others are not good. Others have their own advantages or functions that RC does not possess. in terms of learning and using, we should first learn selenium IDE and then switch to selenium RC. so next we will introduce selenium RC.

 

 

The following is a reference to selenium IDE, which is used in selenium IDE.

Selenium IDE is a Firefox plug-in that can be used for script recording and case conversion, therefore, selenium ide + firebug will become your two assistants for writing test cases in the future (selenium Core + iedevelpertoolbar can be used in IE ).

Selenium ide download: http://seleniumhq.org/download/

Firebug download: https://addons.mozilla.org/firefox/addon/1843

The following describes the use of selenium.:

1. Install selenium IDE and firebug.

2. Start selenium ide:

 

After IDE is started, the following dialog box is displayed:


Selenium
Main functions of IDE. A table composed of command, target, and value is a script. Each script is composed of one action, and each
Action is composed of (command, target, value. Command refers to the content mentioned in the API reference manual. Target refers to an object in the Web, such as text, input box, etc. What if an object is selected? The XPath is used here. If you are not familiar with it, refer to "use of xpath", and "value" is the value of this object.

3. Recording and running scripts


When the above ide window pops up, we can start recording selenium scripts. There is a red dot in the upper right corner. When it is recorded on time (for example), it indicates that IDE is recording scripts.
OK, start recording. When recording, you can directly operate the Firefox browser window. Ide will automatically record your operations. The following is an example:




In this example, the procedure is as follows:

(1). Enter: http://www.baidu.com/in the address bar/

(2) After logging on to the Baidu homepage, enter "hyddd" in the query box ".

(3). Click "Baidu ".

(4). On the search result page, right-click the first record (I .e., hyddd-blog Garden), right-click the menu, and click Verify testpersent hyddd-blog garden ".

(5) Click the first record (that is, enter the hyddd-blog Park)

(6). A new tab page pops up in Firefox and enters my blog.

OK. Now let's take a look at our selenium ide recording results:>



The middle table is the recording result. You can press "run script" to replay the script again. It is worth noting that at runtime, firefox may consider the last operation in the script (I .e:
Step 6) if the pop-up box is invalid, the browser will automatically block the pop-up. You need to set Firefox to its specific location.
Yes: Firefox-> menubar-> Tools-> options-> content-> Block
Pop-up window, you can remove the hook or add the corresponding URL in the exceptions.

So far, script recording has been completed successfully:>


After running the script, you will find that the color of the IDE table has changed. Before running, the script table is white. After running, the table is blue, it can also be divided into deep blue and light blue, which indicates:
The action succeeds, for example, opening the webpage successfully, clicking the button successfully, and so on. The deep blue color indicates that the judgment is correct, for example, the text "hyddd-blog Garden" exists on the page.

After reading the correct information, let's take a look at the error.


When an error occurs, the table may appear in two colors: Light pink and dark pink. The light pink red indicates that the judgment result is false. In this case, the execution will continue, and the failure will not affect the operation of the case. The dark pink indicates that the action fails, for example: no buttons are found (for example). In this case, the running will stop.

4. Other important functions of selenium ide

As mentioned at the beginning of this article, selenium ide also has an important function of converting scripts. Let's take a look at it:>


Selenium IDE can convert HTML scripts to scripts in C #, Java, and other languages, which provides great convenience for us to write selenium RC test cases in the future.

Original address http://www.cnblogs.com/hyddd/archive/2009/05/24/1487967.html


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.