jaja714 Posted February 14, 2017 Posted February 14, 2017 I'm trying to click on specific "hidden" fields on a web page and I've installed debugbar (as per Click a button in a webpage - Started by Mithrandir, February 15, 2010 ) to narrow it down but I'm not quite sure how to convert the info from debugbar to the appropriate IE calls. I just want to click here and then enter in some data. Document HTML BODY Div class=urlconverter DIV id=stepConvert DIV class=urlconverter-section-1 DIV class=container DIV class=urlconverter-section-left-1 DIV class=class=container DIV class=urlconverter-section-1-1 DIV class=row DIV class=col-sm-12 UL class=urlconverted-section=1=1=form LI INPUT id=target
Subz Posted February 14, 2017 Posted February 14, 2017 Try something like this: #include <IE.au3> Local $oIE = _IECreate('http://yui.github.io/yui2/docs/yui_2.9.0_full/examples/button/btn_example05.html', 1) Local $oInputs = _IETagNameGetCollection($oIE, "input") For $oInput In $oInputs If $oInput.id = "firstname" Then _IEFormElementSetValue($oInput, "John") If $oInput.id = "lastname" Then _IEFormElementSetValue($oInput, "Doe") Next
jaja714 Posted February 14, 2017 Author Posted February 14, 2017 There are 50 items that match that and many of them have blank .ids. I can never know I am at the one I need. Now, I kind of have it working with this: $colLinks = _IETagNameGetCollection($oIE, 'div') For $oLink In $colLinks If $oLink.className() = 'urlconverter-section-1-title' Then $x = _IEPropertyGet($oLink, 'screenx') $y = _IEPropertyGet($oLink, 'screeny') writelog($x,$y) MouseClick("",$x+20,$y+50) Send($url) Sleep(2000) Send("{ENTER}") EndIf Next but, admittedly, it is rather crude and prone to error. ps I haven't even gotten to the "hard" part yet!
Subz Posted February 14, 2017 Posted February 14, 2017 Did you try my example? I'm not sure why you're targeting a div rather than an Input button, each button has to have a unique id/name. Do you have a URL that we can test?
jaja714 Posted February 15, 2017 Author Posted February 15, 2017 2 hours ago, jaja714 said: There are 50 items that match that and many of them have blank .ids. I can never know I am at the one I need. yes, I tried your example.
jaja714 Posted February 15, 2017 Author Posted February 15, 2017 2 hours ago, Subz said: Do you have a URL that we can test? https://www.onlinevideoconverter.com/video-converter
Subz Posted February 15, 2017 Posted February 15, 2017 #include <IE.au3> Local $oIE = _IECreate('https://www.onlinevideoconverter.com/video-converter', 1) ;~ Add URL Local $oInputs = _IETagNameGetCollection($oIE, 'input') For $oInput In $oInputs If $oInput.id = 'texturl' Then _IEFormElementSetValue($oInput, 'https://www.youtube.com/watch?v=uMK0prafzw0') Next ;~ Click Start Button Local $oInputs = _IETagNameGetCollection($oIE, 'a') For $oInput In $oInputs If $oInput.id = 'convert1' Then _IEAction($oInput, 'Click') Next jaja714 1
jdelaney Posted February 15, 2017 Posted February 15, 2017 (edited) You can use my signature to return an array of matching dom objects based on a xpath...if you find that the _IE functions to get specific enough to find your object. Edited February 15, 2017 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
jaja714 Posted February 21, 2017 Author Posted February 21, 2017 (edited) Ah, thanks to both jd and Subz (and Dale Holm too) for the info as I was able to make quite a bit of progress here. I have a skeleton working but I have a sleep statement I'd like to replace. So, when I call _IECreate, _IELoadWait is implied. However, when I click on a button that loads a new page or redirects to another url, how do I "wait" for that task to complete before proceeding with my next step? I tried putting _IELoadWait but that doesn't work. If I don't put that SLEEP statement in there, the whole script fails later with "The requested action with this object has failed" on the $oInput.href reference. Even with the SLEEP statement, I get the occasional "The requested action with this object has failed" but I'm sure increasing the SLEEP time will solve that. Before I do that ... how can I code so that I don't have to rely on that SLEEP statement? expandcollapse popupFunc dl($url,$dest) _IEErrorNotify(True) writelog($url,$dest) If FileExists($dest) Then Return $oIE = _IECreate('https://www.onlinevideoconverter.com/video-converter') ;~ Add URL $oInputs = _IETagNameGetCollection($oIE, 'input') For $oInput In $oInputs If $oInput.id = 'texturl' Then _IEFormElementSetValue($oInput, $url) EndIf Next Sleep(2000) ;~ Click Start Button $oInputs = _IETagNameGetCollection($oIE, 'a') For $oInput In $oInputs ; writelog('id',$oInput.id) If $oInput.id = 'convert1' Then _IEAction($oInput, 'Click') _IELoadWait($oIE) EndIf Next SLEEP(10000) While True ;~ Download file $oInputs = _IETagNameGetCollection($oIE, 'a') If @error = 0 Then If IsObj($oInput) Then For $oInput In $oInputs writelog('ID',$oInput.ID) If StringInStr($oInput.href,'onlinevideoconverter.com/download?file=') Then InetGet($oInput.href, $dest,0,1) _IEQuit($oIE) Return EndIf Next EndIf Else writelog('@error',@error) EndIf sleep(500) WEnd EndFunc Edited February 22, 2017 by jaja714
Subz Posted February 21, 2017 Posted February 21, 2017 What I have found is try and use IECreate with attach or IEAttach so it doesn't create new instances helps. You could use something like While _IEPropertyGet($oIE, 'Busy') Sleep(50) Wend Or look for something else on the page in the page properties to see when to move to the next action. Hope that helps. jaja714 1
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