AFC Posted July 15, 2013 Share Posted July 15, 2013 (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> </span> <div class="btn3">Add Site/Page</div></a> Second one: <a class="single_like_button btn3-wrap" onclick="openFbLWin_857528();"> <span> </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 July 18, 2013 by AFC Link to comment Share on other sites More sharing options...
Gianni Posted July 15, 2013 Share Posted July 15, 2013 hi AFC perhaps you do not find the second one, because you get out of the loop when you find the firsttry 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 Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
AFC Posted July 15, 2013 Author Share Posted July 15, 2013 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 Link to comment Share on other sites More sharing options...
DW1 Posted July 15, 2013 Share Posted July 15, 2013 If onclick="openFbLWin_857528();" is static, you could just execute the javascript function: $oIE.document.parentWindow.execScript('openFbLWin_857528();',"javascript") mLipok and 0xdefea7 2 AutoIt3 Online Help Link to comment Share on other sites More sharing options...
AFC Posted July 15, 2013 Author Share Posted July 15, 2013 Thanks thats great idea but it is not static Link to comment Share on other sites More sharing options...
dragan Posted July 16, 2013 Share Posted July 16, 2013 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. Link to comment Share on other sites More sharing options...
BrewManNH Posted July 16, 2013 Share Posted July 16, 2013 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 GudeHow 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 Link to comment Share on other sites More sharing options...
dragan Posted July 16, 2013 Share Posted July 16, 2013 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. mLipok 1 Link to comment Share on other sites More sharing options...
BrewManNH Posted July 16, 2013 Share Posted July 16, 2013 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 GudeHow 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 Link to comment Share on other sites More sharing options...
AFC Posted July 18, 2013 Author Share Posted July 18, 2013 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) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now