RUN Test Case Reuse - Selenium IDE
run (macro name) - Selenium IDE command
Through the use of the run (macro) command, you can re-use one macro (test case) inside of another. For example, this allows you to re-use a "Login Macro" as building bloc in multiple other macros.
Demo: In the Kantu demo macros the DemoCsvReadWithLoop and DemoCsvReadWithWhile macros both use run to call Sub_DemoCsvRead_FillForm. This subroutine is responsible for the form filling part, which is the same in both demo macros.
Another demo can be found in DemoXDesktopAutomation and DemoXDesktopAutomation_OCR. These macros both call Sub_XDesktopAutomation_Area. This subroutine is responsible for limiting the vision search area.
How is the subroutine related the main program?
- - Variables are visible in the subroutine. (Do not confuse this with global variables, which are even visible between macros.)
- - If the value of a variable is changed in the subroutine, it changes the value in the main macro, too ("Call by reference").
- - For internal variables the same rules as for variables apply. Once exception: !macroname is always the macro name of the main macro.
- - !runtime is the overall runtime (main program and subroutine runtime is counted together)
- - VisionLimitSearchArea restrictions are handled just as internal variables
RUN command with macros in folders
RUN supports macros in folders. It understands absolute and relative paths:
- - RUN | /reuse/logins/gmail/user1 => Path from root folder (top folder)
- - RUN | gmail/user1 (no / at the start!) => Relative path from current folder of the macro
The example below is very basic. Best if you see the RUN command in action by running the DemoCsvReadWithWhile macro that installs with the IDE. DemoCsvReadWithWhile uses RUN to call the form filling subroutine inside a WHILE loop. In the log file this is indicated by the line "[status] Running 'Sub_DemoCsvRead_FillForm', called by 'DemoCsvReadWithLoop'".
|echo||Now we are logged in!|
Related Demo Macros
DemoCsvReadWithWhile, DemoCsvReadWithLoop, DemoXDesktopAutomation, DemoXDesktopAutomation_OCR (these macros all use RUN)
The ready-to-import-and-run source code of all demo macros can be found in the Github repository testmacros folder.
Anything wrong or missing on this page? Suggestions?
...then please contact us.