Jump to content
Sign in to follow this  
taylormade

How do I check for the existance of a button on a web page?

Recommended Posts

taylormade

part of my script is:

------------------------------------------------------

If StringInStr(_IEBodyReadText($oIE), $Text, 2) = 0 and $a = 1 Then

_IELinkClickByText($oIE, "Accept project")

; more code here

Endif

------------------------------------------------------

What I'm doing is waiting for the page NOT to contain the text in $Text.

Then it should procede to the next line: _IELinkClickByText($oIE, "Accept project") (click the button)

However, there are occations when $Text is not present on the page, AND that button is NOT there either (ie: the page doesn't load fully, or a different page appears briefely)

In that case, I want my script to exit the IF / Endif and just procede past it and continue the code.

I want to run this in the Scite Editor for now, so I don't need any UI and such.

Here is the error I'm getting when the scenario I illustrated above occurs.

" Warning from function _IELinkClickByText "

Can I trap that error and then get out of the IF / ENDIF section gracefully somehow?

bob

Edited by taylormade

Share this post


Link to post
Share on other sites
Blue_Drache

Psudeocode noodling...

While 1
Sleep(10)
If _PageLoaded() Then
If Not _SearchForText() Then
         _IELinkClickByText($oIE, "Accept project")
         If @error <> 0 then ConsoleWrite("Unable to locate click link by text.  Error code: " & @error & @CRLF)
     EndIf
EndIf
WEnd

This is what I got based on what you want to do.

Also, what error code is it throwing? According to the help file, @error can be one of 8 values with different meanings. The conslewrite call will scribble it into the console on SciTE so you can see what's happening.

Edited by Blue_Drache

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Share this post


Link to post
Share on other sites
taylormade

nice quick response..:

I'm new to AutoIT so...

Are:

If _PageLoaded() Then

If Not _SearchForText() Then

supposed to be in my code "as is" or do I need to put parameters to them.

_SearchForText seems to need more info right?

Share this post


Link to post
Share on other sites
Blue_Drache

Psuedocode, dude. Not real code. That means I roughed out the structure and idea with simplified language. _pageloaded() and _searchfortext() are placeholders for whatever code you're going to use.


Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Share this post


Link to post
Share on other sites
taylormade

if you have a Paypal account, I can shoot you a few bucks to fix my actual code with the real stuff?

Share this post


Link to post
Share on other sites
Blue_Drache

No. We don't do that here. Our focus is to teach you how to do it ... not write it for you.


Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Share this post


Link to post
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
Sign in to follow this  

×