jamesjara Posted March 21, 2011 Share Posted March 21, 2011 Hi all. i am new with this.. i am trying to: 1. open page, click in a element by his value 2. then open a second page , click in element by id But i dont now why sometimes doit sometimes dont This is my code 1. problem with sometimes the clicks works 2. i think if i put iexplorer visibility to 0 , dont work at all expandcollapse popup#include <IE.au3> #NoTrayIcon $oIE=ObjCreate("InternetExplorer.Application.1") $URL = "http://www.deferncom.com/web1" $oIE.Navigate( $URL ) $oIE.Visible=1 $oIE.RegisterAsDropTarget = 1 $oIE.RegisterAsBrowser = 1 With $oIE .Height = "100" .Width = "100" EndWith sleep(5000) $oDivs = _IETagNameGetCollection($oIE, "input") $count = 0; For $oDiv in $oDivs If String($oDiv.value) = "go now" Then If ($count=0) then sleep(100) //sometimes works... _IEAction ($oDiv, "click") //MsgBox to delay the submit of the click MsgBox(0, "", "" ) $count = 1; sleep(10000); $URL2 = "http://www.deferncom.com/page.php?3434" $oIE.Navigate( $URL2 ) sleep(5000) $oDiv2 = _IEGetObjById ($oIE, "like") _IEAction ($oDiv2, "click") MsgBox(0, "", "" ) sleep(10000); EndIf EndIf Next very very thanks 4 your time bless Link to comment Share on other sites More sharing options...
DaleHohm Posted March 22, 2011 Share Posted March 22, 2011 (edited) Well, I would write your code like this: #include <IE.au3> $oIE =_IECreate("http://www.deferncom.com/web1") ;_IEPropertySet($oIE, "height", 100) ;_IEPropertySet($oIE, "width", 100) $oInputs = _IETagNameGetCollection($oIE, "input") For $oInput in $oInputs If String($oInput.value) = "go now" Then _IEAction($oInput, "click") _IELoadWait($oIE) _IENavigate($oIE, "http://www.deferncom.com/page.php?3434") $oDiv2 = _IEGetObjById($oIE, "like") _IEAction($oDiv2, "click") _IELoadWait($oIE) ExitLoop EndIf Next You should not need the Sleeps when you use the _IE functions. I don't see anything on the page in your sample with a value of "go now", so I couldn't take it any further. Dale Edited March 22, 2011 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...
jamesjara Posted March 22, 2011 Author Share Posted March 22, 2011 (edited) thankss @DaleHohm yesterday i read about IELoadWait but ican implement now i can, but always persist a problem the problem is: the IELoadWait cant handle the submit of the click, because always jump to the another page to fast, but if i remove all code less _IEAction($oInput, "click") the click is made. i think is because the html element is ajax '<input type="button" id="u544078_1" onclick="return fbpage_set_fan_status(this, "13159*****87891", 1, 1, null, null, {"preserve_tab":true})" value="Me gusta">' and as you can see the web is facebook. #include <IE.au3> $oIE =_IECreate("http://www.facebook.com/") ;_IEPropertySet($oIE, "height", 100) ;_IEPropertySet($oIE, "width", 100) $oInputs = _IETagNameGetCollection($oIE, "input") For $oInput in $oInputs //in your languaje maybe is I like If String($oInput.value) = "Me gusta" Then _IEAction($oInput, "click") //the click is not made when the next code exist,if i remove next code works. when "me gusta" _IELoadWait($oIE) _IENavigate($oIE, "http://www.facebook.com/photo.php?fbid=") $oDiv2 = _IEGetObjById($oIE, "like") _IEAction($oDiv2, "click") _IELoadWait($oIE) ExitLoop EndIf Next thanks excelent support Edited March 29, 2011 by big_daddy Link to comment Share on other sites More sharing options...
DaleHohm Posted March 22, 2011 Share Posted March 22, 2011 So what happens on the page when you click the button? What you need to do is to wait for some change on the page that indicates that the action associated with the click has completed... perhaps some text is displayed or something changes color - you'll need to figure out how to look for that change before moving on. 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...
jamesjara Posted March 23, 2011 Author Share Posted March 23, 2011 (edited) So what happens on the page when you click the button? What you need to do is to wait for some change on the page that indicates that the action associated with the click has completed... perhaps some text is displayed or something changes color - you'll need to figure out how to look for that change before moving on.Dalego idea, i will tried to capture the change value of the button, and i will tell u what happend Edited March 23, 2011 by jamesjara 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