Sign in to follow this  
Followers 0
AFC

Can't click 2nd Div Object

10 posts in this topic

#1 ·  Posted (edited)

in short how can I click dynamic javascript objects ? ( I learned that I can't find their source via source code tab)

I have a strange problem, don't know what is it about. I want to click an object on webpage which classname is "btn3"
But there are 2 of "btn3" objects on the page. The problem is I can find first one but can't find second one. So here it is
 
First one:

<a class="add-btn btn3-wrap" href="/add_edit_sites.html">
<span>&nbsp;</span>
<div class="btn3">Add Site/Page</div></a>

Second one:

<a class="single_like_button btn3-wrap" onclick="openFbLWin_857528();">
<span>&nbsp;</span>
<div class="btn3">Like</div></a>

And my AutoIt code: (didn't put click code, just put msgbox to see if I can find or not but just saw msgbox only 1 time)

$oDivs = _IETagNameGetCollection ($amf_IE, "div")
For $oDiv in $oDivs

    If (String($oDiv.classname)="btn3")  Then
        MsgBox(0,"","")
    ExitLoop
    EndIf
Next

I just tried to use innerText but again I couldn't find second object. I think it is not about AutoIt code, there must be something I'm missing

Edited by AFC

Share this post


Link to post
Share on other sites



hi AFC

perhaps you do not find the second one, because you get out of the loop when you find the first

try to remove exitloop from inside the for-next loop

$oDivs = _IETagNameGetCollection ($amf_IE, "div")
For $oDiv in $oDivs

    If (String($oDiv.classname)="btn3")  Then
        MsgBox(0,"","")
  ;  ExitLoop  < ==== remove this
    EndIf
Next

bye


small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Share this post


Link to post
Share on other sites

Thanks for your suggest but no it is not cause

I think Autoit wors with source code and it may be problem beacuse I can see that tag in inspect element but cant see in source code, in some way it is hidden

Share this post


Link to post
Share on other sites

If onclick="openFbLWin_857528();" is static, you could just execute the javascript function:

$oIE.document.parentWindow.execScript('openFbLWin_857528();',"javascript")
2 people like this

Share this post


Link to post
Share on other sites

Thanks thats great idea but it is not static 

Share this post


Link to post
Share on other sites

try this:
 

$oDivs = _IETagNameGetCollection ($amf_IE, "div")
For $oDiv in $oDivs
    If $oDiv.classname == 'btn3' Then
        If $oDiv.innertext == 'Like' Then
            MsgBox(0,"","success")
            ExitLoop
        EndIf
    EndIf
Next

You better use "==" instead of "=" for object's properties.

Share this post


Link to post
Share on other sites

You better use "==" instead of "=" for object's properties.

Why?

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

I know, it's very strange, but whenever I used "=", I couldn't always get all IE object's properties, but only the first one.
I don't know why is this happening because in autoit "=" means both, set and get value, but when it comes to object's properties, (at least with IE objects), I'm forced to use "==" because that's the only way for me to get all data I need.

I dunno if it's IE version related, or OS related, or AutoIt version related...
All I know is that I have IE 10, win7 64-bit, and I must use "==" to get all values.

I also know that on my older system (WinXP 32-bit, with IE8) I could use only "=" to get all values.

1 person likes this

Share this post


Link to post
Share on other sites

It shouldn't affect getting the properties, "==" is used as a case-sensitive string comparison, whereas "=" is case-insensitive. As long as the information you're comparing to doesn't rely on case-sensitivity, then it shouldn't matter. If it doesn't work with just "=" then it could be a bug, or your code, if it's a bug, it should be reported as such.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

Thank you for your interest but it didn't solve my problem, 

in short how can I click dynamic javascript objects ? ( I learned that I can't find their source via source code tab)

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