Monitor Web Page for a Pop Up or Element
This article describes methods that can be applied in the event that you would like to monitor a web-page for a popup, or any other element that you would like to send an interactive action towards in the event that it is present.
It is possible to decouple the monitoring process from the main process. The attached sample processes work in conjunction. The main process launches a browser instance and the monitor process attaches to the browser launched in the initial process. The monitor process relentlessly loops to look for a control identified in the browser. This method can be applied to any pop-up as required.
This example contains two processes described in detail below.
The initial process launches a browser, navigates to google.com, starts the monitoring process, waits 10 seconds, and navigates back to google.com in the event that the monitoring process pressed ‘I’m Feeling Lucky’ element as it’s designed to do when it is found. This button mimics a control that a monitoring process seeks to find from a pop-up - with the google landing page acting as the identified 'pop-up' window.
The subsequent monitoring process loops infinitely until the initial process terminates the browser session, attaches to the browser launched by the initial process, and clicks the ‘I’m Feeling Lucky’ element which in this case would mimic an element in a pop-up that we are looking for.
Please note the 'Start Process' action is not available in basic edition of WinAutomation - both Basic and Pro/ProPlus versions are attached. If you are using the basic version, you will have to start both processes manually (or schedule them for your own tasks). For Pro/Pro Plus users, please import the attached processes into your 'My Processes' folder prior to execution to avoid errors Action 2 of the Main Process. Also note that a pop warning up will appear when running through the Process Designer advising users that the 'Start Process' action which is designated to work through the WA Console.
Wait for Window – Main Process
- Action 1: ‘Launch New Internet Explorer’ > set ‘Initial Url’ > ‘Store Internet Explorer Instance into:’ %Browser%
- Action 2: ‘Start Process’ > Point ‘Process to Run:’ to Wait for Window – Monitor Process
- Action 3: ‘Loop’ > from 1 to 5 incrementing by one (any loop can be used here to satisfy your process)
- Action 4: ‘Wait’ > set to 10 seconds for this particular example
- Action 5: ‘Go to Web Page’ > reverts page back to original state after target element triggered by monitoring process
- Action 6: ‘Close Web Browser > closes %Browser%
Wait for Window – Monitor Process
- Action 1: ‘Loop while the condition’ 1 > 0 is true (infinite loop)
- Action 2: ‘Launch New Internet Explorer’ > set ‘Operation’ to Attach to Running IE > ‘Select IE’ by Title > ‘Tab Title’ set to Google for this example
- Action 3: ‘If Window’ > ‘Get Window’ by Window Instance/Handle > ‘Window Instance’ set to %Browser% which latches onto %Browser.Handle% initiated in main process > ‘Check if Window’ set to Is Open
- Action 4: ‘Click Link on Web Page’ > ‘Web Browser Instance:’ set to %Browser% > ‘Select Control From Repository’ and identify element for ‘Im Feeling Lucky’ (to mimic control which overrides popup)
- Action 7: ‘Label’ titled ‘Stop Monitoring’ – once added to process, go back to action 2 and set exception handling to ‘Continue Process Execution’ > ‘Go to Label’ > ‘Stop Monitoring’
- Action 8:‘Stop Process’ > set ‘End Process’ to ‘Successfully’.When the main process closes the %Browser% action 2 will eventually fail and that will trigger the end of this monitoring process.