Detecting images and buttons in browser

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
river10
Newbie
Posts: 5
Joined: Tue Oct 28, 2003 4:03 pm

Detecting images and buttons in browser

Post by river10 » Mon Dec 08, 2003 5:44 pm

Hello,

I am currently doing some internet scripting in Internet Explorer by pressing tab a defined number of times to get to the appropriate image or button and then "Press Enter".

The problem I run into is when the button that needs to be pressed isn't always in the exact same location. i.e. takes a different amount of tabs each time to get to it.

So, is there anyway to "recognize" a particular image or button on the page and navigate to that?

Thanks.

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Tue Dec 09, 2003 12:15 am

This is not a solution, but 3 approaches that sometimes provide a work around for me:

========================
1. I have found it useful to count tabs from the bottom of the page vs. from the top.

Use the following commands:
Press Shift
Press Tab*n
Release Shift

========================
2. Use Edit, Find in Page, some string just ahead of the button. After doing Find, then count Tabs or Shift-Tabs to go down/up to your button.

========================
3. Some pages may have bookmarks, so enter the URL with the bookmark into the address block, then do your Tab counting from there.

Note: Also watch out for Toolbars/Explorer Bars that may be on/off. Some of these may also get involved in the Tab counting process. So perhaps you may have to have your macro turn off oll toolbars/Explorer Bars before counting. That then raises the issue of how to restore the toolbars that were active before you started, but now I am drifting into other issues. Just wanted to wave some caution flags from some of my scar tissue.

One last note: Toggling F11 in MSIE will provide a "full view" which may provide some consistency to the layouts you are dealing with. Most menus and Toolbars will go away and then return when toggled at end of process.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Tue Dec 09, 2003 12:21 pm

The other solution, which is often overlooked, is just to navigate straight to the URL that the button takes you to when clicked on.

If the button submits form data then you can sometimes also add the query string to the URL with the data you want, bypassing the form completely.

In which case you may not need to script IE at all and just use HTTPRequest with form data parameters to return the required result.

Just a thought. May not be appropriate in your case. But usually I avoid scripting IE at all and instead issue the data to get the required result.
MJT Net Support
[email protected]

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Tue Dec 09, 2003 4:11 pm

If the button submits form data then you can sometimes also add the query string to the URL with the data you want, bypassing the form completely.
Aaaah!. I like that. Very clever. That goes in my toolbox, thanks. :D
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Tue Dec 09, 2003 4:55 pm

And don't forget that HTTPRequest can also POST data, so if a GET operation with the form parameters query string on the URL fails, POST the form parameters instead.
MJT Net Support
[email protected]

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts