• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Advanced Web Browser Automation
 

Advanced Web Browser Automation

on

  • 4,835 views

Advanced Web Browser Automation

Advanced Web Browser Automation

Statistics

Views

Total Views
4,835
Views on SlideShare
4,832
Embed Views
3

Actions

Likes
0
Downloads
55
Comments
0

1 Embed 3

http://www.slideshare.net 3

Accessibility

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Advanced Web Browser Automation Advanced Web Browser Automation Presentation Transcript

  • Advanced Commands
  • Advanced Commands
    • After visually recording the main parts of the macro, enhance and fine-tune the macro by editing it.
    • All macros are simple text files
    • File structure and commands fully documented
  • Macro in a Notepad File:
    • The recorded macro is stored in an easy to read text file (file ending: ".iim") which can be easily edited.
    • To edit a macro go to edit tab present on the left hand side of the browser, next to play and record and press edit macro button.
    • The default editor for editing Internet Macros is "Windows Notepad" (notepad.exe).
    • You can use another editor by changing the default editor in EDIT tab > click OPTIONS > PATHS tab.
    • If the macro has the name “mymacro", the corresponding text file is called “mymacro.iim".
    Editing Macros:
  • Editing Macros Screenshot:
  • TOP 5 reasons to edit a macro
    • Edit typos made during recording
    • Insert Variables
    • Insert tags for response time measurements
    • Replace Session IDs with “*”
    • Copy & Paste several macros together or split macros in parts.
    • The link of some web sites change each time you visit them. This is because they create links with a "session id" which is different each time you log in.
    • Solution 1: Try a different ClickMode
    • Solution 2: Edit the macro manually after you recorded it and replace the ID (or any other changing part of the string) with "*".
    • Example: The command line:
      • TAG POS=1 TYPE=AREA
      • ATTR=HREF: https://overture.com/s/index.jhtml;$sessionid$tzut78ZUZTIU67$&%
    • can be written as:
    • TAG POS=1 TYPE=AREA ATTR=HREF: *index.jhtml*
    Session IDs
    • Built-in variables
      • These variables are used to define certain properties of the macro behavior
      • For example the macro timeout value SET !TIMEOUT 33.
    • User-defined Variables
      • These variables are created at run time by the command line &quot;-var_MYVAR <value>&quot;.
      • For Example -var_ITEM 15 creates the variable {{ITEM}} and gives it the value 15.
      • These variables can be part of ANYTHING inside the macro.
      • In addition to routine tasks of opening and saving web pages, macros can be used for more complicated tasks. For example, extracting data from one website and inserting it into another.
    Two kinds of Variables:
  • Built-in Variables
    • SET !TIMEOUT 33
      • Defines new timeout value
    • SET !ERRORCONTINUE (YES/NO)
      • Tells IM to ignore errors and continue
    • SET !REPLAYSPEED (FAST/MEDIUM/SLOW)
    • SET !FILELOG c:mylog.txt
      • Sets a specific log file name for the current macro
    • SET !EXTRACTADD {{!URLCURRENT}}
      • Contains the current page URL
      • {{…}} are used when the value of the variable is used
    • See user manual for a list of all built-in variables
  • Getting Data to a website
    • You can submit different information to the same Web page using Internet Macro.
    • The data source can be in two different formats:
      • Either a text file with a list of variables and their values (“ini file style”)
      • A comma separated text file (CSV format) which can be generated by Microsoft Excel and many other applications.
      • The “List of variables&quot; format is recommend if you have many different variables (for example detailed address data or test of one user).
      • The CSV format is most appropriate for use with a few variables with many different values (for example a long list of user accounts that you want to submit to a website).
    • You can link to any CSV or List of variable file by using the statement in the macro:
        • CMDLINE !DATASOURCE mydata.txt
    Submitting Data to Websites:
    • A CSV file looks like this:
      • “ FIRST NAME&quot; , “LAST NAME&quot; , “AGE“
      • “ Andrew&quot;, “Smith&quot;, “23&quot;
      • “ John”, “Rafols”, “39”
      • “ Ann”, “Schwarz”, “30”
      • Variables in the macro: {{!COL1}}, {{!COL2}}, {{!COL3}}
    • A “List of variables“ file looks like this:
      • [iOpus]
      • FirstName=Andrew
      • LastName=Smith
      • Age=23
      • Variables in the macro: {{FirstName}}, {{LastName}}, {{Age}}
    CSV and Variable Files
  • Demo: Submit Data to Website
    • Take a list of ISBN numbers from a file and search for them at Amazon.com
      • 0970436300
      • 0471430218
      • 0471201006
      • 0471232815
      • 0131421891
    • Take a list of keywords and search for them on Google.com
  • Getting Data from web pages
  • Getting data from the Web Page
    • Save web page
    • Downloading file
    • PRINT
    • EXTRACT command
    • More specialized commands:
      • “ Save Target As”, “Save Picture As” Events
    In general, getting data from websites is more complicated than submitting data, as there any many forms in which the data is made available. Internet Macros offers commands for each situation:
  • Web Data Extraction TAG…. EXTRACT=…
    • Internet Macros can extract data from Web sites.
    • Open the site of your interest and start recording.
    • Click on the EXTRACT DATA button while in recording mode to bring up the extraction wizard.
    • The EXTRACT button is only available in the
      • iMacros Browser but not in the IE Plug-In.
    Extracting Data:
    • Open the Extraction Wizard.
    • In the browser window select the text that you want to extract.
    • Click the &quot;Suggest&quot; Button.
    • Click TEST to test run the extraction.
    • If you are satisfied with the result, click ADD to add the EXTRACT statement to the macro.
    • If you extract a complete table, the table data is automatically converted into comma-separated data
    Defining which Data to Extract:
  • Data Extraction Wizard
    • There are three ways to save extracted data:
    • Built-in SAVEAS feature:
      • You can use the SAVEAS TYPE=EXTRACT command inside a macro.
      • If several EXTRACT commands are used within one macro, the content is appended to the file.
    • Reuse in macro using the {{!EXTRACT}} variable
    • Saving the data via the Internet Macros Scripting Interface :
      • When you run the macro from a script you can return the data to the script and save it with whatever method or format you prefer.
      • For example, you can save it to a text file or even directly to a database.
    How to Store Extracted Information
  • Demo: Extract Data from Website
    • Create a price comparison engine: Take a list of ISBN numbers from a file and search for them at Amazon.com. Then save them in a CSV file with two columns (1st column: ISBN number, 2nd column: Price in US$)
      • 0970436300
      • 0471430218
      • 0471201006
      • 0471232815
      • 0131421891