官术网_书友最值得收藏!

Getting started with the Selenium IDE

Now, let's get our hands dirty! We will be playing with Selenium Interactive Development Environment (Selenium IDE or simply IDE) in this section. IDE is one of the greatest starting points for the Selenium project. It allows someone who has never programmed in his or her life to record a useful test in a matter of minutes and start adding new tests to the test suite in no time.

Installing the Selenium IDE

Selenium IDE is a browser plugin that only works in Firefox browser. It is easy to install and integrates well with the functionality of the browser. Use these easy-to-follow steps to install the IDE in the browser:

  1. In your Firefox browser, navigate to the Selenium website at http://seleniumhq.org:
  2. Click on the Download Selenium link on the home page shown:
  3. In the Selenium IDE section on the Download page, click on the link for the latest released version, as shown here:
  4. Allow Selenium to be installed on your computer by clicking on Allow on the following permission dialog:
  5. The following dialog will show you all of the Selenium IDE components that will be installed on your browser. Click on Install Now when it becomes clickable after several seconds. The installation dialog is shown in the following screenshot:
  6. Restart Firefox.

    Now that the plugins have been installed, you should see a little icon in the browser:

  7. Clicking on that button will reveal the Selenium IDE window, as shown in the following screenshot:

We are now ready to go!

Recording our first test

Just like many commercial testing tools, the Selenium IDE supports the Record-Playback style of writing tests. The IDE monitors your browser and notes down any actions that you perform. By compiling a list of actions, a test slowly emerges. Let's start recording our first test by following these steps:

  1. Open the Selenium IDE in the Firefox browser and make sure the recording mode is on, as shown in following screenshot:

    Note

    Note that the recording indicator is a little difficult to read since it does not change color when on or off. The main difference is a slightly light gray square around the button when it's on. This is one of several major drawbacks of Selenium IDE.

  2. In a new tab, navigate to http://awful-valentine.com, as shown in the following screenshot:
  3. Click on the search text field and type in cheese in the search bar and click on the submit button. The following screenshot shows the search box and the submit button:

    As we are performing these actions, the IDE is recording all of them in the background. We can inspect all of the recorded actions in the IDE window, as shown in the following screenshot:

Let's walk through the table inside the IDE window to get a better understanding of each item.

The table has three columns in it:

  • The first column is Command. This is where the action of the command is defined, such as a click or type.
  • The second column is Target, where the command will be performed.
  • Finally, the third column is Value. This section is only used when the target element, such as a text field, needs some text inserted into it.

We have our simple script now; let's save it so we can reuse it later.

Saving the test

Our next step is to save the test run to a file:

  1. Click on the File option:
  2. Choose Save Test Case.
  3. Name the file search_test.html and save it.

Notice that we saved the test as an HTML file. This is because Selenese, the language that the IDE uses to record and playback tests, is just an HTML table. You can even open the search_test.html file in your web browser and see how it looks! In the following screenshot, we have Selenium IDE and the saved test opens side by side for easy comparison:

Right away, you can see that the IDE (on the left) and the saved Selenese output displayed in a web browser (on the right) look extremely similar.

主站蜘蛛池模板: 蓝田县| 荣成市| 靖安县| 株洲县| 宜良县| 宿松县| 贞丰县| 康平县| 嵊泗县| 宁乡县| 洛阳市| 朝阳市| 内乡县| 大新县| 股票| 右玉县| 东乌珠穆沁旗| 呼伦贝尔市| 小金县| 东乡县| 溧阳市| 双流县| 云霄县| 玛曲县| 蒙自县| 永和县| 莱州市| 祥云县| 南岸区| 巴南区| 洱源县| 新野县| 扶绥县| 政和县| 普兰县| 山东省| 简阳市| 松滋市| 富平县| 万安县| 鄄城县|