byoda Posted June 7, 2010 Share Posted June 7, 2010 Ive been trying to come up with a script to automatically click on a javascript link. I cant seem to get it. Here are the javascript variable. <A class=tab-text id=li_T06 href="javascript:f_lsnb('T06', 6)">Flash</A> Thank you. Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 7, 2010 Share Posted June 7, 2010 Get the object reference to 'li_T06' and use it with _IEAction() and "click", or "focus" then ControlSend(). See help file under _IEAction() for both methods. 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 Link to comment Share on other sites More sharing options...
DaleHohm Posted June 7, 2010 Share Posted June 7, 2010 Or _IELinkClickByText($oIE, "Flash") 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 Link to comment Share on other sites More sharing options...
byoda Posted June 8, 2010 Author Share Posted June 8, 2010 I tried the following and I cant get it to work. There are no errors, but the link is not clicked. I know this is pretty straight forward. Am I missing something? Thank for your help. #include<IE.au3> $oIE=_IECreate() _IENavigate($oIE, "https://"&$ipaddress&"/index.html") $oSubmit=_IEGetObjByName($oIE, "vFlash")<----I tried li_T06 $hwnd=_IEPropertyGet($oIE, "hwnd") _IEAction($oSubmit, "focus") ControlSend($hwnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{Enter}") AS WELL AS #include<IE.au3> $oIE=_IECreate() _IENavigate($oIE, "https://"&$ipaddress&"/index.html") Sleep(60000) $oSubmit = _IEGetObjByName ($oIE, "vFlash")<----I tried li_T06 _IEAction ($oSubmit, "click") _IELoadWait ($oIE) Link to comment Share on other sites More sharing options...
DaleHohm Posted June 8, 2010 Share Posted June 8, 2010 (edited) #include<IE.au3> $oIE = _IECreate("https://"&$ipaddress&"/index.html") _IELinkClickByText($oIE, "Flash") Don't make it harder than it needs to be... Dale Edited June 8, 2010 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 Link to comment Share on other sites More sharing options...
byoda Posted June 8, 2010 Author Share Posted June 8, 2010 #include<IE.au3> $oIE = _IECreate("https://"&$ipaddress&"/index.html") _IELinkClickByText($oIE, "Flash") Don't make it harder than it needs to be... Dale Dale, You prob meant "vFlash". Either way, I tried this and it doesnt work. Are there any logs I can check? Once again, no errors, just not being clicked. Does it have anything to do with javascript and frames? Thanks. Link to comment Share on other sites More sharing options...
DaleHohm Posted June 8, 2010 Share Posted June 8, 2010 If what you posted was correct:<A class=tab-text id=li_T06 href="javascript:f_lsnb('T06', 6)">Flash</A>then it most certainly is Flash and not vFlash.SciTe console would should you a No Match error if it doesn't exist in the current window or frame.There are lots of reasons that clicking that link might no do what you expect, be rest assured a link with the text Flash is getting clicked unless you get No Match. further analysis and digging into HTML would be required on your part to see why.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 Link to comment Share on other sites More sharing options...
byoda Posted June 8, 2010 Author Share Posted June 8, 2010 If what you posted was correct:<A class=tab-text id=li_T06 href="javascript:f_lsnb('T06', 6)">Flash</A>then it most certainly is Flash and not vFlash.SciTe console would should you a No Match error if it doesn't exist in the current window or frame.There are lots of reasons that clicking that link might no do what you expect, be rest assured a link with the text Flash is getting clicked unless you get No Match. further analysis and digging into HTML would be required on your part to see why.DaleThanks for the correction and the help. I will try to figure it out. Thanks. Link to comment Share on other sites More sharing options...
byoda Posted June 9, 2010 Author Share Posted June 9, 2010 Thanks for the correction and the help. I will try to figure it out. Thanks.Dale,I think I understand what is going on. The link that I am trying to click is within a frame (lsnb). What would be the best way to call the frame and then click on the vFlash link? Ive researched, but everything deals with forms. Thank you. <frameset frameborder="no" framespacing="0" rows="37,23,*,0"> <frame src="snb.html" name="snb" scrolling="no" frameborder="0" framespacing="0" marginheight="0" marginwidth="0" noresize="noresize" /> <frame src="blank_005.html" name="lsnb" scrolling="no" frameborder="0" framespacing="0" marginheight="0" marginwidth="0" noresize="noresize" /> <frame src="sysSummary.html" name="da" scrolling="auto" frameborder="0" framespacing="0" marginheight="0" marginwidth="0" noresize="noresize" /> <frame scrolling="no" src="blank_005.html" name="hidden_frame" noresize="noresize" marginheight="0" marginwidth="0" frameborder="0" framespacing="0" /> </frameset> Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 9, 2010 Share Posted June 9, 2010 Start from: $oFrame = _IEFrameGetObjByName($oIE, "lsnb") Then use $oFrame vice $oIE for the rest of you efforts to get and click the element. 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 Link to comment Share on other sites More sharing options...
byoda Posted June 9, 2010 Author Share Posted June 9, 2010 Start from: $oFrame = _IEFrameGetObjByName($oIE, "lsnb") Then use $oFrame vice $oIE for the rest of you efforts to get and click the element. Ive been trying different combinations and I think this is right, but still not working. Thanks for your help. $oFrame=_IEFrameGetObjByName($oIE, "lsnb") $oLink=_IEGetObjByName($oFrame, "vFlash") _IEAction($oLink, "click") Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 9, 2010 Share Posted June 9, 2010 Still using _IEErrorHandlerRegister() and running from SciTE? What errors in the console pane? 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 Link to comment Share on other sites More sharing options...
byoda Posted June 9, 2010 Author Share Posted June 9, 2010 Still using _IEErrorHandlerRegister() and running from SciTE? What errors in the console pane? Apologies for the newb code and just now undertanding about the errors in the console panel. Thank you. #include <Date.au3> #include <IE.au3> #include <Constants.au3> #include<Process.au3> ;Global Variables $ipaddress=IniRead("C:\Automation\local_config.ini", "GENERAL", "ipaddress", "NotFound") $username=IniRead("C:\Automation\local_config.ini", "GENERAL", "username", "NotFound") $password=IniRead("C:\Automation\local_config.ini", "GENERAL", "password", "NotFound") $logdate=(@MON & @MDAY & @YEAR & @HOUR & @MIN & @MSEC) $PicName=''&$ipaddress&'-'&$logdate&'' $logdirectory=$logdate ;Logging into iDRAC GUI $oIE=_IECreate() _IENavigate($oIE, "https://"&$ipaddress&"/index.html") _IELinkClickByText($oIE, "Continue to this website (not recommended).") $oHWND = _IEPropertyGet($oIE, "hwnd") WinSetState($oHWND, "", @SW_MAXIMIZE) $oForm = _IEFormGetCollection($oIE, 0) $oName = _IEFormElementGetObjByName($oForm, "user") $oPass = _IEFormElementGetObjByName($oForm, "password") $oSubmit = _IEFormElementGetObjByName($oForm, "btnOK") $hwnd = _IEPropertyGet($oIE, "hwnd") _IEFormElementSetValue($oName, $username) _IEFormElementSetValue($oPass, $password) _IEAction($oSubmit, "focus") ControlSend($hwnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{Enter}") sleep(40000) _IEErrorHandlerRegister() $oFrame=_IEFrameGetObjByName($oIE, "lsnb") $oLink=_IEGetObjByName($oFrame, "vFlash") _IEAction($oLink, "click") >"C:\Program Files\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Automation\javalink.au3" --> IE.au3 V2.4-0 Warning from function _IEFormElementGetObjByName, $_IEStatus_NoMatch --> IE.au3 V2.4-0 Error from function _IEAction, $_IEStatus_InvalidDataType --> IE.au3 V2.4-0 Warning from function _IEGetObjByName, $_IEStatus_NoMatch (Name: vFlash, Index: 0) --> IE.au3 V2.4-0 Error from function _IEAction, $_IEStatus_InvalidDataType >Exit code: 0 Time: 56.465 Link to comment Share on other sites More sharing options...
byoda Posted June 10, 2010 Author Share Posted June 10, 2010 Apologies for the newb code and just now undertanding about the errors in the console panel. Thank you. #include <Date.au3> #include <IE.au3> #include <Constants.au3> #include<Process.au3> ;Global Variables $ipaddress=IniRead("C:\Automation\local_config.ini", "GENERAL", "ipaddress", "NotFound") $username=IniRead("C:\Automation\local_config.ini", "GENERAL", "username", "NotFound") $password=IniRead("C:\Automation\local_config.ini", "GENERAL", "password", "NotFound") $logdate=(@MON & @MDAY & @YEAR & @HOUR & @MIN & @MSEC) $PicName=''&$ipaddress&'-'&$logdate&'' $logdirectory=$logdate ;Logging into iDRAC GUI $oIE=_IECreate() _IENavigate($oIE, "https://"&$ipaddress&"/index.html") _IELinkClickByText($oIE, "Continue to this website (not recommended).") $oHWND = _IEPropertyGet($oIE, "hwnd") WinSetState($oHWND, "", @SW_MAXIMIZE) $oForm = _IEFormGetCollection($oIE, 0) $oName = _IEFormElementGetObjByName($oForm, "user") $oPass = _IEFormElementGetObjByName($oForm, "password") $oSubmit = _IEFormElementGetObjByName($oForm, "btnOK") $hwnd = _IEPropertyGet($oIE, "hwnd") _IEFormElementSetValue($oName, $username) _IEFormElementSetValue($oPass, $password) _IEAction($oSubmit, "focus") ControlSend($hwnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{Enter}") sleep(40000) _IEErrorHandlerRegister() $oFrame=_IEFrameGetObjByName($oIE, "lsnb") $oLink=_IEGetObjByName($oFrame, "vFlash") _IEAction($oLink, "click") >"C:\Program Files\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Automation\javalink.au3" --> IE.au3 V2.4-0 Warning from function _IEFormElementGetObjByName, $_IEStatus_NoMatch --> IE.au3 V2.4-0 Error from function _IEAction, $_IEStatus_InvalidDataType --> IE.au3 V2.4-0 Warning from function _IEGetObjByName, $_IEStatus_NoMatch (Name: vFlash, Index: 0) --> IE.au3 V2.4-0 Error from function _IEAction, $_IEStatus_InvalidDataType >Exit code: 0 Time: 56.465 Could the problem be that there is not action tag for the javascript? Link to comment Share on other sites More sharing options...
DaleHohm Posted June 10, 2010 Share Posted June 10, 2010 Could the problem be that there is not action tag for the javascript?No. Look at the messages in the console... the first one:--> IE.au3 V2.4-0 Warning from function _IEFormElementGetObjByName, $_IEStatus_NoMatchis a warning telling you that your call to _IEFormElementGetObjByName did not match anything on the page (then your subsequent attempt to act on that object resulted in an Invalid Data Type, meaning it was not an object since the previous function did not return one).Address the messages in the order you receive them as they cascade. I suggest using SciTe Debug mode (see my sig) for more info on what lines fail.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 Link to comment Share on other sites More sharing options...
byoda Posted June 10, 2010 Author Share Posted June 10, 2010 Forgot to list the frame code. <frameset rows="0,0,76,*" border="0"> <frame scrolling="no" src="blank_005.html" name="virtual" noresize="noresize" marginheight="0" marginwidth="0" frameborder="0" framespacing="0" /> <frame scrolling="no" src="blank_005.html" name="blank" noresize="noresize" marginheight="0" marginwidth="0" frameborder="0" framespacing="0" /> <frameset cols="128,*" border="0"> <frame src="logo.html" name="logo" scrolling="no" frameborder="0" framespacing="0" noresize="noresize" marginheight="0" marginwidth="0" /> <frame src="globalnav.html" name="globalnav" scrolling="no" frameborder="0" framespacing="0" noresize="noresize" marginheight="0" marginwidth="0" /> </frameset> <!--Need an id so the javascript can get to this element for the pulltab and we need to give it an initial width - REH--> <frameset cols="200,*" frameborder="no" framespacing="0" border="0" id="contentframeset"> <frameset frameborder="no" framespacing="0" rows="60,*"> <frame src="title.html" name="title" scrolling="no" frameborder="0" framespacing="0" marginheight="0" marginwidth="0" noresize="noresize" /> <frame src="treelist.html" name="treelist" scrolling="auto" frameborder="0" framespacing="0" marginheight="0" marginwidth="0" noresize="noresize" /> </frameset> <frameset frameborder="no" framespacing="0" rows="37,23,*,0"> <frame src="snb.html" name="snb" scrolling="no" frameborder="0" framespacing="0" marginheight="0" marginwidth="0" noresize="noresize" /> <frame src="blank_005.html" name="lsnb" scrolling="no" frameborder="0" framespacing="0" marginheight="0" marginwidth="0" noresize="noresize" /> <frame src="sysSummary.html" name="da" scrolling="auto" frameborder="0" framespacing="0" marginheight="0" marginwidth="0" noresize="noresize" /> <frame scrolling="no" src="blank_005.html" name="hidden_frame" noresize="noresize" marginheight="0" marginwidth="0" frameborder="0" framespacing="0" /> </frameset> </frameset> </frameset> Link to comment Share on other sites More sharing options...
byoda Posted June 10, 2010 Author Share Posted June 10, 2010 Thanks Dale, ill keep on trying. Link to comment Share on other sites More sharing options...
DaleHohm Posted June 10, 2010 Share Posted June 10, 2010 Also note that there is an icon in the DebugBar toolbar to the left of the one that looks like an eye that will show you the content in each of the frames. 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 Link to comment Share on other sites More sharing options...
byoda Posted June 10, 2010 Author Share Posted June 10, 2010 I am putting #AutoIt3Wrapper_Run_Debug_Mode=Y on the top of my script and I do not get anymore extra debug output. Any suggestions? Thanks. Link to comment Share on other sites More sharing options...
DaleHohm Posted June 10, 2010 Share Posted June 10, 2010 Don't know what to say... you should get lines like the following to the console: !> Starting in DebugMode.. Line: @error-@extended: Line syntax 0001: 0-0: #AutoIt3Wrapper_Run_Debug_Mode=Y 0002: 0-0: #include <IE.au3> 0004: 0-0: $oIE = _IECreate("http://www.google.es/search?q=comida+china&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:es-ES:official&client=firefox-a") 0005: 0-0: $oMiddle = _IEGetObjById($oIE, "ires") ; div id=ires 0006: 0-0: $oH3s = _IETagNameGetCollection($oMiddle, "h3") ; h3 tags contain the links you want 0007: 0-11: For $oH3 in $oH3s 0008: 0-11: $oA = _IETagnameGetCollection($oH3, "a", 0) ; get reference to the link 0010: 0-1: Next 0008: 0-1: $oA = _IETagnameGetCollection($oH3, "a", 0) ; get reference to the link 0010: 0-1: 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 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