patrickso Posted January 6, 2020 Posted January 6, 2020 Hi! I'm very new to AutoIT and just learning now. I'd like to know the basics of running a test on a web browser using chrome and IE. Can you help with the following? - I can see files au3 are being shared and im assuming these are helper scripts that says "include", do i copy them the where the "include" folder is of my my AutoIT folder alone? - Where do I put the chromedriver? - Do you have a sample code I can use to get me started in testing web using chrome and IE? I have installed beta version of AutoIT, I have the editor available, downloaded the wd_core, WinHttp, Json..but not really sure where to go from there. Can you please help? thank you very much in advance
crazycrash Posted January 6, 2020 Posted January 6, 2020 Wow, fantastic! Your function works super well with everything I tested so far. However it also returns success with something like this: _WD_DownloadFile("http://www.google.com/notexisting.jpg", @ScriptDir & "\testimage.jpg") I'll be away for a week, but will definitely give another update later on. Thanks!
Danp2 Posted January 6, 2020 Author Posted January 6, 2020 (edited) @crazycrash Thanks for the testing. I'll look to see why it is returning the wrong value. Edited January 6, 2020 by Danp2 Latest Webdriver UDF Release Webdriver Wiki FAQs
Danp2 Posted January 6, 2020 Author Posted January 6, 2020 HI @patrickso, Take a look at this wiki page that @water is creating -- https://www.autoitscript.com/wiki/WebDriver Then jump over to this thread and give any feedback / suggestions -- Latest Webdriver UDF Release Webdriver Wiki FAQs
J-Luc Posted January 6, 2020 Posted January 6, 2020 On 12/27/2019 at 4:08 PM, Danp2 said: Please update to the latest source available from here on Github and then retest your script. Just back from vacations, so first thanks for your quick feedback, and happy new year ! I downloaded the 1.6.4.2 version of WinHTTP.au3 and unfortunatelly get the same result and outputs... Is there any way to increase debug messages (especially on the gecko driver) to dig into the issue ?
Danp2 Posted January 6, 2020 Author Posted January 6, 2020 (edited) @J-Luc Please post the contents of the geckodriver console window. Edit: Also might be helpful to repost the output from Scite. Edited January 6, 2020 by Danp2 Latest Webdriver UDF Release Webdriver Wiki FAQs
J-Luc Posted January 6, 2020 Posted January 6, 2020 Well, forget about my request. In fact, after reviewing my environment and UDF, I realized that I was not using the proper JSON UDF ! The vacation break and rest was definitively usefull. Thanks for help !
crazycrash Posted January 7, 2020 Posted January 7, 2020 It returns success because it simply downloads the error page of the file not found and saves it as a jpg. So in a way it works correct, not sure if it should be changed. This wont happen if everything is used properly. The function returns failiure if the url is not reachable as it should.
Danp2 Posted January 7, 2020 Author Posted January 7, 2020 @crazycrash Yeah... I already fixed it earlier today. However, it requires a minor change to one of the WinHttp functions. Waiting to see if @trancexx accepts my PR. 🙂 Latest Webdriver UDF Release Webdriver Wiki FAQs
ngocthang26 Posted January 8, 2020 Posted January 8, 2020 Hi Danp2, I want hide cmd run chromedriver When i see line code but i don't find any function config ? var driverService = ChromeDriverService.CreateDefaultService(); driverService.HideCommandPromptWindow = true; var driver = new ChromeDriver(driverService, new ChromeOptions()); You can suggest help me. Thanks
Danp2 Posted January 8, 2020 Author Posted January 8, 2020 @ngocthang26 That looks like Selenium coding, which wouldn't be applicable here. I've just added the answer to your question in the Webdriver wiki entry, which can be found here. ngocthang26 1 Latest Webdriver UDF Release Webdriver Wiki FAQs
ngocthang26 Posted January 8, 2020 Posted January 8, 2020 (edited) 3 hours ago, Danp2 said: @ngocthang26 That looks like Selenium coding, which wouldn't be applicable here. I've just added the answer to your question in the Webdriver wiki entry, which can be found here. thanks, working.. P/s: I use -headless hide browser but so slow code. I try suggest in google search but don't improve. You can other method hide browser ? const chromeOptions = new chrome.Options();//.headless(); chromeOptions.addArguments("--headless"); chromeOptions.addArguments("--proxy-server='direct://'"); chromeOptions.addArguments("--proxy-bypass-list=*"); chromeOptions.addArguments("window-size=1024,1324"); chromeOptions.addArguments("--blink-settings=imagesEnabled=false"); Edited January 8, 2020 by ngocthang26
Danp2 Posted January 8, 2020 Author Posted January 8, 2020 2 hours ago, ngocthang26 said: I use -headless hide browser but so slow code. I try suggest in google search but don't improve. You can other method hide browser ? Hard to say since you haven't shown us any of your Autoit code. 😏 Latest Webdriver UDF Release Webdriver Wiki FAQs
crazycrash Posted January 11, 2020 Posted January 11, 2020 I would personally prefer for the path to be created in the _WD_DownloadFile function if it doesn't exist. I believe this would be the case for most applications. Local $hFile = FileOpen($sDest, 18 + $FO_CREATEPATH ) Cheers
Danp2 Posted January 11, 2020 Author Posted January 11, 2020 @crazycrash IMO, we aren't dealing with "most applications" here. We're dealing with a scripting / developer tool. As such, I would expect the person writing the script to take care of creating the destination directory before calling the function. Also, have you checked to see if this is how other Autoit functions behave? FWIW, I tested InetGet, and it didn't create the missing directory. Latest Webdriver UDF Release Webdriver Wiki FAQs
chrisgreece Posted January 12, 2020 Posted January 12, 2020 (edited) First of all i have to thank you for this great UDF! I just discovered it while i was trying to do some little project of mine in chrome and has been really useful! I have a question though if you have the time to help me out i would really appreciate it! I am playing with the demo and the actions and i have reached a certain point but i can not go any further for some reason This is the code i have written so far (which is just an alternation in your demo.au3) expandcollapse popupLocal $sElement, $aElements, $sValue, $sButton, $sResponse, $bDecode, $sDecode, $hFileOpen _WD_Navigate($sSession, "https://tws.ydt/") $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, $sElementSelector) $oERect = _WD_ElementAction($sSession, $sElement, 'rect') ConsoleWrite("Element Coords = " & $oERect.Item('x') & " / " & $oERect.Item('y') & " / " & $oERect.Item('width') & " / " & $oERect.Item('height') & @CRLF) Local Const $sStartElement = "//a[@id='proceed-link']" _WD_ElementAction($sSession, $sElement, $sElementSelector) ; Click search button $sButton = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, $sElementSelector) _WD_ElementAction($sSession, $sButton, 'click') _WD_LoadWait($sSession, 2000) $aButton = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, $sStartElement) _WD_ElementAction($sSession, $aButton, 'click') _WD_LoadWait($sSession, 2000) Local Const $id = "//input[@id='username']" $cButton = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, $id) _WD_ElementAction($sSession, $cButton, 'click') _WD_ElementAction($sSession, $cButton, 'value', "288076") _WD_LoadWait($sSession, 0) Local Const $psw = "//input[@id='password']" $dButton = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, $psw) _WD_ElementAction($sSession, $dButton, 'click') _WD_ElementAction($sSession, $dButton, 'value', "**************") _WD_LoadWait($sSession, 0) Local Const $login = "//input[@id='button']" $btnlogin = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, $login) _WD_ElementAction($sSession, $btnlogin, 'click') _WD_LoadWait($sSession, 0) _WD_Navigate($sSession, "https://tws.ydt/roster/nas.jsp") Local Const $radio = "//input[@id='j_idt32:_1']" $radio1 = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, $radio) _WD_ElementAction($sSession, $radio1, 'click') _WD_LoadWait($sSession, 0) Local Const $radiobtn = "//button[@id='selectButton']" $radiobtn1 = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, $radiobtn) _WD_ElementAction($sSession, $radiobtn1, 'click') _WD_LoadWait($sSession, 2000) sleep (2000) ///So far all good; It works beautifully Now below is where i encounter some problem and its more of a javascript problem rathen than autoit's or the udf's but i was wondering if you could help me out Local Const $span = "//[@id='minuteOutput']" $span1 = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, $span) _WD_ElementAction($sSession, $dButton, 'value', "10") ///This is a timer which, when it reaches zero it goes back to the end, i am trying to manipulate that so it stays at 10 but i cant locate ;the ///object :( _WD_LoadWait($sSession, 0) local $sStrategy, $sSelector, $dStartElement , $dultiple $dStartElement = Default $dMultiple = Default $sElement = _WD_FindElement($sSession,$sStrategy, $sSelector, $dStartElement, $dMultiple) /// And this one i am using to find an element to click on the page but the output is that the element is not found :/ ///The first element i am trying to change and i cant locate is this <span id="minuteOutput" style="font-weight: bold; color: rgb(32, 68, 223);">9</span> ///The second element is <a onclick="submitForm('form',0,{source:'j_idt152'});return false;" class="xi" href="#">Φύλλα Υπηρεσίας</a> /// which i tried using like the class for calling it but i just cant figured it out! Again i guess my question is really stupid but i am really ///struggling to figure it out otherwise i wouldnt bother! If you could point me to a direction i'd be really satisfied! Found Solution! $sText="Φύλλα Υπηρεσίας" _WD_LinkClickByText($sSession, $sText, $lPartial = Default) Edited January 12, 2020 by chrisgreece Found Solution!!!
chrisgreece Posted January 12, 2020 Posted January 12, 2020 Also an other question ,if i may. In the form there is an other button which i get in the console of Chrome by writing in the console var result = document.getElementsByClassName("x7j")[4].innerHTML; console.log(result); The result is "Δημιουργία νέου ΦΥ" which i want to click But when i go to autoit and i type Local Const $Create = "//button[@class='x7j[4]']" _WD_ElementAction($sSession, $Create, 'click') _WD_LoadWait($sSession, 2000) the output is this __WD_Post: URL=HTTP://127.0.0.1:9515/session/6339368ffe703b9d78b33239acadef15/element///button[@class='x7j[4]']/click; $sData={"id":"//button[@class='x7j[4]']"} __WD_Post: StatusCode=404; ResponseText={"value":{"error":"unknown command","message":"unknown command: unknown command: session/6339368ffe703b9d78b33239acadef15/element///button%5B@class='x7j%5B4%5D'%5D/click","stacktrace":"Backtrace:\n\tOrdinal0 [0x012CA113+1548563]\n\tOrdinal0 [0x0124DDA1+1039777]\n\tOrdinal0 [0x011CE485+517253]\n\tOrdinal0 [0x01177E44+163396]\n\tOrdinal0 [0x01177CAA+162986]\n\tOrdinal0 [0x0115221E+8734]\n\tOrdinal0 [0x01152606+9734]\n\tOrdinal0 [0x01152C80+11392]\n\tOrdinal0 [0x012671B7+1143223]\n\tGetHandleVerifier [0x01362B46+507814]\n\tGetHandleVerifier [0x01362864+507076]\n\tGetHandleVerifier [0x01369F47+537511]\n\tGetHandleVerifier [0x01363402+510050]\n\tOrdinal0 [0x0125F29C+1110684]\n\tOrdinal0 [0x0115204E+8270]\n\tOrdinal0 [0x01151D99+7577]\n\tGetHandleVerifier [0x015FDE3C+3240604]\n\tBaseThreadInitThunk [0x75E5338A+18]\n\tRtlInitializeExceptionChain [0x77E49902+99]\n\tRtlInitializeExceptionChain [0x77E498D5+54]\n"}} _WD_ElementAction: {"value":{"error":"unknown command","message":"unknown command: unknown command: session/6339368ffe7... _WD_ElementAction ==> Webdriver Exception: {"value":{"error":"unknown command","message":"unknown command: unknown command: session/6339368ffe703b9d78b33239acadef15/element///button%5B@class='x7j%5B4%5D'%5D/click","stacktrace":"Backtrace:\n\tOrdinal0 [0x012CA113+1548563]\n\tOrdinal0 [0x0124DDA1+1039777]\n\tOrdinal0 [0x011CE485+517253]\n\tOrdinal0 [0x01177E44+163396]\n\tOrdinal0 [0x01177CAA+162986]\n\tOrdinal0 [0x0115221E+8734]\n\tOrdinal0 [0x01152606+9734]\n\tOrdinal0 [0x01152C80+11392]\n\tOrdinal0 [0x012671B7+1143223]\n\tGetHandleVerifier [0x01362B46+507814]\n\tGetHandleVerifier [0x01362864+507076]\n\tGetHandleVerifier [0x01369F47+537511]\n\tGetHandleVerifier [0x01363402+510050]\n\tOrdinal0 [0x0125F29C+1110684]\n\tOrdinal0 [0x0115204E+8270]\n\tOrdinal0 [0x01151D99+7577]\n\tGetHandleVerifier [0x015FDE3C+3240604]\n\tBaseThreadInitThunk [0x75E5338A+18]\n\tRtlInitializeExceptionChain [0x77E49902+99]\n\tRtlInitializeExceptionChain [0x77E498D5+54]\n"}} __WD_Post: URL=HTTP://127.0.0.1:9515/session/6339368ffe703b9d78b33239acadef15/execute/sync; $sData={"script":"return document.readyState", "args":[]} __WD_Post: StatusCode=200; ResponseText={"value":"complete"} _WD_ExecuteScript: {"value":"complete"} I also tried like that Local Const $Create = "//button[@class='x7j']" _WD_ElementAction($sSession, $Create, 'click') _WD_LoadWait($sSession, 2000) and also by text but nothing seems to work $bText="Δημιουργία νέου ΦΥ" _WD_LinkClickByText($sSession, $bText, $lPartial = Default) _WD_LoadWait($sSession, 2000) Sleep (2000) The element is this <button type="button" onclick="submitForm('form',0,{source:'fyllaYpiresiasTable:j_idt315'});return false;" class="x7j">Δημιουργία νέου ΦΥ</button>
Danp2 Posted January 12, 2020 Author Posted January 12, 2020 @chrisgreece You can't pass an xpath to _WD_ElementAction. You need to call _WD_FindElement first, and then pass it's result to _WD_ElementAction. A good example of this is the code for _WD_LinkClickByText. 20 minutes ago, chrisgreece said: _WD_LinkClickByText($sSession, $bText, $lPartial = Default) Not sure if this is part of your issue, but this isn't the correct way to pass an optional parameter. Either exclude it all together, ie -- _WD_LinkClickByText($sSession, $bText) or pass an appropriate value to override the default value of True -- _WD_LinkClickByText($sSession, $bText, False) Latest Webdriver UDF Release Webdriver Wiki FAQs
chrisgreece Posted January 12, 2020 Posted January 12, 2020 Thank you for your prompt reply. I did try that but unfortunately still could not find the element so i used Imagesearch for that button instead. May i ask something that confuses me! Before on the previous inputs i was able to pass on some values. But right now after having used imagesearch and logged on to the form i want to pass values on it doesnt recognise the inputs . Is it because i used imagesearch and so the "$sSession" is stuck right before that? Here is the form i want to pass the values to. I tried this Local Const $InputCTG = "//input[@id='katigoria_input']" $InputCTG1 = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, $InputCTG) _WD_ElementAction($sSession, $InputCTG1, 'value', "ΗΜΕΡΗΣΙΑ ΑΝΑΠΑΥΣΗ") _WD_LoadWait($sSession, 0) and the output is that __WD_Post: URL=HTTP://127.0.0.1:9515/session/43be6e67c6ade1419a71caede4566f55/element; $sData={"using":"xpath","value":"//input[@id='katigoria_input']"} __WD_Post: StatusCode=404; ResponseText={"value":{"error":"no such element","message":"no such element: Unable to locate element: {\"method\":\"xpath\",\"selector\":\"//input[@id='katigoria_input']\"}\n (Session info: chrome=79.0.3945.117)","stacktrace":"Backtrace:\n\tOrdinal0 [0x00DFA113+1548563]\n\tOrdinal0 [0x00D7DDA1+1039777]\n\tOrdinal0 [0x00CFE485+517253]\n\tOrdinal0 [0x00C98539+99641]\n\tOrdinal0 [0x00CB3BB0+211888]\n\tOrdinal0 [0x00CA97B0+169904]\n\tOrdinal0 [0x00CB2594+206228]\n\tOrdinal0 [0x00CA95FB+169467]\n\tOrdinal0 [0x00C9160A+71178]\n\tOrdinal0 [0x00C92690+75408]\n\tOrdinal0 [0x00C92629+75305]\n\tOrdinal0 [0x00D971B7+1143223]\n\tGetHandleVerifier [0x00E92B46+507814]\n\tGetHandleVerifier [0x00E92864+507076]\n\tGetHandleVerifier [0x00E99F47+537511]\n\tGetHandleVerifier [0x00E93402+510050]\n\tOrdinal0 [0x00D8F29C+1110684]\n\tOrdinal0 [0x00D9938B+1151883]\n\tOrdinal0 [0x00D994F3+1152243]\n\tOrdinal0 [0x00D983F5+1147893]\n\tBaseThreadInitThunk [0x75E5338A+18]\n\tRtlInitializeExceptionChain [0x77E49902+99]\n\tRtlInitializeExceptionChain [0x77E498D5+54]\n"}} _WD_FindElement: {"value":{"error":"no such element","message":"no such element: Unable to locate element: {\"method\":\"xpath\",\"selector\":\"//input[@id='katigoria_input']\"}\n (Session info: chrome=79.0.3945.117)","stacktrace":"Backtrace:\n\tOrdinal0 [0x00DFA113+1548563]\n\tOrdinal0 [0x00D7DDA1+1039777]\n\tOrdinal0 [0x00CFE485+517253]\n\tOrdinal0 [0x00C98539+99641]\n\tOrdinal0 [0x00CB3BB0+211888]\n\tOrdinal0 [0x00CA97B0+169904]\n\tOrdinal0 [0x00CB2594+206228]\n\tOrdinal0 [0x00CA95FB+169467]\n\tOrdinal0 [0x00C9160A+71178]\n\tOrdinal0 [0x00C92690+75408]\n\tOrdinal0 [0x00C92629+75305]\n\tOrdinal0 [0x00D971B7+1143223]\n\tGetHandleVerifier [0x00E92B46+507814]\n\tGetHandleVerifier [0x00E92864+507076]\n\tGetHandleVerifier [0x00E99F47+537511]\n\tGetHandleVerifier [0x00E93402+510050]\n\tOrdinal0 [0x00D8F29C+1110684]\n\tOrdinal0 [0x00D9938B+1151883]\n\tOrdinal0 [0x00D994F3+1152243]\n\tOrdinal0 [0x00D983F5+1147893]\n\tBaseThreadInitThunk [0x75E5338A+18]\n\tRtlInitializeExceptionChain [0x77E49902+99]\n\tRtlInitializeExceptionChain [0x77E498D5+54]\n"}} _WD_FindElement ==> No match: HTTP status = 404 __WD_Post: URL=HTTP://127.0.0.1:9515/session/43be6e67c6ade1419a71caede4566f55/element//value; $sData={"id":"", "text":"ȌƑȓʁ ԇ"} __WD_Post: StatusCode=404; ResponseText={"value":{"error":"no such element","message":"no such element: Element_id length is invalid\n (Session info: chrome=79.0.3945.117)","stacktrace":"Backtrace:\n\tOrdinal0 [0x00DFA113+1548563]\n\tOrdinal0 [0x00D7DDA1+1039777]\n\tOrdinal0 [0x00CFE485+517253]\n\tOrdinal0 [0x00C97E61+97889]\n\tOrdinal0 [0x00C94AD0+84688]\n\tOrdinal0 [0x00CA977D+169853]\n\tOrdinal0 [0x00C931E6+78310]\n\tOrdinal0 [0x00CA9991+170385]\n\tOrdinal0 [0x00CB2594+206228]\n\tOrdinal0 [0x00CA95FB+169467]\n\tOrdinal0 [0x00C9160A+71178]\n\tOrdinal0 [0x00C92690+75408]\n\tOrdinal0 [0x00C92629+75305]\n\tOrdinal0 [0x00D971B7+1143223]\n\tGetHandleVerifier [0x00E92B46+507814]\n\tGetHandleVerifier [0x00E92864+507076]\n\tGetHandleVerifier [0x00E99F47+537511]\n\tGetHandleVerifier [0x00E93402+510050]\n\tOrdinal0 [0x00D8F29C+1110684]\n\tOrdinal0 [0x00D9938B+1151883]\n\tOrdinal0 [0x00D994F3+1152243]\n\tOrdinal0 [0x00D983F5+1147893]\n\tBaseThreadInitThunk [0x75E5338A+18]\n\tRtlInitializeExceptionChain [0x77E49902+99]\n\tRtlInitializeExceptionChain [0x77E498D5+54]\n"}} _WD_ElementAction: {"value":{"error":"no such element","message":"no such element: Element_id length is invalid\n (Ses... _WD_ElementAction ==> Webdriver Exception: {"value":{"error":"no such element","message":"no such element: Element_id length is invalid\n (Session info: chrome=79.0.3945.117)","stacktrace":"Backtrace:\n\tOrdinal0 [0x00DFA113+1548563]\n\tOrdinal0 [0x00D7DDA1+1039777]\n\tOrdinal0 [0x00CFE485+517253]\n\tOrdinal0 [0x00C97E61+97889]\n\tOrdinal0 [0x00C94AD0+84688]\n\tOrdinal0 [0x00CA977D+169853]\n\tOrdinal0 [0x00C931E6+78310]\n\tOrdinal0 [0x00CA9991+170385]\n\tOrdinal0 [0x00CB2594+206228]\n\tOrdinal0 [0x00CA95FB+169467]\n\tOrdinal0 [0x00C9160A+71178]\n\tOrdinal0 [0x00C92690+75408]\n\tOrdinal0 [0x00C92629+75305]\n\tOrdinal0 [0x00D971B7+1143223]\n\tGetHandleVerifier [0x00E92B46+507814]\n\tGetHandleVerifier [0x00E92864+507076]\n\tGetHandleVerifier [0x00E99F47+537511]\n\tGetHandleVerifier [0x00E93402+510050]\n\tOrdinal0 [0x00D8F29C+1110684]\n\tOrdinal0 [0x00D9938B+1151883]\n\tOrdinal0 [0x00D994F3+1152243]\n\tOrdinal0 [0x00D983F5+1147893]\n\tBaseThreadInitThunk [0x75E5338A+18]\n\tRtlInitializeExceptionChain [0x77E49902+99]\n\tRtlInitializeExceptionChain [0x77E498D5+54]\n"}} __WD_Post: URL=HTTP://127.0.0.1:9515/session/43be6e67c6ade1419a71caede4566f55/execute/sync; $sData={"script":"return document.readyState", "args":[]} __WD_Post: StatusCode=200; ResponseText={"value":"complete"} _WD_ExecuteScript: {"value":"complete"} Although the html Attribute is this <input id="katigoria_input" name="katigoria_input" type="text" class="ui-autocomplete-input ui-inputfield ui-widget ui-state-default ui-corner-all" autocomplete="off" value="" size="40" onkeyup="toUpperGreek(this);" role="textbox" aria-disabled="false" aria-readonly="false" aria-multiline="false"> <span id="katigoria" class="ui-autocomplete"><input id="katigoria_input" name="katigoria_input" type="text" class="ui-autocomplete-input ui-inputfield ui-widget ui-state-default ui-corner-all" autocomplete="off" value="" size="40" onkeyup="toUpperGreek(this);" role="textbox" aria-disabled="false" aria-readonly="false" aria-multiline="false"><input id="katigoria_hinput" name="katigoria_hinput" type="hidden" autocomplete="off"></span> //And also this is on the span (i have tried also as id "katigoria_hinput" but still no luck) Thank you for your time!~!!!
Danp2 Posted January 12, 2020 Author Posted January 12, 2020 @chrisgreece I can't access the site, so it's difficult to know why the element isn't being found. Have you checked to see if the site uses frames? Latest Webdriver UDF Release Webdriver Wiki FAQs
Recommended Posts