dangkhoa9xset Posted July 1, 2017 Share Posted July 1, 2017 Hello, I'm trying to fill objects like in the page below in code but it has written in PHP language and WordPess source. It doesn't work right, it just fills above the textbox and when I click on other objects the text has gone away. Help me fill it and choose the item in the combo box, please! Here is my AutoIt code #include <FF V0.6.0.1b-15.au3> $sURL = "https://www.grammarly.com/signup?breadcrumbs=true&install=true" _FFConnect() If _FFIsConnected() Then _FFOpenURL($sURL) $sInput = _FFObjGet("_60f178-field", "class") ; returns a string - no object! _FFObj($sInput, "value", "autoit") ;_FFSetValue("mmmmmm", "txtName", "id") Else MsgBox(0,"Error:", "Can't connnect to FireFox") EndIf Here is PHP code <input type="name" data-qa="txtName" maxlength="100" class="_60f178-field" value=""> Link to comment Share on other sites More sharing options...
Danp2 Posted July 2, 2017 Share Posted July 2, 2017 The React library wraps the input element to encapsulate it and it appears to monitor for the keypress event. I played around with this over the last day or so and finally came up with what I believe is a working solution -- #include <FF V0.6.0.1b-15.au3> $sURL = "https://www.grammarly.com/signup?breadcrumbs=true&install=true" _FFConnect() If _FFIsConnected() Then _FFOpenURL($sURL) $sInput = _FFObjGet("_60f178-field", "class") ; returns a string - no object! If @error = $_FF_ERROR_Success Then _FFSendReact($sInput, "autoit") EndIf Else MsgBox(0,"Error:", "Can't connnect to FireFox") EndIf Func _FFSendReact($sElement, $sValue = "") If StringLeft($sElement, 7) = "OBJECT|" Then $sElement = StringMid($sElement, 8) If StringLeft($sElement, 1) = "." Then $sElement = "window.content.document" & $sElement _FFCmd('FFau3.sendReact=function sendReact(a,b){try{var c=FFau3.WCD.createEvent("KeyboardEvent");for (var i = 0, len = b.length; i < len; i++) {c.initKeyEvent("keypress",true,true,null,false,false,false,false,b.charCodeAt(i),b.charCodeAt(i));a.dispatchEvent(c);};return 1}catch(e){return-1}return 0};') _FFCmd("FFau3.sendReact(" & $sElement & ",'" & $sValue & "');") EndFunc dangkhoa9xset 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
dangkhoa9xset Posted July 4, 2017 Author Share Posted July 4, 2017 It works perfectly! thanks, sir. One two things: 1. How I choose another field because of the same class? 2. What I have to do to select a combo box? I'm a newbie, please help me. Thanks a lot. Link to comment Share on other sites More sharing options...
dangkhoa9xset Posted July 4, 2017 Author Share Posted July 4, 2017 (edited) $sInput0 = _FFObjGet("_60f178-field","class",0) ; returns a string - no object! $sInput1 = _FFObjGet("_60f178-field","class",1) $sInput2 = _FFObjGet("_60f178-field","class",2) If @error = $_FF_ERROR_Success Then _FFSendReact($sInput0, "autoit") _FFSendReact($sInput1, "autoit@gmail.com") _FFSendReact($sInput2, "autoit") EndIf I have done the first requirement but I can't send "." character. Edited July 4, 2017 by dangkhoa9xset Link to comment Share on other sites More sharing options...
Danp2 Posted July 4, 2017 Share Posted July 4, 2017 Please keep the discussion on the open forum so that everyone can potentially help / benefit. Quote Please help me Danp2, I can't send "." character and help me select the combo box, I'm a newbie $sInput0 = _FFObjGet("_60f178-field","class",0) ; returns a string - no object! $sInput1 = _FFObjGet("_60f178-field","class",1) $sInput2 = _FFObjGet("_60f178-field","class",2) If @error = $_FF_ERROR_Success Then _FFSendReact($sInput0, "autoit") _FFSendReact($sInput1, "autoit@gmail.com") _FFSendReact($sInput2, "autoit") dangkhoa9xset 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Danp2 Posted July 4, 2017 Share Posted July 4, 2017 I don't know why the period isn't being sent successfully. Perhaps there's a better way to implement this code. <shrug> dangkhoa9xset 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
dangkhoa9xset Posted July 5, 2017 Author Share Posted July 5, 2017 (edited) anyone help me send "." to these fields? please Edited July 5, 2017 by dangkhoa9xset Link to comment Share on other sites More sharing options...
Danp2 Posted July 5, 2017 Share Posted July 5, 2017 The issue is that the charCode <> keyCode for certain characters such as comma and period, so the posted solution doesn't work as-is. I have an idea for an alternate solution, but haven't worked out all of the details of implementation. dangkhoa9xset 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Danp2 Posted July 6, 2017 Share Posted July 6, 2017 It's a hack, but you can try this revised version -- Func _FFSendReact($sElement, $sValue = "") If StringLeft($sElement, 7) = "OBJECT|" Then $sElement = StringMid($sElement, 8) If StringLeft($sElement, 1) = "." Then $sElement = "window.content.document" & $sElement _FFCmd('FFau3.sendReact=function sendReact(a,b){try{var c=FFau3.WCD.createEvent("KeyboardEvent");c.initKeyEvent("keypress",true,true,null,false,false,false,false,008,008);a.value=b.concat(".");a.dispatchEvent(c);return 1}catch(e){return-1}return 0};') _FFCmd("FFau3.sendReact(" & $sElement & ",'" & $sValue & "');") EndFunc dangkhoa9xset 1 Latest Webdriver UDF Release Webdriver Wiki FAQs 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