Web Browser Scripting


Published on

The Scripting Interface of the iMacros Scripting Edition is designed as COM object and allows the user to remote control (script) the iMacros Browser, Internet Explorer and Firefox web browser from any Windows programming or scripting language.

Published in: Technology
  • Be the first to comment

  • Be the first to like this

No Downloads
Total Views
On Slideshare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide
  • Web Browser Scripting

    1. 1. Automated Web Testing Command-Line & Scripting Interface
    2. 2. Command Line Interface <ul><li>Typical uses: </li></ul><ul><li>Use macro with batch file </li></ul><ul><li>Integrate with Windows task scheduler </li></ul><ul><li>Integrate with thousands of other software packages </li></ul><ul><li>Commands: </li></ul><ul><li>Start the macro: -macro <macroname> </li></ul><ul><li>Send values to macro: -var_myvar <x> </li></ul><ul><li>Repeat macro: -loop <x> </li></ul><ul><li>Keep IM Browser open: -noexit </li></ul><ul><li>Run in background: -tray / -silent </li></ul><ul><li>Example: –macro test –var_myvar Hello[SP]World </li></ul>
    3. 3. Command Line Interface (cont’d) Take values from the command line: CMDLINE !VAR1 http://www.iOpus.com/iim Check on the return value: The Internet Macros executable &quot;imacros.exe&quot; set the predefined batch file variable &quot; %ERRORLEVEL% &quot;. The value is either 1 if the macro was completed successfully or negative if an error was encountered.
    4. 4. Example Batch File <ul><li>&quot;C:IIMimacros.exe&quot; -macro Demo-FillForm -loop 3 </li></ul><ul><li>if %errorlevel% == 1 goto ok </li></ul><ul><li>if NOT %errorlevel% == 1 goto error </li></ul><ul><li>:ok </li></ul><ul><li>echo Macro completed succesfully! </li></ul><ul><li>goto end </li></ul><ul><li>:error </li></ul><ul><li>echo Error encountered during replay. </li></ul><ul><li>echo Errorcode=%errorlevel% </li></ul><ul><li>:end </li></ul><ul><li>The batch variable %errorlevel% is set by &quot;imacros.exe&quot; upon exit </li></ul>
    5. 5. Demo Project <ul><li>Set up a test macro that runs once a day and saves the CNN.com home page to a file: </li></ul>The task scheduler can be accessed via the Windows Control Panel
    6. 6. Scripting Interface <ul><li>Why use the Scripting Interface? </li></ul><ul><li>Works with any Windows Scripting or programming language </li></ul><ul><li>Simple but powerful set of commands </li></ul><ul><li>Detailed error handling </li></ul><ul><li>Windows OS includes Windows Scripting Host (WSH) </li></ul><ul><li>Easy database access </li></ul>
    7. 7. The six most important commands: <ul><li>set iim1= CreateObject (“iMacros&quot;) </li></ul><ul><li>i = iim1. iimInit (“”) </li></ul><ul><li>i = iim1. iimDisplay (&quot;This is a test&quot;) </li></ul><ul><li>i = iim1. iimSet (&quot;-var_name1&quot;, &quot;Tom Tester&quot;) </li></ul><ul><li>i = iim1. iimPlay (“Test1&quot;) </li></ul><ul><li>If i > 0 Then s = &quot;Everything OK” </li></ul><ul><li>Else s = iim1. iimGetLastError () </li></ul><ul><li>MsgBox s </li></ul><ul><li>i = iim1. iimExit </li></ul>
    8. 8. Error Return Codes All functions return a value > 0 if they succeed, and an error code < 0 in case of problems. Error codes below -100 are error codes generated during the macro replay. Same code as when macro is run manually. -1 Macro timeout (Macro takes too long to run) -2 IIM Interface timeout (IM browser does not respond) -3 User pressed STOP button -4 Communication error (should not happen) -5 Browser closed (User pressed EXIT button)
    9. 9. VB6 with Intellisense Support In order to enable Intellisense support, you need to add the „IInternetMacros“ component to your project („Early binding“). The alternative is to use CreateObject („Late Binding“, no Intellisense support) Intellisense in action… Add iMacros COM object
    10. 10. Demo Projects <ul><li>Performance Monitoring </li></ul><ul><ul><li>Create response time measurement macro, and return the data to your script for further processing. Use {{!STOPWATCHTIME}} to return the measured time. </li></ul></ul><ul><ul><li>Use a script to alert you when response time is above threshold </li></ul></ul><ul><li>Create Google News Extractor: </li></ul><ul><ul><li>Submit keyword search to Google News </li></ul></ul><ul><ul><li>Extract headlines from returned search results </li></ul></ul><ul><ul><li>Store headlines in text file </li></ul></ul><ul><ul><li>Click NEXT link until all results are extracted </li></ul></ul>
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.