Download presentation
Presentation is loading. Please wait.
Published byOphelia Rodgers Modified over 9 years ago
1
Test Automation For Web-Based Applications Portnov Computer School Presenter: Ellie Skobel
2
2 Day 5 Selenium IDE User Extensions
3
User-Implemented User-Implemented functionality for Selenium. Done with JavaScript Accomplished by adding methods to the Selenium object prototype, and the PageBot object prototype On startup, Selenium will automatically look through methods on these prototypes, using name patterns to recognize which ones are actions, assertions and locators. 3
4
All methods on the Selenium prototype beginning with “do” are added as actions. ◦ doMouseOver ◦ doTypeAllCaps For each action there is also *AndWait action created automaticly AndWait ◦ doMouseOverAndWait AndWait ◦ doTypeAllCapsAndWait Action method can take up to two parameters, which will be passed values from the second and third columns 4
5
All get* and is* methods on the Selenium prototype are added as accessors ◦ isAllCaps -> boolean ◦ getNumRows -> value All get* and is* methods on the Selenium prototype automatically result in the availability of store*, assert*, assertNot*, verify*, verifyNot*, waitFor*, and waitForNot* commands. 5 Added as: storeAllCaps storeNumRows Added as: storeAllCaps storeNumRows getNumRows => storeNumRows assertNumRows assertNotNumRows verifyNumRows verifyNotNumRows waitForNumRows waitForNotNumRows getNumRows => storeNumRows assertNumRows assertNotNumRows verifyNumRows verifyNotNumRows waitForNumRows waitForNotNumRows
6
Define your own assertions as assert* methods ◦ assertAllCaps Will auto-generate “verify” and “waitFor” commands ◦ verifyAllCaps ◦ waitForAllCaps An assert method can take up to 2 parameters, which will be passed the values of the second and third columns 6
7
1. Create your user extension and save it as filename.js 2. Open Firefox and open Selenium-IDE. 3. Select Options>Options>General tab 4. Next to Selenium Core Extensions input field click on Browse button and find the filename.js file. Click on OK. (Your user-extension will not yet be loaded, you must close and restart Selenium-IDE) 5. In your empty test, create a new command, your user-extension should now be an options in the Commands dropdown. 7
8
Copy the text from the following location: ◦ http://docs.google.com/Doc?id=dm6sk55_37fmpg8tcr http://docs.google.com/Doc?id=dm6sk55_37fmpg8tcr Paste the text into a new file and save it as "goto_sel_ide.js" 8
9
9 Open Firefox Open Selenium IDE Select Options>Options Click Browse and add the goto_sel_ide.js file
10
Restart Selenium IDE! 10 Your user-extension should now be an options in the Commands dropdown
11
Extends Selenium IDE to allows flow control. Consists of following user defined commands: ◦ label ◦ gotolabel ◦ goto ◦ gotoIf ◦ while ◦ endWhile 11 Plus auto-generated commands such as: gotoAndWait, endWhileAndWait, gotoIfAndWait, … Plus auto-generated commands such as: gotoAndWait, endWhileAndWait, gotoIfAndWait, …
12
label – starting point for the goto command gotolabel - performs an unconditional jump Skips any number of rows up or down in the script, to the location of the “label” goto – is the same as gotolabel command 12 Lines skipped
13
label – starting point for the gotoIf command gotoIf – performs a jump if javascript expression evaluated as true Takes 2 parameters: 1.javascript expression 2.label to jump to if javascript expression evaluated as true 13 Lines skipped Lines skipped
14
while – marks the beginning of the while loop. Cycles through all lines of code sandwiched between itself and endWhile command Takes 1 parameter: javascript expression endWhile – marks the end of the while loop 14
15
Copy the following code into Source View of Selenium IDE store 10 x gotolabel target1 getEval alert("This should no appear!"); label target1 store 14 y gotoIf ${y} > ${x} target2 getEval alert("This should not appear either!"); label target2 while storedVars['x']<=storedVars['y'] getEval storedVars['x'] = ${x} +1; echo ${x} endWhile getEval alert("Finished") 15
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.