12
返回列表 发新帖
楼主: AlexQin

Tutorial #3 – My first Selenium IDE script

[复制链接]
论坛徽章:
1056
紫蜘蛛
日期:2015-09-22 15:53:22紫蜘蛛
日期:2015-10-15 13:48:52紫蜘蛛
日期:2015-10-15 14:45:48紫蜘蛛
日期:2015-10-15 14:47:47紫蜘蛛
日期:2015-10-15 14:48:45九尾狐狸
日期:2015-09-22 15:53:22九尾狐狸
日期:2015-10-15 13:50:37九尾狐狸
日期:2015-10-15 14:45:48九尾狐狸
日期:2015-10-15 14:47:47九尾狐狸
日期:2015-10-15 14:48:45
11#
 楼主| 发表于 2017-5-30 17:16 | 只看该作者
Using Other Formats
Converting Selenium IDE test scripts to Other Programming Languages
Selenium IDE supports conversion test scripts into set of programming languages from a default type (HTML). The converted test scripts cannot be played back using Selenium IDE until and unless it is reverted back to HTML. Thus the conversion is beneficial and constructive only when we are executing it from other tools of Selenium Suite.
Step 1 – Click on the options tab under the menu bar and select the programming language format under format option in order to convert the test script into our desired format.
Step 2 – As soon as we select our Desired Programming language format (“Java / JUnit4 / WebDriver” in our case), a prompt box appears which says “Changing format is now marked experimental! If you continue, recording and playback may not work, your changes may be lost and you may have to copy and paste the test in a text editor to save. It is better to make a copy of your test cases before you continue. Do you still want to proceed?” Click “OK” to continue.
Thus, the above converted code can be executed by using WebDriver.
Mark that editing or modifying Selenium IDE test scripts from Source View is not advisable. If done so, the tool might introduce several repercussions. Several known bugs are already associated with it.

使用道具 举报

回复
论坛徽章:
1056
紫蜘蛛
日期:2015-09-22 15:53:22紫蜘蛛
日期:2015-10-15 13:48:52紫蜘蛛
日期:2015-10-15 14:45:48紫蜘蛛
日期:2015-10-15 14:47:47紫蜘蛛
日期:2015-10-15 14:48:45九尾狐狸
日期:2015-09-22 15:53:22九尾狐狸
日期:2015-10-15 13:50:37九尾狐狸
日期:2015-10-15 14:45:48九尾狐狸
日期:2015-10-15 14:47:47九尾狐狸
日期:2015-10-15 14:48:45
12#
 楼主| 发表于 2017-5-30 17:17 | 只看该作者
Selenium IDE Commands
Each Selenium IDE test step can chiefly be split into following three components:
  • Command
  • Target
  • Value

Types of Selenium IDE commands
There are three flavors of Selenium IDE commands. Each of the test step in Selenium IDE falls under any of the following category.
  • Actions
  • Accessors
  • Assertions

Actions
Actions are those commands which interact directly with the application by either altering its state or by pouring some test data.
For Example, “type” command lets the user to interact directly with the web elements like text box. It allows them to enter a specific value in the text box and as when the value is entered; it is showed on the UI as well.
Another example is “click” command. “click” command lets the user to manipulate with the state of the application.
In case of failure of an action type command, the test script execution halts and rest of the test steps would not be executed.
Accessors
Accessors are those commands which allows user to store certain values to a user defined variable. These stored values can be later on used to create assertions and verifications.
For example, “storeAllLinks” reads and stores all the hyperlinks available within a web page into a user defined variable. Remember the variable is of array type if there are multiple values to store.
Assertions
Assertions are very similar to Accessors as they do not interact with the application directly. Assertions are used to verify the current state of the application with an expected state.
Forms of Assertions:
#1. assert – the “assert” command makes sure that the test execution is terminated in case of failure.
#2. verify – the “verify” command lets the Selenium IDE to carry on with the test script execution even if the verification is failed.
#3. waitFor – the “waitFor” command waits for a certain condition to be met before executing the next test step. The conditions are like page to be loaded, element to be present. It allows the test execution to proceed even if the condition is not met within the stipulated waiting period.
Commonly used Selenium IDE commands
[td]
Command
Description
#Argu
ments
open
Opens a specified URL in the browser.
1
assertTitle, VerifyTitle
Returns the current page title and compares it with the specified title
1
assertElementPresent, verifyElementPresent
Verify / Asserts the presence of an element on a web page.
1
assertTextPresent, verifyTextPresent
Verify / Asserts the presence of a text within the web page.
1
type, typeKeys,
sendKeys
Enters a value (String) in the specified web element.
2
Click, clickAt,
clickAndWait
Clicks on a specified web element within a web page.
1
waitForPageToLoad
Sleeps the execution and waits until the page is loaded completely.
1
waitForElement
Present
Sleeps the execution and waits until the specified element is present
1
chooseOkOnNext
Confirmation,
chooseCancelOn
NextConfirmation
Click on ”OK” or “Cancel” button when next confirmation box appears.
0

使用道具 举报

回复
论坛徽章:
1056
紫蜘蛛
日期:2015-09-22 15:53:22紫蜘蛛
日期:2015-10-15 13:48:52紫蜘蛛
日期:2015-10-15 14:45:48紫蜘蛛
日期:2015-10-15 14:47:47紫蜘蛛
日期:2015-10-15 14:48:45九尾狐狸
日期:2015-09-22 15:53:22九尾狐狸
日期:2015-10-15 13:50:37九尾狐狸
日期:2015-10-15 14:45:48九尾狐狸
日期:2015-10-15 14:47:47九尾狐狸
日期:2015-10-15 14:48:45
13#
 楼主| 发表于 2017-5-30 17:18 | 只看该作者
