jrumbaug Posted March 18, 2015 Share Posted March 18, 2015 I'm puzzled. I can find the elements and have confirmed the names. But the values do not change with this script. ;;;; go through new screen and insert ID & BIRTH Local $cID = "00401889792" Local $cBirthDate = "07/21/2004" $oForms = _IEFormGetCollection ($oIE ) For $oForm In $oForms $oElements = _IEFormElementGetCollection ($oForm) For $oElement IN $oElements If $oElement.name = "txtMemberId" Then _IEFormElementSetValue( $oElement , $cID ) $oElement.value = $cID ; redundant attempt to assign value MsgBox(1, "found ID",@error ) ; pops up and confirms name found EndIf If $oElement.name = "txtDob" Then _IEFormElementSetValue( $oElement , $cBirthDate ) EndIf Next Next Is there a better way to assign a new value?? Thank in advance Jim Rumbaugh Link to comment Share on other sites More sharing options...
DougShields Posted March 18, 2015 Share Posted March 18, 2015 Your code works fine for me using the "q" element on Google. Check the return code, @error, and @extended from _IEFormElementSetValue() to see if it believes it was successful or why not. You might also add a call to _IEFormElementGetValue for debugging purposes. In the what-else-to-look-for bin I would check for any other properties, events, JavaScript, etc. attached to the field that might be messing things up. E.g. an onchange or onclick event could be changing what you set #include <IE.au3> $oIE = _IECreate("https://www.google.com", 1) $cID = "00401889792" $oForms = _IEFormGetCollection($oIE) For $oForm In $oForms $oElements = _IEFormElementGetCollection($oForm) For $oElement In $oElements If $oElement.name = "q" Then $rc = _IEFormElementSetValue($oElement, $cID) MsgBox(0, "Result", $rc & ", " & @error & ", " & @extended & ", " & _IEFormElementGetValue($oElement)) EndIf Next Next Link to comment Share on other sites More sharing options...
Scriptonize Posted March 18, 2015 Share Posted March 18, 2015 (edited) Sometimes webpages play tricks with you Maybe this approach will work for you.;textfield edit_250 (Connection name or number) $hInpBox = _IEGetObjByName($oIE,"account_name") _IEAction($hInpBox,"focus") _IEFormElementSetValue($hInpBox,$sConName) Edited March 18, 2015 by Scriptonize If you learn from It, it's not a mistake Link to comment Share on other sites More sharing options...
sherkas Posted March 19, 2015 Share Posted March 19, 2015 Ive found several issues lately where some (as mentioned above) require a focus, input added, and then a blur event called. Link to comment Share on other sites More sharing options...
Solution jrumbaug Posted April 1, 2015 Author Solution Share Posted April 1, 2015 I solved my problem. It was a mistake on my part. (kinda). Even though the fields were found, the fields were found in the wrong form. The form I needed was in a frame. My code was sending the values to a form on the main page. This works: $oFrame = _IEFrameGetCollection($oIE, 0) $oForms = _IEFormGetCollection ($oFrame ) For $oForm In $oForms $oElements = _IEFormElementGetCollection ($oForm) For $oElement IN $oElements If $oElement.name = "txtMemberId" Then $oElement.value = $cID EndIf If $oElement.name = "txtDob" Then $oElement.value = $cBirthDate EndIf Next Next How I found the error: I checked for the value of the variable before I re-assigned it. When it reported some unexpected value I new I was pulling data from the wrong spot. Thank you all for help Jim Rumbaugh 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