The renewal maintenance has officially ended for Progress iMacros effective November 30, 2023.
This Wiki site will also no longer be moderated from the Progress side.
Thank you again for your business and support.
Sincerely, The Progress Team
Difference between revisions of "Web Page Dialogs"
(10 intermediate revisions by 2 users not shown) | |||
Line 2: | Line 2: | ||
This is a collection of tips and tricks on how to automate web page dialogs (WPD). These dialogs are IE only. Technically they are created by either a [http://msdn2.microsoft.com/en-us/library/ms536759(VS.85).aspx ShowModalDialog] or [http://msdn2.microsoft.com/en-us/library/ms536759(VS.85).aspx showmodelessDialog] command. They are not tabbed web pages and Internet Explorer (and the iMacros Browser) can not open them inside a tab. But iMacros has several methods to automate and test such dialogs. | This is a collection of tips and tricks on how to automate web page dialogs (WPD). These dialogs are IE only. Technically they are created by either a [http://msdn2.microsoft.com/en-us/library/ms536759(VS.85).aspx ShowModalDialog] or [http://msdn2.microsoft.com/en-us/library/ms536759(VS.85).aspx showmodelessDialog] command. They are not tabbed web pages and Internet Explorer (and the iMacros Browser) can not open them inside a tab. But iMacros has several methods to automate and test such dialogs. | ||
− | + | ||
− | + | ||
+ | |||
+ | == Simply fill in the values with a [[TAG]] command == | ||
+ | |||
+ | Do not overlook the possibility that you might not need to handle the web page dialog at all. On some websites the iMacros [[TAG]] command can fill in the values in a box, even so you can not do it manually (= need to use the web page dialog). | ||
+ | An example is the date control of this [http://www.tase.co.il/TASE/General/Company/companyHistoryData.htm?subDataType=0&companyID=000412&shareID=00412015 Hebrew site]. Even though a normal user needs to use the date control, the iMacros TAG command can fill in the date directly. This works because iMacros circumvents certain Javascript checks. | ||
+ | |||
+ | [[Image:Web_page_dialog_simple_tag.png]] | ||
+ | |||
+ | == Use the [[Browser_Automation#Web_Page_Dialogs|Dialog Manager]] == | ||
Advantage: | Advantage: | ||
This method works well for simple dialogs. | This method works well for simple dialogs. | ||
− | Semi-visual recording with the dialog manager | + | <!--Semi-visual recording with the dialog manager |
− | Click-command can also click on buttons on modal windows (Use [[DirectScreen]] recording to get the coordinates you need, then insert a <nowiki>{{CLICK 11 22}}</nowiki> command in the [[ONWEBPAGEDIALOG]] line. | + | Click-command can also click on buttons on modal windows (Use [[DirectScreen]] recording to get the coordinates you need, then insert a <nowiki>{{CLICK 11 22}}</nowiki> command in the [[ONWEBPAGEDIALOG]] line.--> |
<br> | <br> | ||
− | Disadvantage: Tabbing from line to line is complicated and error-prone on complex screens. Click command needs to be created manually. | + | Disadvantage: Tabbing from line to line is complicated and error-prone on complex screens. <!--Click command needs to be created manually.--> |
− | + | ||
− | + | == Use [[DirectScreen]] == | |
DirectScreen can be used to automate all '''modeless''' dialog Windows. | DirectScreen can be used to automate all '''modeless''' dialog Windows. | ||
+ | |||
Advantage: Very powerful, supports even drag&drop, mouseover and Image Recognition on the dialog. | Advantage: Very powerful, supports even drag&drop, mouseover and Image Recognition on the dialog. | ||
<br> | <br> | ||
Disadvantage: '''Does not work on modal dialogs''' (recording works, but replay fails because the dialog stops the application. This is not a bug in iMacros, IE behaves the same way). | Disadvantage: '''Does not work on modal dialogs''' (recording works, but replay fails because the dialog stops the application. This is not a bug in iMacros, IE behaves the same way). | ||
− | |||
− | |||
− | '''''If''''' this methods works, it is very powerful and highly recommended. So we suggest to test this method if you need to automate complex web page dialogs: | + | == Use [[ONWEBPAGEDIALOG]] with the MACRO parameter == |
+ | |||
+ | Advantage: This method is very powerful and highly recommended. It allows you to play a specific macro on a web page dialog. | ||
+ | <br> | ||
+ | Disadvantage: Recording the commands for the web page dialog is a bit more complicated. Variables set with [[iimSet]] are not substituted in the specified macro. | ||
+ | |||
+ | Rather than sending a series of keys to the dialog, you can tell the [[ONWEBPAGEDIALOG]] command to play a macro file in the dialog using the following syntax: | ||
+ | |||
+ | ONWEBPAGEDIALOG MACRO=MacroFile.iim | ||
+ | |||
+ | Of course, this technique presupposes that you can "guess" the TAG commands for the elements in the dialog in order to manually create the macro file for it, | ||
+ | |||
+ | -or- | ||
+ | |||
+ | You first use this method to extract the entire HTML of the webpage dialog, save it to a file, then load the local file in the browser and use it to record the commands. | ||
+ | |||
+ | For example, you would first use something like the following: | ||
+ | |||
+ | ONWEBPAGEDIALOG MACRO=ExtractWebPageDialog.iim | ||
+ | |||
+ | Where ExtractWebPageDialog.iim is simply: | ||
+ | |||
+ | TAG POS=1 TYPE=HTML ATTR=* EXTRACT=HTM | ||
+ | SAVEAS TYPE=EXTRACT FOLDER=* FILE=MyWebPageDialog.htm | ||
+ | |||
+ | Then you would load MyWebPageDialog.htm into the browser, record the commands, and save the macro file as something like HandleWebPageDialog.iim. Note: You would also need to remove the recorded URL GOTO command. | ||
+ | |||
+ | You would then change the [[ONWEBPAGEDIALOG]] command in your main macro to the following: | ||
+ | |||
+ | ONWEBPAGEDIALOG MACRO=HandleWebPageDialog.iim | ||
+ | |||
+ | A drawback to this approach is that you cannot pass variable values into the specified macro from the scripting interface using [[iimSet]]. However, you can overcome this by using custom script/programming code to dynamically generate and write the macro to disk with all the variable values already substituted. | ||
+ | |||
+ | == Try to open the dialog in a tab == | ||
+ | |||
+ | '''''If''''' this methods works, it is also very powerful and highly recommended. So we suggest to test this method if you need to automate complex web page dialogs: | ||
a. Get the URL of the dialog window. If you open the dialog window inside Internet Explorer (not the iMacros Browser) the dialog has an address field. Get the URL pf the dialog window from there. | a. Get the URL of the dialog window. If you open the dialog window inside Internet Explorer (not the iMacros Browser) the dialog has an address field. Get the URL pf the dialog window from there. | ||
Line 31: | Line 74: | ||
c. Sometimes the SAVE function of a dialog does not work when opened as tab (data is not send to a server). We found that often the data is still stored by the website locally (e. g. using internal Javascript or cookies). So when you open the dialog method using method (1) it has the correct data and all you need to do is to click the SAVE button of the dialog. | c. Sometimes the SAVE function of a dialog does not work when opened as tab (data is not send to a server). We found that often the data is still stored by the website locally (e. g. using internal Javascript or cookies). So when you open the dialog method using method (1) it has the correct data and all you need to do is to click the SAVE button of the dialog. | ||
− | + | == Try [[iMacros for Firefox]] == | |
+ | |||
Web Page dialogs were "invented" by Microsoft and only work in Internet Explorer (and the IE compatible iMacros Browser). So often the website will simply not work in Firefox. But sometimes a website displays a normal website instead of a web page dialog when used with Firefox. In this case it can be automated with iMacros for Firefox. Or you can change the iMacros Browser [[set-user-agent.vbs|user agent]] to identify itself as a Firefox browser. | Web Page dialogs were "invented" by Microsoft and only work in Internet Explorer (and the IE compatible iMacros Browser). So often the website will simply not work in Firefox. But sometimes a website displays a normal website instead of a web page dialog when used with Firefox. In this case it can be automated with iMacros for Firefox. Or you can change the iMacros Browser [[set-user-agent.vbs|user agent]] to identify itself as a Firefox browser. |
Latest revision as of 12:40, 14 August 2013
How to automate Web Page Dialogs
This is a collection of tips and tricks on how to automate web page dialogs (WPD). These dialogs are IE only. Technically they are created by either a ShowModalDialog or showmodelessDialog command. They are not tabbed web pages and Internet Explorer (and the iMacros Browser) can not open them inside a tab. But iMacros has several methods to automate and test such dialogs.
Simply fill in the values with a TAG command
Do not overlook the possibility that you might not need to handle the web page dialog at all. On some websites the iMacros TAG command can fill in the values in a box, even so you can not do it manually (= need to use the web page dialog). An example is the date control of this Hebrew site. Even though a normal user needs to use the date control, the iMacros TAG command can fill in the date directly. This works because iMacros circumvents certain Javascript checks.
Use the Dialog Manager
Advantage:
This method works well for simple dialogs.
Disadvantage: Tabbing from line to line is complicated and error-prone on complex screens.
Use DirectScreen
DirectScreen can be used to automate all modeless dialog Windows.
Advantage: Very powerful, supports even drag&drop, mouseover and Image Recognition on the dialog.
Disadvantage: Does not work on modal dialogs (recording works, but replay fails because the dialog stops the application. This is not a bug in iMacros, IE behaves the same way).
Use ONWEBPAGEDIALOG with the MACRO parameter
Advantage: This method is very powerful and highly recommended. It allows you to play a specific macro on a web page dialog.
Disadvantage: Recording the commands for the web page dialog is a bit more complicated. Variables set with iimSet are not substituted in the specified macro.
Rather than sending a series of keys to the dialog, you can tell the ONWEBPAGEDIALOG command to play a macro file in the dialog using the following syntax:
ONWEBPAGEDIALOG MACRO=MacroFile.iim
Of course, this technique presupposes that you can "guess" the TAG commands for the elements in the dialog in order to manually create the macro file for it,
-or-
You first use this method to extract the entire HTML of the webpage dialog, save it to a file, then load the local file in the browser and use it to record the commands.
For example, you would first use something like the following:
ONWEBPAGEDIALOG MACRO=ExtractWebPageDialog.iim
Where ExtractWebPageDialog.iim is simply:
TAG POS=1 TYPE=HTML ATTR=* EXTRACT=HTM SAVEAS TYPE=EXTRACT FOLDER=* FILE=MyWebPageDialog.htm
Then you would load MyWebPageDialog.htm into the browser, record the commands, and save the macro file as something like HandleWebPageDialog.iim. Note: You would also need to remove the recorded URL GOTO command.
You would then change the ONWEBPAGEDIALOG command in your main macro to the following:
ONWEBPAGEDIALOG MACRO=HandleWebPageDialog.iim
A drawback to this approach is that you cannot pass variable values into the specified macro from the scripting interface using iimSet. However, you can overcome this by using custom script/programming code to dynamically generate and write the macro to disk with all the variable values already substituted.
Try to open the dialog in a tab
If this methods works, it is also very powerful and highly recommended. So we suggest to test this method if you need to automate complex web page dialogs:
a. Get the URL of the dialog window. If you open the dialog window inside Internet Explorer (not the iMacros Browser) the dialog has an address field. Get the URL pf the dialog window from there.
b. Now use the iMacros Browser. Open a new tab and paste the URL from step (a). Often, the dialog window opens now inside a tab. You can now use the normal recording features (TAG,...) to automate the dialog!
c. Sometimes the SAVE function of a dialog does not work when opened as tab (data is not send to a server). We found that often the data is still stored by the website locally (e. g. using internal Javascript or cookies). So when you open the dialog method using method (1) it has the correct data and all you need to do is to click the SAVE button of the dialog.
Try iMacros for Firefox
Web Page dialogs were "invented" by Microsoft and only work in Internet Explorer (and the IE compatible iMacros Browser). So often the website will simply not work in Firefox. But sometimes a website displays a normal website instead of a web page dialog when used with Firefox. In this case it can be automated with iMacros for Firefox. Or you can change the iMacros Browser user agent to identify itself as a Firefox browser.