Chuckero Posted August 4, 2020 Posted August 4, 2020 (edited) Hello, I'm trying to click on a button 'Choose file' in a web page but I couldn't, I already tried a lot of different ways but nothing works. The button in the web is created with this code: 4) Write a text and upload it: <input name="userfile1" type="file" accept=".txt"> In the console I got "invalid argument", but I have no idea what argument is missing. This is a web page I created to test some controls (just create a file and save it in a local drive, like "C:\Temp\TestPage.htm") expandcollapse popup<html><head><meta http-equiv="Content-Type" content="text/html; charset=windows-1252"></head> <body> <h1>WEB DRIVER TEST</h1> <pre></pre> <hr> <div id="InternalTest"> <b>This file provides some objects to test the Web Driver automation</b><br> <br> <i> This is a small text copied from Wikipedia only for this tests.</i> <h1>Virus</h1> <p> A virus is a <a href="https://en.wiktionary.org/wiki/submicroscopic" class="extiw" title="wikt:submicroscopic">submicroscopic</a> <a href="https://en.wiktionary.org/wiki/Infectious_agent" class="mw-redirect" title="Infectious agent">infectious agent</a> agent that replicates only inside the living cells of an organism. Viruses can infect all types of <a href="https://en.wiktionary.org/wiki/Life_forms" class="mw-redirect" title="Life forms">life forms</a>, from animals and plants to microorganisms, including bacteria and archaea.[2] Since Dmitri Ivanovsky's 1892 article describing a non-bacterial pathogen infecting tobacco plants, and the discovery of the tobacco mosaic virus by Martinus Beijerinck in 1898,[3] more than 6,000 virus species have been described in detail,[4] of the millions of types of viruses in the environment.[5] Viruses are found in almost every ecosystem on Earth and are the most numerous type of biological entity.[6][7] The study of viruses is known as virology, a subspeciality of microbiology. </p> <form name="MyForm1" action="InternalTest_Crispware.HTM" enctype="multipart/form-data" method="POST"> <br> <p>1) What is a virus?</p> <input type="radio" name="Option1" value="1">All types of life forms<br> <input type="radio" name="Option2" value="2">A submicroscopic infectious agent<br> <br> <p>More questions about virus</p> 2) When Since Dmitri Ivanovsky described the virues? <input type="number" name="Answer1" size="5"> <br><br> 3) More than how many virus species have been described in detail? <input type="number" name="Answer2" size="5"> <br> <br> 4) Write a text and upload it: <input name="userfile1" type="file" accept=".txt"> <br> <input type="hidden" name="TRS_TYPE" value="2"> <input type="hidden" name="PAGE_SELECT" value="3"> <br> <input type="submit" value="EXECUTE"> </form> </div> </body></html> And this is my AutoIt Code to click on that controls: expandcollapse popupLocal $sRet Local $strURL = "file:///C:/Temp/TestPage.htm" ; TestPage path.. Local Const $CTRL_QUESTION_1 = "//input[@name='Option2']" Local Const $CTRL_QUESTION_2 = "//input[@name='Answer1']" Local Const $CTRL_QUESTION_3 = "//input[@name='Answer2']" Local Const $CTRL_INPUT_FILE_NAME = "//input[@name='userfile1']" Local Const $CTRL_INPUT_FILE_TYPE = "//input[@type='file']" Local Const $CTRL_INPUT_EXECUTE = "//input[@value='EXECUTE']" Local $sElement, $aElements, $sValue, $sButton, $sResponse, $bDecode, $sDecode, $hFileOpen ; Set up and Open Chrome. _WD_Option('Driver', 'chromedriver.exe') _WD_Option('Port', 9515) _WD_Option('DriverParams', '--log-path="' & @ScriptDir & '\chrome.log"') $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true }}}}' _WD_Startup() $sSession = _WD_CreateSession($sDesiredCapabilities) ;Sleep(1000) ; Go to TestPage. _WD_Navigate($sSession, $strURL) ; Click on the second radio in the question 1. --- WORKS! --- ConsoleWrite("-- Answering question 1..." & @CRLF) $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, $CTRL_QUESTION_1) _WD_ElementAction($sSession, $sElement, 'click') MsgBox($MB_OK + $MB_ICONERROR, $strTitle, "Check point 1, $sElement: " & $sElement) ; Fills the question 2. --- WORKS! --- ConsoleWrite("-- Answering question 2..." & @CRLF) $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, $CTRL_QUESTION_2) _WD_ElementAction($sSession, $sElement, 'value', "1892") MsgBox($MB_OK + $MB_ICONERROR, $strTitle, "Check point 2, $sElement: " & $sElement) ; Fills the question 3. --- WORKS! --- ConsoleWrite("-- Answering question 3..." & @CRLF) $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, $CTRL_QUESTION_3) _WD_ElementAction($sSession, $sElement, 'value', "6000") MsgBox($MB_OK + $MB_ICONERROR, $strTitle, "Check point 3, $sElement: " & $sElement) ; Click on the button to load a file, first way. --- DO NOT WORK!!! --- ConsoleWrite("-- Answering question 4, clicking on 'Choose file' button, using @name..." & @CRLF) $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, $CTRL_INPUT_FILE_NAME) $sRet = _WD_ElementAction($sSession, $sElement, 'click') MsgBox($MB_OK + $MB_ICONERROR, $strTitle, "Check point 4, $sElement: " & $sElement) ; Click on the button to load a file, second way. --- DO NOT WORK!!! --- ConsoleWrite("-- Answering question 4, clicking on 'Choose file' button, using @type..." & @CRLF) $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, $CTRL_INPUT_FILE_TYPE) $sRet = _WD_ElementAction($sSession, $sElement, 'click') MsgBox($MB_OK + $MB_ICONERROR, $strTitle, "Check point 4, $sElement: " & $sElement) ; Click on the button 'Execute'. --- WORKS! --- ConsoleWrite("-- Clicking on the button 'Execute', using @value..." & @CRLF) $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, $CTRL_INPUT_EXECUTE) $sRet = _WD_ElementAction($sSession, $sElement, 'click') MsgBox($MB_OK + $MB_ICONERROR, $strTitle, "Check point 5, $sElement: " & $sElement) ; Close Chrome. _WD_DeleteSession($sSession) _WD_Shutdown() This is the result: expandcollapse popup_WD_IsLatestRelease: True _WD_IsLatestRelease ==> Success _WDStartup: OS: WIN_10 WIN32_NT 18362 _WDStartup: AutoIt: 3.3.14.5 _WDStartup: WD.au3: 0.3.0.5 (Up to date) _WDStartup: WinHTTP: 1.6.4.1 (Download latest source at <https://raw.githubusercontent.com/dragana-r/autoit-winhttp/master/WinHttp.au3>) _WDStartup: Driver: chromedriver.exe _WDStartup: Params: --log-path="C:\...\chrome.log" _WDStartup: Port: 9515 __WD_Post: URL=HTTP://127.0.0.1:9515/session; $sData={"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true }}}} __WD_Post: StatusCode=200; ResponseText={"value":{"capabilities":{"acceptInsecureCerts":false,"browserName":"chrome","browserVersion":"84.0.... _WD_CreateSession: {"value":{"capabilities":{"acceptInsecureCerts":false,"browserName":"chrome","browserVersion":"84.0.4147.105","chrome":{"chromedriverVersion":"83.0.4103.39 (ccbf011cb2d2b19b506d844400483861342c20cd-refs/branch-heads/4103@{#416})","userDataDir":"C:\\Users\\gushen\\AppData\\Local\\Temp\\scoped_dir38148_1555801215"},"goog:chromeOptions":{"debuggerAddress":"localhost:52484"},"networkConnectionEnabled":false,"pageLoadStrategy":"normal","platformName":"windows","proxy":{},"setWindowRect":true,"strictFileInteractability":false,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000},"unhandledPromptBehavior":"dismiss and notify","webauthn:virtualAuthenticators":true},"sessionId":"861d2834a29b1388b0bc7c7bb75d56c3"}} __WD_Post: URL=HTTP://127.0.0.1:9515/session/861d2834a29b1388b0bc7c7bb75d56c3/url; $sData={"url":"file:///C:/Temp/TestPage.htm"} __WD_Post: StatusCode=200; ResponseText={"value":null}... _WD_Navigate: {"value":null} -- Answering question 1... __WD_Post: URL=HTTP://127.0.0.1:9515/session/861d2834a29b1388b0bc7c7bb75d56c3/element; $sData={"using":"xpath","value":"//input[@name='Option2']"} __WD_Post: StatusCode=200; ResponseText={"value":{"element-6066-11e4-a52e-4f735466cecf":"213f69fd-791e-4904-ae45-71e7164ac58c"}}... _WD_FindElement: {"value":{"element-6066-11e4-a52e-4f735466cecf":"213f69fd-791e-4904-ae45-71e7164ac58c"}} __WD_Post: URL=HTTP://127.0.0.1:9515/session/861d2834a29b1388b0bc7c7bb75d56c3/element/213f69fd-791e-4904-ae45-71e7164ac58c/click; $sData={"id":"213f69fd-791e-4904-ae45-71e7164ac58c"} __WD_Post: StatusCode=200; ResponseText={"value":null}... _WD_ElementAction: {"value":null}... -- Answering question 2... __WD_Post: URL=HTTP://127.0.0.1:9515/session/861d2834a29b1388b0bc7c7bb75d56c3/element; $sData={"using":"xpath","value":"//input[@name='Answer1']"} __WD_Post: StatusCode=200; ResponseText={"value":{"element-6066-11e4-a52e-4f735466cecf":"a3b631e1-56ea-4d13-9e00-dcfc9fcb2beb"}}... _WD_FindElement: {"value":{"element-6066-11e4-a52e-4f735466cecf":"a3b631e1-56ea-4d13-9e00-dcfc9fcb2beb"}} __WD_Post: URL=HTTP://127.0.0.1:9515/session/861d2834a29b1388b0bc7c7bb75d56c3/element/a3b631e1-56ea-4d13-9e00-dcfc9fcb2beb/value; $sData={"id":"a3b631e1-56ea-4d13-9e00-dcfc9fcb2beb", "text":"1892"} __WD_Post: StatusCode=200; ResponseText={"value":null}... _WD_ElementAction: {"value":null}... -- Answering question 3... __WD_Post: URL=HTTP://127.0.0.1:9515/session/861d2834a29b1388b0bc7c7bb75d56c3/element; $sData={"using":"xpath","value":"//input[@name='Answer2']"} __WD_Post: StatusCode=200; ResponseText={"value":{"element-6066-11e4-a52e-4f735466cecf":"2660c0da-2078-4eea-9777-6af939fbea80"}}... _WD_FindElement: {"value":{"element-6066-11e4-a52e-4f735466cecf":"2660c0da-2078-4eea-9777-6af939fbea80"}} __WD_Post: URL=HTTP://127.0.0.1:9515/session/861d2834a29b1388b0bc7c7bb75d56c3/element/2660c0da-2078-4eea-9777-6af939fbea80/value; $sData={"id":"2660c0da-2078-4eea-9777-6af939fbea80", "text":"6000"} __WD_Post: StatusCode=200; ResponseText={"value":null}... _WD_ElementAction: {"value":null}... -- Answering question 4, clicking on 'Choose file' button, using @name... __WD_Post: URL=HTTP://127.0.0.1:9515/session/861d2834a29b1388b0bc7c7bb75d56c3/element; $sData={"using":"xpath","value":"//input[@name='userfile1']"} __WD_Post: StatusCode=200; ResponseText={"value":{"element-6066-11e4-a52e-4f735466cecf":"73afd77b-04ab-4c32-9d44-643e793404db"}}... _WD_FindElement: {"value":{"element-6066-11e4-a52e-4f735466cecf":"73afd77b-04ab-4c32-9d44-643e793404db"}} __WD_Post: URL=HTTP://127.0.0.1:9515/session/861d2834a29b1388b0bc7c7bb75d56c3/element/73afd77b-04ab-4c32-9d44-643e793404db/click; $sData={"id":"73afd77b-04ab-4c32-9d44-643e793404db"} __WD_Post: StatusCode=400; ResponseText={"value":{"error":"invalid argument","message":"invalid argument\n (Session info: chrome=84.0.4147.... _WD_ElementAction: {"value":{"error":"invalid argument","message":"invalid argument\n (Session info: chrome=84.0.4147.... _WD_ElementAction ==> Webdriver Exception: {"value":{"error":"invalid argument","message":"invalid argument\n (Session info: chrome=84.0.4147.105)","stacktrace":"Backtrace:\n\tOrdinal0 [0x00469563+2725219]\n\tOrdinal0 [0x00368551+1672529]\n\tOrdinal0 [0x00250202+524802]\n\tOrdinal0 [0x001E486D+84077]\n\tOrdinal0 [0x001FAA9D+174749]\n\tOrdinal0 [0x001E41F6+82422]\n\tOrdinal0 [0x001FACE1+175329]\n\tOrdinal0 [0x00203D7C+212348]\n\tOrdinal0 [0x001FA94B+174411]\n\tOrdinal0 [0x001E2528+75048]\n\tOrdinal0 [0x001E35A0+79264]\n\tOrdinal0 [0x001E3539+79161]\n\tOrdinal0 [0x0037D607+1758727]\n\tGetHandleVerifier [0x00586546+1050150]\n\tGetHandleVerifier [0x00586291+1049457]\n\tGetHandleVerifier [0x005910D7+1094071]\n\tGetHandleVerifier [0x00586B46+1051686]\n\tOrdinal0 [0x00375B06+1727238]\n\tOrdinal0 [0x0037EB7B+1764219]\n\tOrdinal0 [0x0037ECE3+1764579]\n\tOrdinal0 [0x00394C05+1854469]\n\tBaseThreadInitThunk [0x75DD6359+25]\n\tRtlGetAppContainerNamedObjectPath [0x77A37B74+228]\n\tRtlGetAppContainerNamedObjectPath [0x77A37B44+180]\n"}} -- Answering question 4, clicking on 'Choose file' button, using @type... __WD_Post: URL=HTTP://127.0.0.1:9515/session/861d2834a29b1388b0bc7c7bb75d56c3/element; $sData={"using":"xpath","value":"//input[@type='file']"} __WD_Post: StatusCode=200; ResponseText={"value":{"element-6066-11e4-a52e-4f735466cecf":"73afd77b-04ab-4c32-9d44-643e793404db"}}... _WD_FindElement: {"value":{"element-6066-11e4-a52e-4f735466cecf":"73afd77b-04ab-4c32-9d44-643e793404db"}} __WD_Post: URL=HTTP://127.0.0.1:9515/session/861d2834a29b1388b0bc7c7bb75d56c3/element/73afd77b-04ab-4c32-9d44-643e793404db/click; $sData={"id":"73afd77b-04ab-4c32-9d44-643e793404db"} __WD_Post: StatusCode=400; ResponseText={"value":{"error":"invalid argument","message":"invalid argument\n (Session info: chrome=84.0.4147.... _WD_ElementAction: {"value":{"error":"invalid argument","message":"invalid argument\n (Session info: chrome=84.0.4147.... _WD_ElementAction ==> Webdriver Exception: {"value":{"error":"invalid argument","message":"invalid argument\n (Session info: chrome=84.0.4147.105)","stacktrace":"Backtrace:\n\tOrdinal0 [0x00469563+2725219]\n\tOrdinal0 [0x00368551+1672529]\n\tOrdinal0 [0x00250202+524802]\n\tOrdinal0 [0x001E486D+84077]\n\tOrdinal0 [0x001FAA9D+174749]\n\tOrdinal0 [0x001E41F6+82422]\n\tOrdinal0 [0x001FACE1+175329]\n\tOrdinal0 [0x00203D7C+212348]\n\tOrdinal0 [0x001FA94B+174411]\n\tOrdinal0 [0x001E2528+75048]\n\tOrdinal0 [0x001E35A0+79264]\n\tOrdinal0 [0x001E3539+79161]\n\tOrdinal0 [0x0037D607+1758727]\n\tGetHandleVerifier [0x00586546+1050150]\n\tGetHandleVerifier [0x00586291+1049457]\n\tGetHandleVerifier [0x005910D7+1094071]\n\tGetHandleVerifier [0x00586B46+1051686]\n\tOrdinal0 [0x00375B06+1727238]\n\tOrdinal0 [0x0037EB7B+1764219]\n\tOrdinal0 [0x0037ECE3+1764579]\n\tOrdinal0 [0x00394C05+1854469]\n\tBaseThreadInitThunk [0x75DD6359+25]\n\tRtlGetAppContainerNamedObjectPath [0x77A37B74+228]\n\tRtlGetAppContainerNamedObjectPath [0x77A37B44+180]\n"}} -- Clicking on the button 'Execute', using @value... __WD_Post: URL=HTTP://127.0.0.1:9515/session/861d2834a29b1388b0bc7c7bb75d56c3/element; $sData={"using":"xpath","value":"//input[@value='EXECUTE']"} __WD_Post: StatusCode=200; ResponseText={"value":{"element-6066-11e4-a52e-4f735466cecf":"1160dced-0198-45e7-a630-9e19a29736de"}}... _WD_FindElement: {"value":{"element-6066-11e4-a52e-4f735466cecf":"1160dced-0198-45e7-a630-9e19a29736de"}} __WD_Post: URL=HTTP://127.0.0.1:9515/session/861d2834a29b1388b0bc7c7bb75d56c3/element/1160dced-0198-45e7-a630-9e19a29736de/click; $sData={"id":"1160dced-0198-45e7-a630-9e19a29736de"} __WD_Post: StatusCode=200; ResponseText={"value":null}... _WD_ElementAction: {"value":null}... __WD_Delete: URL=HTTP://127.0.0.1:9515/session/861d2834a29b1388b0bc7c7bb75d56c3 __WD_Delete: StatusCode=200; ResponseText={"value":null}... _WD_DeleteSession: {"value":null} Any comment are very appreciated! Edited August 4, 2020 by Chuckero
Danp2 Posted August 4, 2020 Author Posted August 4, 2020 Instead of this -- $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, $CTRL_INPUT_FILE_NAME) $sRet = _WD_ElementAction($sSession, $sElement, 'click') try this -- _WD_SelectFiles($sSession, $_WD_LOCATOR_ByXPath, $CTRL_INPUT_FILE_NAME, @ScriptDir & '\chrome.log') Also, you need to update your WinHTTP version (see message in console output) Latest Webdriver UDF Release Webdriver Wiki FAQs
Chuckero Posted August 4, 2020 Posted August 4, 2020 1 hour ago, Danp2 said: Instead of this -- $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, $CTRL_INPUT_FILE_NAME) $sRet = _WD_ElementAction($sSession, $sElement, 'click') try this -- _WD_SelectFiles($sSession, $_WD_LOCATOR_ByXPath, $CTRL_INPUT_FILE_NAME, @ScriptDir & '\chrome.log') It worked perfectly! Thanks @Danp2!!
stephan111 Posted August 5, 2020 Posted August 5, 2020 (edited) _WD_ExecuteScript does not set the correct @error With this code: Local $accountBalanceNew = _WD_ExecuteScript($sSession, "return $.ajax({url:'/?getfile=account_logic',type:'post',dataType: 'text', data:'getaccount=1',success : function(text){return text;}});") ConsoleWrite(@error & @CRLF) ConsoleWrite($_WD_HTTPRESULT & @CRLF) I'm getting this answer if everything is ok: Quote __WD_Post: URL=HTTP://127.0.0.1:4444/session/654a99f2-22fd-4104-b797-d0590aecf0c6/execute/sync; $sData={"script":"return $.ajax({url:'/?getfile=account_logic',type:'post',dataType: 'text', data:'getaccount=1',success : function(text){return text;}});", "args":[]} __WD_Post: StatusCode=200; ResponseText={"value":"<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"UTF-8\">\n<meta name=\"viewpo... _WD_ExecuteScript: {"value":"<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"UTF-8\">\n<meta name=\"viewpo... 0 200 But it HTTP status is 500 @error is still '0' = $_WD_ERROR_Success Quote __WD_Post: URL=HTTP://127.0.0.1:4444/session/654a99f2-22fd-4104-b797-d0590aecf0c6/execute/sync; $sData={"script":"return $.ajax({url:'/?getfile=account_logic',type:'post',dataType: 'text', data:'getaccount=1',success : function(text){return text;}});", "args":[]} __WD_Post: StatusCode=500; ResponseText={"value":{"error":"javascript error","message":"[object Object]","stacktrace":"WebDriverError@chrome... __WD_Post ==> Webdriver Exception: {"value":{"error":"javascript error","message":"[object Object]","stacktrace":"WebDriverError@chrome://marionette/content/error.js:175:5\nJavaScriptError@chrome://marionette/content/error.js:354:5\nevaluate.sandbox/<@chrome://marionette/content/evaluate.js:173:13\n"}} _WD_ExecuteScript: {"value":{"error":"javascript error","message":"[object Object]","stacktrace":"WebDriverError@chrome... _WD_ExecuteScript ==> Webdriver Exception: HTTP status = 500 0 500 Tried it with version 0.3.0.6 and 0.3.0.3 Regards Stephan Edited August 5, 2020 by stephan111
Danp2 Posted August 5, 2020 Author Posted August 5, 2020 (edited) @stephan111 Thanks for the report. I'll take a look to see what's going on. Edit: It worked in my brief testing. Can you provide a short reproducer script that demonstrates the issue? Edited August 5, 2020 by Danp2 Latest Webdriver UDF Release Webdriver Wiki FAQs
stephan111 Posted August 5, 2020 Posted August 5, 2020 (edited) Since version 0.3.0.4 _WD_Shutdown does not close the console anymore. Changelog: Quote Changed (_WD_Shutdown): Allow shutdown of specific module by name or PID Is there something that I have to do additionally to close the console? My shutdown sequence is _WD_DeleteSession($sSession) _WD_Shutdown() Regards Stephan Edited August 5, 2020 by stephan111
stephan111 Posted August 5, 2020 Posted August 5, 2020 22 minutes ago, Danp2 said: @stephan111 Thanks for the report. I'll take a look to see what's going on. This is a log of Chrome: Quote [1596632637.035][INFO]: [1014734fc1e802f19da8948369573e9b] COMMAND ExecuteScript { "args": [ ], "script": "return $.ajax({url:'/?getfile=account_logic',type:'post',dataType: 'text', data:'getaccount=1',success : function(text){return text;}});" } [1596632637.035][INFO]: Waiting for pending navigations... [1596632637.036][INFO]: Done waiting for pending navigations. Status: ok [1596632644.399][INFO]: Waiting for pending navigations... [1596632644.400][INFO]: Done waiting for pending navigations. Status: ok [1596632644.400][INFO]: [1014734fc1e802f19da8948369573e9b] RESPONSE ExecuteScript ERROR javascript error: (Session info: chrome=84.0.4147.105)
Danp2 Posted August 5, 2020 Author Posted August 5, 2020 22 minutes ago, stephan111 said: Since version 0.3.0.4 _WD_Shutdown does not close the console anymore. Sorry, but I can't reproduce this. Does it close properly for you when you run wd_demo? Please post a short, runnable script that we can run for testing. Quote This is a log of Chrome Unfortunately, that doesn't really help in this situation. I need to be able to reproduce the issue in order to fix it. The basic test I ran was to change the DemoScript function in wd_demo.au3 to this -- _WD_ExecuteScript($sSession, "return arguments[0].second;", '{"first": "1st", "second": "2nd", "third": "3rd"}') ConsoleWrite(@error & @CRLF & $_WD_HTTPRESULT & @CRLF) _WD_ExecuteScript($sSession, "dslfkjsdklfj;", '{}') ConsoleWrite(@error & @CRLF & $_WD_HTTPRESULT & @CRLF) and this is the resulting output -- +Running: DemoScript __WD_Post: URL=HTTP://127.0.0.1:9515/session/6afbb5764c2949de44a10cb89c215424/execute/sync; $sData={"script":"return arguments[0].second;", "args":[{"first": "1st", "second": "2nd", "third": "3rd"}]} __WD_Post: StatusCode=200; ResponseText={"value":"2nd"}... _WD_ExecuteScript: {"value":"2nd"}... 0 200 __WD_Post: URL=HTTP://127.0.0.1:9515/session/6afbb5764c2949de44a10cb89c215424/execute/sync; $sData={"script":"dslfkjsdklfj;", "args":[{}]} __WD_Post: StatusCode=500; ResponseText={"value":{"error":"javascript error","message":"javascript error: dslfkjsdklfj is not defined\n (Se... __WD_Post ==> Webdriver Exception: {"value":{"error":"javascript error","message":"javascript error: dslfkjsdklfj is not defined\n (Session info: chrome=84.0.4147.105)","stacktrace":"Backtrace:\n\tOrdinal0 [0x010087E3+2852835]\n\tOrdinal0 [0x00EF5BB1+1727409]\n\tOrdinal0 [0x00DCE4B9+517305]\n\tOrdinal0 [0x00DD040D+525325]\n\tOrdinal0 [0x00DD02FC+525052]\n\tOrdinal0 [0x00DD09BD+526781]\n\tOrdinal0 [0x00D852AF+217775]\n\tOrdinal0 [0x00D7B85D+178269]\n\tOrdinal0 [0x00D84B9C+215964]\n\tOrdinal0 [0x00D7B70B+177931]\n\tOrdinal0 [0x00D62584+75140]\n\tOrdinal0 [0x00D63650+79440]\n\tOrdinal0 [0x00D635E9+79337]\n\tOrdinal0 [0x00F0AD5C+1813852]\n\tGetHandleVerifier [0x0112C616+1075574]\n\tGetHandleVerifier [0x0112C367+1074887]\n\tGetHandleVerifier [0x01137497+1120247]\n\tGetHandleVerifier [0x0112CC16+1077110]\n\tOrdinal0 [0x00F03206+1782278]\n\tOrdinal0 [0x00F0C3BB+1819579]\n\tOrdinal0 [0x00F0C523+1819939]\n\tOrdinal0 [0x00F22B45+1911621]\n\tBaseThreadInitThunk [0x77816359+25]\n\tRtlGetAppContainerNamedObjectPath [0x77947C24+228]\n\tRtlGetAppContainerNamedObjectPath [0x77947BF4+180]\n"}} _WD_ExecuteScript: {"value":{"error":"javascript error","message":"javascript error: dslfkjsdklfj is not defined\n (Se... _WD_ExecuteScript ==> Webdriver Exception: HTTP status = 500 10 500 +Finished: DemoScript Latest Webdriver UDF Release Webdriver Wiki FAQs
stephan111 Posted August 5, 2020 Posted August 5, 2020 11 minutes ago, Danp2 said: +Running: DemoScript __WD_Post: URL=HTTP://127.0.0.1:9515/session/6afbb5764c2949de44a10cb89c215424/execute/sync; $sData={"script":"return arguments[0].second;", "args":[{"first": "1st", "second": "2nd", "third": "3rd"}]} __WD_Post: StatusCode=200; ResponseText={"value":"2nd"}... _WD_ExecuteScript: {"value":"2nd"}... 0 200 __WD_Post: URL=HTTP://127.0.0.1:9515/session/6afbb5764c2949de44a10cb89c215424/execute/sync; $sData={"script":"dslfkjsdklfj;", "args":[{}]} __WD_Post: StatusCode=500; ResponseText={"value":{"error":"javascript error","message":"javascript error: dslfkjsdklfj is not defined\n (Se... __WD_Post ==> Webdriver Exception: {"value":{"error":"javascript error","message":"javascript error: dslfkjsdklfj is not defined\n (Session info: chrome=84.0.4147.105)","stacktrace":"Backtrace:\n\tOrdinal0 [0x010087E3+2852835]\n\tOrdinal0 [0x00EF5BB1+1727409]\n\tOrdinal0 [0x00DCE4B9+517305]\n\tOrdinal0 [0x00DD040D+525325]\n\tOrdinal0 [0x00DD02FC+525052]\n\tOrdinal0 [0x00DD09BD+526781]\n\tOrdinal0 [0x00D852AF+217775]\n\tOrdinal0 [0x00D7B85D+178269]\n\tOrdinal0 [0x00D84B9C+215964]\n\tOrdinal0 [0x00D7B70B+177931]\n\tOrdinal0 [0x00D62584+75140]\n\tOrdinal0 [0x00D63650+79440]\n\tOrdinal0 [0x00D635E9+79337]\n\tOrdinal0 [0x00F0AD5C+1813852]\n\tGetHandleVerifier [0x0112C616+1075574]\n\tGetHandleVerifier [0x0112C367+1074887]\n\tGetHandleVerifier [0x01137497+1120247]\n\tGetHandleVerifier [0x0112CC16+1077110]\n\tOrdinal0 [0x00F03206+1782278]\n\tOrdinal0 [0x00F0C3BB+1819579]\n\tOrdinal0 [0x00F0C523+1819939]\n\tOrdinal0 [0x00F22B45+1911621]\n\tBaseThreadInitThunk [0x77816359+25]\n\tRtlGetAppContainerNamedObjectPath [0x77947C24+228]\n\tRtlGetAppContainerNamedObjectPath [0x77947BF4+180]\n"}} _WD_ExecuteScript: {"value":{"error":"javascript error","message":"javascript error: dslfkjsdklfj is not defined\n (Se... _WD_ExecuteScript ==> Webdriver Exception: HTTP status = 500 10 500 +Finished: DemoScript Same here. Your second test generates an JS error. My problem is that the JS is correct but there is no answer to a ajax request. I think this is the difference.
Danp2 Posted August 5, 2020 Author Posted August 5, 2020 @stephan111 It shouldn't matter AFAICS. Either way, I still need a reproducer script to be able to fix any existing issues. 😉 Latest Webdriver UDF Release Webdriver Wiki FAQs
stephan111 Posted August 5, 2020 Posted August 5, 2020 54 minutes ago, Danp2 said: Sorry, but I can't reproduce this. Does it close properly for you when you run wd_demo? Please post a short, runnable script that we can run for testing. With this code the console window gets closed with version 0.3.0.3 but not with 0.3.0.4 and higher: expandcollapse popup#include <wd_core.au3> #include <wd_helper.au3> #include <GuiComboBoxEx.au3> #include <GUIConstantsEx.au3> Local $sSession, $sDesiredCapabilities SetupChrome() _WD_Startup() If @error <> $_WD_ERROR_Success Then Exit -1 EndIf $sSession = _WD_CreateSession($sDesiredCapabilities) _WD_Window($sSession, 'rect', '{"x":0,"y":0,"width":970,"height":800}') GUICreate("test", 300, 670, 975, 3) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") GUISetState(@SW_SHOW) Opt("GUIOnEventMode", 1) ;/ GUI erzeugen While 1 Sleep(100) WEnd Func SetupChrome() $browser = CheckBrowser('chrome') _WD_Option('Driver', 'driver\chromedriver-' & $browser[0] & '.exe') _WD_Option('Port', 9515) ;_WD_Option('DriverParams', '--verbose') $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "excludeSwitches": ["enable-automation"], "useAutomationExtension": false, "prefs": {"credentials_enable_service": false} }}}}' EndFunc Func CheckBrowser($browser) ;https://www.autoitscript.com/forum/topic/191990-webdriver-udf-w3c-compliant-version-05252020/?do=findComment&comment=1443558 $sPath = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\" & $browser & ".exe", "") ConsoleWrite("Path: " & $sPath & @CRLF) $aBrowserVersion = StringSplit(FileGetVersion($sPath), '.') Dim $return[2] $return[0] = $aBrowserVersion[1] $return[1] = StringReplace($sPath, '\', '\\') Return $return EndFunc Func _Exit() _WD_DeleteSession($sSession) _WD_Shutdown() Exit EndFunc ;==>_Exit
stephan111 Posted August 5, 2020 Posted August 5, 2020 26 minutes ago, Danp2 said: @stephan111 It shouldn't matter AFAICS. Either way, I still need a reproducer script to be able to fix any existing issues. 😉 This code shows the same error: _WD_ExecuteScript($sSession, "return $.ajax({url:'http://hosting105782.a2f0c.netcup.net/test.php',type:'post',dataType: 'text', data:'getaccount=1',success : function(text){return text;}});") Quote __WD_Post: URL=HTTP://127.0.0.1:9515/session/5559e6c83543c57b260bfa037d278abc/execute/sync; $sData={"script":"return $.ajax({url:'http://hosting105782.a2f0c.netcup.net/test.php',type:'post',dataType: 'text', data:'getaccount=1',success : function(text){return text;}});", "args":[]} __WD_Post: StatusCode=500; ResponseText={"value":{"error":"javascript error","message":"javascript error: \n (Session info: chrome=84.0.414... __WD_Post ==> Webdriver Exception: {"value":{"error":"javascript error","message":"javascript error: \n (Session info: chrome=84.0.4147.105)","stacktrace":"Backtrace:\n\tOrdinal0 [0x012887E3+2852835]\n\tOrdinal0 [0x01175BB1+1727409]\n\tOrdinal0 [0x0104E4B9+517305]\n\tOrdinal0 [0x0105040D+525325]\n\tOrdinal0 [0x010502FC+525052]\n\tOrdinal0 [0x010509BD+526781]\n\tOrdinal0 [0x010052AF+217775]\n\tOrdinal0 [0x00FFB85D+178269]\n\tOrdinal0 [0x01004B9C+215964]\n\tOrdinal0 [0x00FFB70B+177931]\n\tOrdinal0 [0x00FE2584+75140]\n\tOrdinal0 [0x00FE3650+79440]\n\tOrdinal0 [0x00FE35E9+79337]\n\tOrdinal0 [0x0118AD5C+1813852]\n\tGetHandleVerifier [0x013AC616+1075574]\n\tGetHandleVerifier [0x013AC367+1074887]\n\tGetHandleVerifier [0x013B7497+1120247]\n\tGetHandleVerifier [0x013ACC16+1077110]\n\tOrdinal0 [0x01183206+1782278]\n\tOrdinal0 [0x0118C3BB+1819579]\n\tOrdinal0 [0x0118C523+1819939]\n\tOrdinal0 [0x011A2B45+1911621]\n\tBaseThreadInitThunk [0x7681EE1C+18]\n\tRtlInitializeExceptionChain [0x773C37EB+239]\n\tRtlInitializeExceptionChain [0x773C37BE+194]\n"}} _WD_ExecuteScript: {"value":{"error":"javascript error","message":"javascript error: \n (Session info: chrome=84.0.414... _WD_ExecuteScript ==> Webdriver Exception: HTTP status = 500 0 500
Danp2 Posted August 5, 2020 Author Posted August 5, 2020 1 minute ago, stephan111 said: This code shows the same error: Right... so I don't understand why you are receiving @error of 0 instead of 10. When I run that code, I get this output -- __WD_Post: URL=HTTP://127.0.0.1:9515/session/b3271cb0501780b6fb1608c340f1322f/execute/sync; $sData={"script":"return $.ajax({url:'http://hosting105782.a2f0c.netcup.net/test.php',type:'post',dataType: 'text', data:'getaccount=1',success : function(text){return text;}});", "args":[]} __WD_Post: StatusCode=500; ResponseText={"value":{"error":"javascript error","message":"javascript error: $ is not defined\n (Session info:... __WD_Post ==> Webdriver Exception: {"value":{"error":"javascript error","message":"javascript error: $ is not defined\n (Session info: chrome=84.0.4147.105)","stacktrace":"Backtrace:\n\tOrdinal0 [0x010087E3+2852835]\n\tOrdinal0 [0x00EF5BB1+1727409]\n\tOrdinal0 [0x00DCE4B9+517305]\n\tOrdinal0 [0x00DD040D+525325]\n\tOrdinal0 [0x00DD02FC+525052]\n\tOrdinal0 [0x00DD09BD+526781]\n\tOrdinal0 [0x00D852AF+217775]\n\tOrdinal0 [0x00D7B85D+178269]\n\tOrdinal0 [0x00D84B9C+215964]\n\tOrdinal0 [0x00D7B70B+177931]\n\tOrdinal0 [0x00D62584+75140]\n\tOrdinal0 [0x00D63650+79440]\n\tOrdinal0 [0x00D635E9+79337]\n\tOrdinal0 [0x00F0AD5C+1813852]\n\tGetHandleVerifier [0x0112C616+1075574]\n\tGetHandleVerifier [0x0112C367+1074887]\n\tGetHandleVerifier [0x01137497+1120247]\n\tGetHandleVerifier [0x0112CC16+1077110]\n\tOrdinal0 [0x00F03206+1782278]\n\tOrdinal0 [0x00F0C3BB+1819579]\n\tOrdinal0 [0x00F0C523+1819939]\n\tOrdinal0 [0x00F22B45+1911621]\n\tBaseThreadInitThunk [0x77816359+25]\n\tRtlGetAppContainerNamedObjectPath [0x77947C24+228]\n\tRtlGetAppContainerNamedObjectPath [0x77947BF4+180]\n"}} _WD_ExecuteScript: {"value":{"error":"javascript error","message":"javascript error: $ is not defined\n (Session info:... _WD_ExecuteScript ==> Webdriver Exception: HTTP status = 500 10 500 Are you sure you tested with v0.3.0.6? This release from yesterday did correct an issue with error codes not being properly returned. If you still think this is an issue, please provide the following -- A short, but complete "reproducer" script that I can run to observe the issue The full resulting output from Scite showing your execution of this same code Latest Webdriver UDF Release Webdriver Wiki FAQs
Danp2 Posted August 5, 2020 Author Posted August 5, 2020 41 minutes ago, stephan111 said: With this code the console window gets closed with version 0.3.0.3 but not with 0.3.0.4 and higher Ok... I found the issue and a fix will be in the next release. In the interim, you can change the line -- $aProcessList = ProcessList($vDriver) to $aProcessList = ProcessList($sFile) Latest Webdriver UDF Release Webdriver Wiki FAQs
stephan111 Posted August 5, 2020 Posted August 5, 2020 Works. Thank you very much. It's a pleasure to have a support like yours. Regards Stephan 28 minutes ago, Danp2 said: Ok... I found the issue and a fix will be in the next release. In the interim, you can change the line -- $aProcessList = ProcessList($vDriver) to $aProcessList = ProcessList($sFile)
Chris2 Posted August 7, 2020 Posted August 7, 2020 (edited) On 8/4/2020 at 2:43 PM, Danp2 said: Check the Scite console output for errors. FWIW, I find no matching element for this xpath -- //span[@class='RveJvd snByac'] Lots of people complaining about this same issue online. One known workaround is to use your existing profile instead of allowing chromedriver to create a new one. See the Wiki FAQ for details on how to do this. @Danp2 Thanks a lot. The workaround works! The matching element was wrong. Completly right. Edited August 7, 2020 by Chris2 Danp2 1
seadoggie01 Posted August 10, 2020 Posted August 10, 2020 Is there a way to get the UDF to print the console debugged info to a log? I'm going to be using this for a script that won't be on my computer, so it would be nice to see the debug info if needed All my code provided is Public Domain... but it may not work. Use it, change it, break it, whatever you want. Spoiler My Humble Contributions:Personal Function Documentation - A personal HelpFile for your functionsAcro.au3 UDF - Automating Acrobat ProToDo Finder - Find #ToDo: lines in your scriptsUI-SimpleWrappers UDF - Use UI Automation more Simply-erKeePass UDF - Automate KeePass, a password managerInputBoxes - Simple Input boxes for various variable types
Danp2 Posted August 10, 2020 Author Posted August 10, 2020 @seadoggie01 Not currently, but that would make a nice enhancement. 🙂 Seems like it would be simpler to implement if the calling routine was responsible for opening / closing the log file. It could provide a file handle, which would then be used by the UDF. Thoughts? Latest Webdriver UDF Release Webdriver Wiki FAQs
seadoggie01 Posted August 10, 2020 Posted August 10, 2020 (edited) You mean because then you wouldn't need to use OnAutoItExitRegister to close the log file handle(s)? I started thinking about wrapping my program in another to capture the console and print it to a log... The problem is that I normally print data to the console and save it to write to a log at the end, which would separate anything I print from anything you print 🙂 Also, I'm correct in saying it's not possible to capture your own console output, right? Edited August 10, 2020 by seadoggie01 All my code provided is Public Domain... but it may not work. Use it, change it, break it, whatever you want. Spoiler My Humble Contributions:Personal Function Documentation - A personal HelpFile for your functionsAcro.au3 UDF - Automating Acrobat ProToDo Finder - Find #ToDo: lines in your scriptsUI-SimpleWrappers UDF - Use UI Automation more Simply-erKeePass UDF - Automate KeePass, a password managerInputBoxes - Simple Input boxes for various variable types
Danp2 Posted August 10, 2020 Author Posted August 10, 2020 Actually, you should be able to capture the output yourself by capturing the STDOUT stream. Latest Webdriver UDF Release Webdriver Wiki FAQs
Recommended Posts