Jump to content

Accessing Checkboxes on a Webpage


Recommended Posts

I would like to write a script that automates the clicking of checkboxes on a webpage.

We subscribe to an online list broker that allows us to compile and download lists of companies. First you enter the desired criteria (geography, industry, size, etc) and then you are presented with a list of companies meeting those criteria. Then you select the desired companies by clicking the appropriate check boxes. The system displays 10 companies per page, so if the list contains 75 companies there will be 8 pages. Unfortunately there's no "choose all" function. You have to click each company individually.

The attached screenshot shows the company display. As you can see from the message at the bottom right of the screen, we are looking at the first 10 companies of a list containing 67. I've already clicked two companies and there's a message at the top right of the screen saying "2 companies selected". At the bottom left of the screen there are some controls indicating what is the current page# as well as controls for previous page, next page and "goto page#".

I'm really new at this, so I need some advice on how this may be accomplished. As I understand it, webpages are not regular Windows controls. If that's the case how do I figure out where these checkboxes are located so that they can be checked. However my understanding of webpages may be entirely wrong. That's why I need help.

Any suggestions would be greatly appreciated. Sample code would be even better.

Gary

Link to comment
Share on other sites

See example scripts under _IEFormElementCheckBoxSelect() and the other _IE* functions of the IE.au3 UDF in the help file.

:mellow:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Hi PsaltyDS:

> See example scripts under _IEFormElementCheckBoxSelect()

Thank you for the information.

Actually I noticed those _IE functions listed in the Help index, however it didn’t occur to me that they had to do with Internet Explorer. Stupid me.

From the name I gather that these functions only work with IE.

How about other browsers?

The reason I'm asking is because this particular webpage does not perform well with IE, so I always use Mozilla Firefox.

Are there any tools for Firefox?

Link to comment
Share on other sites

IE has a COM interface that exposes the DOM (document object model) and application automation where AutoIt can use it. Firefox doesn't.

There is an FF.au3 UDF for Firefox, but using it requires you to fist install a Firefox plugin called MozRepl, which exposes FF internals to external automation, so scripts written for it will not work unless that plugin is installed first.

:mellow:

Edit: Typo.

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

===== Regarding: FF.au3...

Hi PsaltyDS:

> There is an FF.au3 UDF for Firefox,

> but using it requires you to fist

> install a Firefox plugin called MoxRepl

Thank you for this information.

I just visited the FF forum on AutoIT and get the impression the the FF udf is still under development and keeps on changing. Also there a no examples similar to those in the regular AutoIT help file. I would imagine that the only way one would know how to use these functions is by delving into the code to see what they do. I'm not a programmer and only began using AutoIT last week. Without the AutoIT help file I'd be lost. So I don't think there's much have hope for me using the FF udf in its current state. Unless someone could can give me some tangible examples.

As I explained above, we subscribe to an online list broker that allows us to compile and download lists of companies. First you enter the desired criteria (geography, industry, size, etc) and then you are presented with a list of companies meeting those criteria. Then you select the desired companies by clicking the appropriate check boxes. The system displays 10 companies per page, so if the list contains 75 companies there will be 8 pages. Unfortunately there's no "choose all" function. You have to click each company individually.

The question is how to find the precise location of the checkboxes. Getting the location of the top checkbox is no problem using Au3Info.exe. And from there it should be a no-brainer to determine the location of the subsequent checkboxes. Usually there's 43 pixels between each checkbox, however if the line is wrapped (example a long company name) 43 pixels is no longer the correct number. And since I cannot determine if the line is wrapped it's impossible to figure out where is the next checkbox.

Once again your advice is greatly appreciated.

===== Regarding: "IE Tab Plus"...

Hi 871...

> there is an addon called IE Tab Plus

Thank you for this information.

I found it at https://addons.mozilla.org/en-US/firefox/addon/10909/ .

Let me understand this...

If I install IE-Tab I will be able to use the standard IE udf?

How about the website for which I am writing the script?

Will it work ok. Remember it's usually buggy with IE and that's why I have been using FF.

Once again your advice is greatly appreciated.

Edited by CE101
Link to comment
Share on other sites

I was a doubter, but this worked with the AutoIt home page loaded in an IE Tab Plus tab in Firefox (per 871, above):

#include <IE.au3>

$oIE = _IEAttach("http://www.autoitscript.com", "url")
If @error Then
    ConsoleWrite("Error - not found." & @LF)
Else
    $sTitle = _IEPropertyGet($oIE, "title")
    ConsoleWrite("Success: " & $sTitle & @LF)
EndIf

Suffers from the same limitation as MozRepl however, a plugin must be installed before the script will work.

:mellow:

P.S. Finding elements by pixel coordinates is going to be a highly unreliable, looserly proposition. Either through real IE or maybe IE Tab as above, learn to use the IE.au3 UDF on it.

:P

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

  • 2 weeks later...

Hi PsaltyDS:

Thank you very much for the code you added to this thread on June29.

I'm afraid I haven't seen your material till now - I forgot to set "email notification" on my posting.

Sorry about that.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...