Web Browser Scripting
Upcoming SlideShare
Loading in...5
×

Like this? Share it with your network

Share

Web Browser Scripting

  • 7,141 views
Uploaded 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......

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.

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
7,141
On Slideshare
7,136
From Embeds
5
Number of Embeds
1

Actions

Shares
Downloads
43
Comments
0
Likes
0

Embeds 5

http://www.slideshare.net 5

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Automated Web Testing Command-Line & Scripting Interface
  • 2. Command Line Interface
    • Typical uses:
    • Use macro with batch file
    • Integrate with Windows task scheduler
    • Integrate with thousands of other software packages
    • Commands:
    • Start the macro: -macro <macroname>
    • Send values to macro: -var_myvar <x>
    • Repeat macro: -loop <x>
    • Keep IM Browser open: -noexit
    • Run in background: -tray / -silent
    • Example: –macro test –var_myvar Hello[SP]World
  • 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. Example Batch File
    • &quot;C:IIMimacros.exe&quot; -macro Demo-FillForm -loop 3
    • if %errorlevel% == 1 goto ok
    • if NOT %errorlevel% == 1 goto error
    • :ok
    • echo Macro completed succesfully!
    • goto end
    • :error
    • echo Error encountered during replay.
    • echo Errorcode=%errorlevel%
    • :end
    • The batch variable %errorlevel% is set by &quot;imacros.exe&quot; upon exit
  • 5. Demo Project
    • Set up a test macro that runs once a day and saves the CNN.com home page to a file:
    The task scheduler can be accessed via the Windows Control Panel
  • 6. Scripting Interface
    • Why use the Scripting Interface?
    • Works with any Windows Scripting or programming language
    • Simple but powerful set of commands
    • Detailed error handling
    • Windows OS includes Windows Scripting Host (WSH)
    • Easy database access
  • 7. The six most important commands:
    • set iim1= CreateObject (“iMacros&quot;)
    • i = iim1. iimInit (“”)
    • i = iim1. iimDisplay (&quot;This is a test&quot;)
    • i = iim1. iimSet (&quot;-var_name1&quot;, &quot;Tom Tester&quot;)
    • i = iim1. iimPlay (“Test1&quot;)
    • If i > 0 Then s = &quot;Everything OK”
    • Else s = iim1. iimGetLastError ()
    • MsgBox s
    • i = iim1. iimExit
  • 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. 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. Demo Projects
    • Performance Monitoring
      • Create response time measurement macro, and return the data to your script for further processing. Use {{!STOPWATCHTIME}} to return the measured time.
      • Use a script to alert you when response time is above threshold
    • Create Google News Extractor:
      • Submit keyword search to Google News
      • Extract headlines from returned search results
      • Store headlines in text file
      • Click NEXT link until all results are extracted