Selenium Tutorial [教程]

上传人:jiups****uk12 文档编号:46001505 上传时间:2018-06-20 格式:PPT 页数:36 大小:683KB
返回 下载 相关 举报
Selenium Tutorial [教程]_第1页
第1页 / 共36页
Selenium Tutorial [教程]_第2页
第2页 / 共36页
Selenium Tutorial [教程]_第3页
第3页 / 共36页
Selenium Tutorial [教程]_第4页
第4页 / 共36页
Selenium Tutorial [教程]_第5页
第5页 / 共36页
点击查看更多>>
资源描述

《Selenium Tutorial [教程]》由会员分享,可在线阅读,更多相关《Selenium Tutorial [教程](36页珍藏版)》请在金锄头文库上搜索。

1、Selenium Web Test Tool TrainingDiscover the automating power of SeleniumPortnov Computer School presents:Presented by: Kangeyan Passoubady (Kangs)Copy Right: 2008, All rights reserved by Kangeyan Passoubady (Kangs). Republishing requires authors permission1Discover the automating power of SeleniumLe

2、ssonSelenese Commands32Discover the automating power of SeleniumVariable Substitution#1 You can store any value into a variable using selenium accessors. Variable substitution provides a simple way to include a previously stored variable in a command parameter If you give the variable name as intAmo

3、unt. To use the variable anywhere else use $intAmount. This will substitute the actual value in the place of $intAmount. Use echo $intAmount to display the values in the Log. Any of the selenium accessors can be used to store a value. Some of the key accessors are storeText, storeValue, storeCookie,

4、 storeAlert and storeEval3Discover the automating power of SeleniumVariable Substitution#31. Open the HelloWorld.html in Firefox2. Create a test case by opening FirefoxToolsSelenium IDE (by default it is in Recording mode)3. Update the base URL of Selenium IDE with the URL in the Firefox address4. C

5、lick on the link “Click here to enter your name”, when prompter for your name, enter your name.5. Your name will be displayed in next line.6. Highlight your name Right click and select the assertText, then Stop the recording in Selenium IDE.7. Rerun the test case in Selenium IDE4Discover the automat

6、ing power of SeleniumVariable Substitution#41. Your test case will look like in Selenium IDE as shown in the figure right side2. Try to run multiple time and make sure your test case is passed without any failures.3. Now save the test case as “Recorded_TestCase_HelloWorld.html”4. Double click and op

7、en the “Recorded_TestCase_HelloWorld.html” either in IE or Firefox.5. You can see all the commands in an HTML table.Your answerOnNextPrompt should be before than the click command. Make sure it precedes otherwise your test case will fail.5Discover the automating power of SeleniumVariable Substitutio

8、n#5 Now well try to do the same exercise using variable substitution In the Selenium IDE, select “answerOnNextPrompt”, Right Click and Select a new command Select the command “store” Target “Kangeyan” Value “vName” Store | Kangeyan | vName Underneath insert a new command and provide the below values

9、 echo | $vName Right click and copy the “echo” command, and paste before the assertText command line6Discover the automating power of SeleniumVariable Substitution #6Your recorded test case will look something similar to this oneChange something similar to this oneSee how the $vName is used in multi

10、ple places7Discover the automating power of SeleniumVariable Substitution #7echo shows the variable values in the Logecho prints the variable values in the third column of the command in Test RunnerSee the usage of $vName in answerOnNextPrompt and assertText8Discover the automating power of Selenium

11、storedVars#1 All the variables are internally stored in a map named “storedVars”. storedVars allows you to access the $varName using the “varName” key within the map. Using storedVars you can reference the values within Javascript Evaluation code. What is a Map? Maps provide a more general way of st

12、oring elements. An object that maps keys to values. A map cannot contain duplicate keys (duplicate variable names); The Map collection type allows to store pairs of elements, termed “keys“ and “values“, where each key maps to one value. Here Keys refers Selenium variable Names and values refers to t

13、heir values.9Discover the automating power of SeleniumstoredVars#2 Open URL: http:/ Type username: Type password: Press Sign In button AssertTextPresent Press SignOut waitForTextNotPresent 10Discover the automating power of SeleniumstoredVars#3Your recorded test case will look something similar to t

14、his oneChange something similar to this oneSee how the storedVars is used in multiple places11Discover the automating power of SeleniumJavaScript Evaluation#1 JavaScript evaluation allows full power of JavaScript code in constructing the Command Parameter JavaScript snippet can be given using the fo

15、llowing syntax. Javascript Javascript keyword is optional The code given is treated as a JavaScript code and executed. storedVars Map can be used to access the previously stored variables Variable substitution should be handled carefully within the JavaScript code.12Discover the automating power of SeleniumJavaScript Evaluation#2 You can use any of the following Eval commands assertEval, assertNotEval, VerifyEval, verifyNotEval, waitForEval, waitForNotEval, storeEval You can use any of the following Expression commands assertExpression, assertNotExpression,verifyExpression, verifyNotExpres

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 行业资料 > 其它行业文档

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号