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

Understanding Selenium commands

In this section, we will walk through the saved test from the IDE, which is written in a language called Selenese. We will then compare the Selenese commands to the commands written in a real programming language.

Note

The code and the step-by-step instructions on how to test it on Windows and other operating systems can be found at https://github.com/dimacus/SeleniumBestPracticesBook.

Reading Selenese

If you ever see the HTML source code of any web page, Selenese will not be a new concept for you. Selenese can simply be described as an HTML table with a table row as a test command. Let's take a closer look at it. Open the search_test.html file in your editor of choice. The whole test should look like this:

We will ignore the first five lines of the code, as it has no practical application for us at this point. On line 6, you will find the following code:

The preceding line declares the base domain URL for our tests.

Note

One of the biggest weaknesses in Selenium 1 (RC) is that it was written in JavaScript, which exposes security issues with third-party domains running arbitrary JavaScript code on any website. The security experts implemented strict rules to prevent Cross-Site Scripting (XSS). Thus, Selenium IDE and RC will not be able to test multiple websites in a single test run.

Our next section of interest is the code on lines 14 to 18, where a single table row (tr) contains our first command in three table data (td) sections. Test lines 14 to 18 are shown here:

The first TD matches the Command column in the IDE, and in this case the command is to open a given URL.

The second TD matches the Target column in the IDE and is telling the test to open the root of the base URL from line 6.

Tip

You can tweak your test here by adding a direct link to a page you want, such as /index.html or /register. This will allow you to go directly to the page you wish to test.

主站蜘蛛池模板: 中卫市| 喀什市| 铁岭县| 湖口县| 舞钢市| 明光市| 开鲁县| 高雄市| 万山特区| 柳州市| 中牟县| 古交市| 平乐县| 沐川县| 英超| 莱芜市| 青铜峡市| 永泰县| 巴青县| 奈曼旗| 调兵山市| 南溪县| 本溪市| 安义县| 广州市| 什邡市| 平利县| 大同县| 山丹县| 乌苏市| 墨竹工卡县| 陈巴尔虎旗| 南昌县| 广宗县| 深州市| 平泉县| 报价| 和林格尔县| 兴安盟| 毕节市| 遂川县|