Jump to content
Macro Express Forums
Upton O Good

Suggestions for how to verify correct web page before continuing script

Recommended Posts

After logging into my bank they always display some advertisement before showing me my accounts. In general, what are some good ways to verify I'm on the right web page before tabbing or clicking around?

 

I already have some scripting that looks for the words "No Thanks", and clicks it, if it exists. Because "No Thanks" is a pretty common button on the ad page. But sometimes they have other buttons instead, like "Remind me later" or "Drop dead" or whatever. So I want an additional check that looks for what SHOULD be there before continuing.

 

I could just continue looking for specific words, like the phrase "Primary Account" or whatever.  But instead I though I might look for specific controls that exist on the accounts page.  However, in order to define a control into a variable, it has to EXIST at least once.  I see no way to save a control variable for long-term use, like if this runs automatically every weekend.

 

I hope this question makes sense. My scripts are years old and I have only recently come back to it. So I'm rusty.

 

Edit: There is another compelling reason for looking for new ways to verify you've landed on the correct web page.  On some pages my searching for certain text does not work. A good example is Gmail.com. Let's say I log in and search for the word "Compose" or "Primary". Those are prominent words near the top of the page. The behavior I hope for is that after <control>f, compose, <escape>, and that word "compose" remains highlighted.  That way I can copy to clipboard and test for the word. If it's present, I'm likely on the right page. But on many web pages certain words do not remain highlighted. On Gmail almost nothing will.  To see the difference do <control>a to highlight all. Notice very little is highlighted. What is a better test?

Edited by Upton O Good
Give better example

Share this post


Link to post
Share on other sites

FYI MEP can't access web form controls. The only control is the entire rendered area. 

 

I like to F6 and evaluate the URI. Maybe it contains something like "myaccounts" in the path or you can use the entire URI. Or there could be parameters in the query that can be used. 

Share this post


Link to post
Share on other sites
6 minutes ago, Cory said:

FYI MEP can't access web form controls. The only control is the entire rendered area. 

 

I guess I didn't fully understand that until now. That could be an area of great improvement for MEP. I've been able to make some inroads into inspecting rendered pages, and drawing conclusions. And I see other people have as well. But most attempts are often unreliable, or not universal on more than one computer, or need frequent repair. I try to do a lot of error checking and taking screen shots for later diagnosis.

 

8 minutes ago, Cory said:

I like to F6 and evaluate the URI.

 

It's a good idea. Because many web pages will immediately "redirect" to their own internal version of URL.  Then at least you know the server is talking.  Though, you dont know if page fully loaded and page scripting is completed.

 

Thanks for the reply. I know it's a pretty vague question to answer.

Share this post


Link to post
Share on other sites
1 hour ago, Cory said:

FYI MEP can't access web form controls. The only control is the entire rendered area.

I discovered that just yesterday when trying to use controls to click on a button.  😧

 

I have scripts for some web sites where a button or image appears, and maybe also changes color when the mouse hovers over it, once the page has loaded.  Since I know where the button will be, I put the mouse there and keep checking the color until it gets to what I want. 

 

I also use Cory's method of examining the URL -- I didn't know F6 would highlight it, I have been using Alt-d. 

 

Also for some pages it works to click within the page, Ctrl-a to highlight everything and copy to clipboard, and look for identifying text.  Typing END or clicking the mouse again usually clears the highlighting.   

Share this post


Link to post
Share on other sites
23 hours ago, Upton O Good said:

on many web pages certain words do not remain highlighted. On Gmail almost nothing will.  To see the difference do <control>a to highlight all. Notice very little is highlighted. What is a better test?

If you come up with something for Gmail, let us know.  I had a great macro that handled the list of emails on the Inbox screen to identify and delete duplicates.  Gmail changed some time ago so the macro is now useless.   

Share this post


Link to post
Share on other sites

Here are three methods for gathering information about a web page when programmatic methods are not available. Use one, two, or all three of the methods to infer whether you're on the "right" page. None of the approaches is 100% reliable, but one or a combination can yield pretty good results.

 

On gathering information from the address line: In general, Alt + D is a more reliable than F6, as F6 is also the hotkey to jump from frame to frame. So if a page has frames, F6 might not do what you intend. In some browsers, Ctrl + L is an alternative way to navigate to the Address bar.

 

Quote

// Method 1: Check window title ("title bar") for keywords
Variable Set String %WindowTitle% to topmost window title
 
// Method 2: Check address bar for keywords
Text Type (Simulate Keystrokes): <ALT>d // Navigate to the Address bar (Ctrl + L might work, as well)
Delay: 100 milliseconds
Clipboard Copy
Delay: 100 milliseconds
Variable Set String %AddressText% from the clipboard contents
 
// Method 3: Check HTML for keywords
HTTP Get: %AddressText% to %HTMLCode%
 
// Test the variables
If Variable %WindowTitle% Contains "Google"
  OR
If Variable %AddressText% Contains "google.ca"
  OR
If Variable %HTMLCode% Contains "Feeling Lucky"
  Text Box Display: YES
Else
  Text Box Display: NO
End If

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...