Sign in to follow this  
Followers 0
neo291

cant click dynamic links created by javascript

7 posts in this topic

Hi!

I'm tryin to click on a particular link on a webpage. And this is what i get as source of that link :-

<div id="linkautoit" class="cont"><a style="cursor: pointer; margin-left: 1px; width: 150px;" onclick="enterRoom('autoit','autoit(39)','D');">autoit(39)</a></div>

The number which appears in the bracket keeps changin.

so far i have managed to get the link name(updated link name with current number in the brackets) but click action is not happenin on it.

Herez what i'm tryin :-

$oDiv = _IEGetObjById ($oIE, "linkautoit")
ConsoleWrite(_IEPropertyGet($oDiv, "innertext") & @CR)
_IEAction ($oDiv, "click")

Pls guide me.


I'm not a programmer. Just a Power User.

Share this post


Link to post
Share on other sites



Hi!

I'm tryin to click on a particular link on a webpage. And this is what i get as source of that link :-

<div id="linkautoit" class="cont"><a style="cursor: pointer; margin-left: 1px; width: 150px;" onclick="enterRoom('autoit','autoit(39)','D');">autoit(39)</a></div>

The number which appears in the bracket keeps changin.

so far i have managed to get the link name(updated link name with current number in the brackets) but click action is not happenin on it.

Herez what i'm tryin :-

$oDiv = _IEGetObjById ($oIE, "linkautoit")
ConsoleWrite(_IEPropertyGet($oDiv, "innertext") & @CR)
_IEAction ($oDiv, "click")

Pls guide me.

Look at _IEAction() Example 2 in the help file, assigning focus and sending "{ENTER}" instead of clicking.

:D


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

Or try this other method from the DOM:

$oDiv = _IEGetObjById ($oIE, "linkautoit")
$oLink = $oDiv.firstChild
_IEAction ($oLink, "click")

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

Thanx PsaltyDS! I tried that method earlier but it dint work.

Thanx DaleHohm!! Your suggestion worked like a charm :D

Therez another question, if the source code is this :-

<div id="linkautoit" class="cont">
<span style="margin-left: 1px; width: 150px;">
<a style="cursor: pointer;" onclick="showNoOfUserNotIncremnt('autoit','autoit','D');enable();">autoit</a></span>
<span><a style="cursor: pointer;" onclick="deleteRoom('autoit','autoit','D');">
<img src="images/delete.gif" border="0" width="16" height="16"></a></span></div>

Dont you think the same method should work as told by DaleHohm ??

For some reason its not working. Its only showing the innertext but not clicking on it.

Any Suggestion ?


I'm not a programmer. Just a Power User.

Share this post


Link to post
Share on other sites

I guess first child thing aint working coz the thing i'm tryin to click is no longer first child.

and i cant figure out how to click on second child/node.

Tried childnodes(i) but i guess that must be a wrong way since it dint work.


I'm not a programmer. Just a Power User.

Share this post


Link to post
Share on other sites

This is working, but then i'm not sure this is the best way to go about it or there is even better way to do this :-

$oDiv = _IEGetObjById ($oIE, "linkautoit")
ConsoleWrite(_IEPropertyGet($oDiv, "innertext") & @CR)
$oLink = $oDiv.childNodes(0)
$oNewLink=$oLink.firstchild
_IEAction ($oNewLink, "click")

I'm not a programmer. Just a Power User.

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

This is slightly less complex:

$oDiv = _IEGetObjById ($oIE, "linkautoit")
$oSpan = $oDiv.firstChild
$oLink = $oSpan.firstChild
_IEAction ($oLink, "click")

Dale

Edit: Here's another way... this will click the first link (index 0) inside the named div:

$oDiv = _IEGetObjById ($oIE, "linkautoit")
$oLink = _IETagnameGetCollection($oDiv, "a", 0)
_IEAction ($oLink, "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

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