Sign in to follow this  
Followers 0
newb_powa'

IEGetObjByName without ID

9 posts in this topic

I'm trying to automate a click on a button, but the problem is that the button got no ID.

<INPUT style="BORDER-RIGHT: 1px solid; BORDER-TOP: 1px solid; BORDER-LEFT: 1px solid; COLOR: white; BORDER-BOTTOM: 1px solid; BACKGROUND-COLOR: #554433" onclick=sendLevelUp(); type=button value="[ Ok! ]">

This is the html code of the button. I've looked trought the help file but I can't find any function that will create a reference to an object by his value. If there is a way just tell it to me, and if there is not, how can I click this button ?

Between, the button is'nt in a form for what i can see.

Thanks for help.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

You need to use either _IETagnameGetCollection or _IEFormElementGetCollection using an index. See the helpfile for examples. You are correct - there is no function to get something directly by value.

Dale

p.s. to click on it use _IEAction click

Edited by DaleHohm

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

You need to use either _IETagnameGetCollection or _IEFormElementGetCollection using an index. See the helpfile for examples. You are correct - there is no function to get something directly by value.

Dale

p.s. to click on it use _IEAction click

I knew about Action ==> click, but I did'nt for _IETagnameGetCollection or _IEFormElementGetCollection, I will look what I get from those two function, thanks

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

I'm trying to automate a click on a button, but the problem is that the button got no ID.

<INPUT style="BORDER-RIGHT: 1px solid; BORDER-TOP: 1px solid; BORDER-LEFT: 1px solid; COLOR: white; BORDER-BOTTOM: 1px solid; BACKGROUND-COLOR: #554433" onclick=sendLevelUp(); type=button value="[ Ok! ]">

This is the html code of the button. I've looked trought the help file but I can't find any function that will create a reference to an object by his value. If there is a way just tell it to me, and if there is not, how can I click this button ?

Between, the button is'nt in a form for what i can see.

Thanks for help.

Check the help file for the _IE* functions. Play with the examples. You first need to get the DOM object for the button, i.e. with _IETagNameGetCollection(), then use _IEAction() with "click".

:P

Edit: Slow typing... beat to it.

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

Share this post


Link to post
Share on other sites

Note that you can in fact find an element by value. but you need to loop through a collection to do it... see the example for _IETagnameGetCollection and examine the value of $oInput.value to find a match.

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

Note that you can in fact find an element by value. but you need to loop through a collection to do it... see the example for _IETagnameGetCollection and examine the value of $oInput.value to find a match.

Dale

It does the trick :P

$oInputs = _IETagNameGetCollection ($oIE, "input")

For $oInput In $oInputs

If $oInput.value = "[ Ok! ]" Then

_IEAction ($oInput, "click")

EndIf

Next

I just put here the code I've used so if someone have the same question, there is the answer.

Thanks for the tips Dale

Share this post


Link to post
Share on other sites

Very good. Suggest you add an ExitLoop however to prevent errors for input tags in the collection after you click:

$oInputs = _IETagNameGetCollection ($oIE, "input")
For $oInput In $oInputs
    If $oInput.value = "[ Ok! ]" Then
        _IEAction ($oInput, "click")
        ExitLoop
    EndIf
Next

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

Edit: Slow typing... beat to it.

@PsaltyDS -- If I'd known you were there, I would have gladly let you handle it :P

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

What if you use the debug bar and know the DOM location?

How could you write that?

$oInputs = _IETagNameGetCollection ($oIE, "input")
If $oInput.234 = "[ Ok! ]" Then
     _IEAction ($oInput, "click")
     ExitLoop
EndIf
Edited by Oldschool

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  
Followers 0