Conclusion
In this tutorial, we tried to make you acquainted with the creation of Selenium IDE scripts. We also briefed you about the usage of various Selenium features.
Here are the cruxes of this article.
  • Test script in Selenium IDE can be created using Record and Playback feature.
  • The script creation mechanism can be divided into 3 processes – Recording, Playing back and Saving the test script.
  • Selenium IDE allows the user to execute a single test step within the test script without executing the entire test script. “Execute this command” is the option which makes this obtainable.
  • User is leveraged to set the execution speed from the option within the toolbar.
  • User can define any test step as a Start point. Thus, the execution will always initiate from that particular test step only.
  • User can set multiple Break points to pause the execution at a certain test step.
  • User can find and verify if the provided target value corresponds to the correct web element within the web page using Find
  • Changing the source view to other formats is not recommended as there is a probability of loss of data.
  • Remember to keep a copy of HTML test script before converting the test script into other non HTML formats.
  • There are majorly three types of commands – Actions, Accessors and Assertions.
  • Actions directly interact with the application and alter its state.
  • Accessors are used to store an elements property in a user defined variable.
  • Assertions are used to check if a specified condition is met or not.
  • Assertions can further be categorized as verify, assert and waitFor commands.
  • Verify makes sure that the test script execution is never halted if even if the verification fails.
  • Assert lets no further execution of the test script in case of failure.
  • WaitFor waits for a stipulated period for a certain condition to meet.
  • Some of the Selenium IDE commands which are used commonly are:
    • open
    • assertTitle / VerifyTitle
    • AssertForElementPresent / VerifyForElementPresent
    • AssertForTextPresent / VerifyForTextPresent
    • type / typeAndWait / sendKeys
    • click /clickAt / clickAndWait
    • waitForPageToLoad
    • waitForElementPresent
    • chooseOkOnNextConfirmation / chooseCancelOnNextConfirmation



使用道具 举报

回复
论坛徽章:
1056
紫蜘蛛
日期:2015-09-22 15:53:22紫蜘蛛
日期:2015-10-15 13:48:52紫蜘蛛
日期:2015-10-15 14:45:48紫蜘蛛
日期:2015-10-15 14:47:47紫蜘蛛
日期:2015-10-15 14:48:45九尾狐狸
日期:2015-09-22 15:53:22九尾狐狸
日期:2015-10-15 13:50:37九尾狐狸
日期:2015-10-15 14:45:48九尾狐狸
日期:2015-10-15 14:47:47九尾狐狸
日期:2015-10-15 14:48:45
14#
 楼主| 发表于 2017-5-30 17:18 | 只看该作者
Next Tutorial #4: There is another tool which plays a very important role in assisting us to create effective test scripts known as “Firebug”. Firebug helps us in inspecting the properties of web elements and web pages. Thus the next tutorial is comprised of installation of Firebug and its usability. We would also create a test script manually using firebug and Selenium IDE.
Note: Do not miss the next tutorial because of its great importance with respect to our forthcoming tutorials on WebDriver.

使用道具 举报

回复
论坛徽章:
1056
紫蜘蛛
日期:2015-09-22 15:53:22紫蜘蛛
日期:2015-10-15 13:48:52紫蜘蛛
日期:2015-10-15 14:45:48紫蜘蛛
日期:2015-10-15 14:47:47紫蜘蛛
日期:2015-10-15 14:48:45九尾狐狸
日期:2015-09-22 15:53:22九尾狐狸
日期:2015-10-15 13:50:37九尾狐狸
日期:2015-10-15 14:45:48九尾狐狸
日期:2015-10-15 14:47:47九尾狐狸
日期:2015-10-15 14:48:45
15#
 楼主| 发表于 2017-5-30 17:19 | 只看该作者

使用道具 举报

回复
论坛徽章:
1056
紫蜘蛛
日期:2015-09-22 15:53:22紫蜘蛛
日期:2015-10-15 13:48:52紫蜘蛛
日期:2015-10-15 14:45:48紫蜘蛛
日期:2015-10-15 14:47:47紫蜘蛛
日期:2015-10-15 14:48:45九尾狐狸
日期:2015-09-22 15:53:22九尾狐狸
日期:2015-10-15 13:50:37九尾狐狸
日期:2015-10-15 14:45:48九尾狐狸
日期:2015-10-15 14:47:47九尾狐狸
日期:2015-10-15 14:48:45
16#
 楼主| 发表于 2017-6-3 22:45 来自手机 | 只看该作者
good job

使用道具 举报

回复

您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

TOP技术积分榜 社区积分榜 徽章 团队 统计 知识索引树 积分竞拍 文本模式 帮助
  ITPUB首页 | ITPUB论坛 | 数据库技术 | 企业信息化 | 开发技术 | 微软技术 | 软件工程与项目管理 | IBM技术园地 | 行业纵向讨论 | IT招聘 | IT文档
  ChinaUnix | ChinaUnix博客 | ChinaUnix论坛
CopyRight 1999-2011 itpub.net All Right Reserved. 北京盛拓优讯信息技术有限公司版权所有 联系我们 未成年人举报专区 
京ICP备16024965号-8  北京市公安局海淀分局网监中心备案编号:11010802021510 广播电视节目制作经营许可证:编号(京)字第1149号
  
快速回复 返回顶部 返回列表