
Holycow
Members-
Posts
7 -
Joined
-
Last visited
Everything posted by Holycow
-
WebDriver UDF (W3C compliant version) - 2024/09/21
Holycow replied to Danp2's topic in AutoIt Example Scripts
@Danp2 OK thank you Dan -
WebDriver UDF (W3C compliant version) - 2024/09/21
Holycow replied to Danp2's topic in AutoIt Example Scripts
@Danp2 I tried DanyLarson's code for html table extraction. I am having problem with this line getting the count of the header cells. $aElements = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, $BaseElement & "/tbody/tr[1]/td", "", True) $ColNumber = UBound($aElements) The $ColNumber returns zero count. However, the next lines return all the cell counts. $aElements = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, $BaseElement & "/tbody/tr/td", "", True) $CellNumber = UBound($aElements) Could you please take a look to see why with restriction to the first row, "tr[1]/td", does not return any array count....Thanks -
WebDriver UDF (W3C compliant version) - 2024/09/21
Holycow replied to Danp2's topic in AutoIt Example Scripts
@danp123 Thank you Dan, your change made it work now. Let me try to understand your code to see how you got this working. I appreciate for your help. Please do let me know if you have the library functions updated and I will download a new copy. -
WebDriver UDF (W3C compliant version) - 2024/09/21
Holycow replied to Danp2's topic in AutoIt Example Scripts
@Danp2 I tried again with your 1st advice, take a look a the partial log attached. nothing works after close because the session id is no longer valid. and any following command would require a valid session id. #include <Constants.au3> #include "wd_core.au3" #include "wd_helper.au3" Local $sDesiredCapabilities, $sSession SetupChrome() _WD_Startup() $sSession = _WD_CreateSession($sDesiredCapabilities) _WD_Navigate($sSession, "https://www.nbcnews.com/") $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//*[@id='content']/div/div[5]/div/div/div[2]/div/section/div[2]/div/div[1]/article/div[2]/h2/a/span") _WD_ElementAction($sSession, $sElement, 'click') Sleep(3000) _WD_NewTab($sSession) _WD_Navigate($sSession, "http://yahoo.com") Sleep(3000) _WD_Attach($sSession, "nbcnews.com", "URL") Sleep(3000) _WD_Attach($sSession, "yahoo.com", "URL") Sleep(1000) ConsoleWrite("about to close tab" & @CRLF) _WD_Window($sSession,"close") ;close tab ConsoleWrite("about to attach" & @CRLF) Sleep(3000) _WD_Attach($sSession, "nbcnews.com", "URL") Sleep(3000) $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//*[@id='hfs-header']/nav/div[2]/div[3]/div[1]/ul/li[1]/a") _WD_ElementAction($sSession, $sElement, 'click') Func SetupChrome() _WD_Option('Driver', 'C:\Users\Tri Tran\Documents\ChromeDriver\chromedriver.exe') _WD_Option('Port', 9515) _WD_Option('DriverParams', '--log-path="' & @ScriptDir & '\chrome.log"') $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":[' & """user-data-dir=C:\\ChromeAutoProfile""," & " ""disable-infobars""" & "" & '] }}}}' EndFunc ;------------------------------------------------------------------------------ _WD_Action: {"value":"https://www.yahoo.com/"} about to close tab __WD_Delete: URL=HTTP://127.0.0.1:9515/session/4a796e89537021ae025f57665f5375e0/window __WD_Delete: StatusCode=200; ResponseText={"value":["CDwindow-19B82533A363BBD2AC3A3D7FFA71BF7E"]} _WD_Window: {"value":["CDwindow-19B82533A363BBD2AC3A3D7FFA71BF7E"]}... about to attach __WD_Get: URL=HTTP://127.0.0.1:9515/session/4a796e89537021ae025f57665f5375e0/window __WD_Get: StatusCode=404; $iResult = 0; $sResponseText={"value":{"error":"no such window","message":"target window already closed\nfrom unknown error: web ... _WD_Window: {"value":{"error":"no such window","message":"target window already closed\nfrom unknown error: web ... _WD_Window ==> Webdriver Exception: HTTP status = 404 _WD_Attach ==> General Error __WD_Post: URL=HTTP://127.0.0.1:9515/session/4a796e89537021ae025f57665f5375e0/element; $sData={"using":"xpath","value":"//*[@id='hfs-header']/nav/div[2]/div[3]/div[1]/ul/li[1]/a"} __WD_Post: StatusCode=404; ResponseText={"value":{"error":"no such window","message":"target window already closed\nfrom unknown error: web view not found\n (Session info: chrome=75.0.3770.100)","stacktrace":"Backtrace:\n\tOrdinal0 [0x00963C43+1457219]\n\tOrdinal0 [0x008DC471+902257]\n\tOrdinal0 [0x0087D54F+513359]\n\tOrdinal0 [0x0086DA68+449128]\n\tOrdinal0 [0x0082FF2D+196397]\n\tOrdinal0 [0x00837446+226374]\n\tOrdinal0 [0x0082F4AB+193707]\n\tOrdinal0 [0x00814160+82272]\n\tOrdinal0 [0x008156E6+87782]\n\tOrdinal0 [0x008155F0+87536]\n\tGetHandleVerifier [0x00ACC781+1305121]\n\tGetHandleVerifier [0x00A14B0E+552366]\n\tGetHandleVerifier [0x00A149D6+552054]\n\tOrdinal0 [0x00971FA7+1515431]\n\tGetHandleVerifier [0x00A15036+553686]\n\tOrdinal0 [0x008F300F+995343]\n\tOrdinal0 [0x008FF65B+1046107]\n\tOrdinal0 [0x008FF7AA+1046442]\n\tOrdinal0 [0x008FE7C5+1042373]\n\tBaseThreadInitThunk [0x76396359+25]\n\tRtlGetAppContainerNamedObjectPath [0x77947A94+228]\n\tRtlGetAppContainerNamedObjectPath [0x77947A64+180]\n"}} _WD_FindElement: {"value":{"error":"no such window","message":"target window already closed\nfrom unknown error: web view not found\n (Session info: chrome=75.0.3770.100)","stacktrace":"Backtrace:\n\tOrdinal0 [0x00963C43+1457219]\n\tOrdinal0 [0x008DC471+902257]\n\tOrdinal0 [0x0087D54F+513359]\n\tOrdinal0 [0x0086DA68+449128]\n\tOrdinal0 [0x0082FF2D+196397]\n\tOrdinal0 [0x00837446+226374]\n\tOrdinal0 [0x0082F4AB+193707]\n\tOrdinal0 [0x00814160+82272]\n\tOrdinal0 [0x008156E6+87782]\n\tOrdinal0 [0x008155F0+87536]\n\tGetHandleVerifier [0x00ACC781+1305121]\n\tGetHandleVerifier [0x00A14B0E+552366]\n\tGetHandleVerifier [0x00A149D6+552054]\n\tOrdinal0 [0x00971FA7+1515431]\n\tGetHandleVerifier [0x00A15036+553686]\n\tOrdinal0 [0x008F300F+995343]\n\tOrdinal0 [0x008FF65B+1046107]\n\tOrdinal0 [0x008FF7AA+1046442]\n\tOrdinal0 [0x008FE7C5+1042373]\n\tBaseThreadInitThunk [0x76396359+25]\n\tRtlGetAppContainerNamedObjectPath [0x77947A94+228]\n\tRtlGetAppContainerNamedObjectPath [0x77947A64+180]\n"}} _WD_FindElement ==> Webdriver Exception: HTTP status = 404 __WD_Post: URL=HTTP://127.0.0.1:9515/session/4a796e89537021ae025f57665f5375e0/element//click; $sData={"id":""} __WD_Post: StatusCode=404; ResponseText={"value":{"error":"no such window","message":"target window already closed\nfrom unknown error: web view not found\n (Session info: chrome=75.0.3770.100)","stacktrace":"Backtrace:\n\tOrdinal0 [0x00963C43+1457219]\n\tOrdinal0 [0x008DC471+902257]\n\tOrdinal0 [0x0087D54F+513359]\n\tOrdinal0 [0x0086DA68+449128]\n\tOrdinal0 [0x0082FF2D+196397]\n\tOrdinal0 [0x00837446+226374]\n\tOrdinal0 [0x0082F4AB+193707]\n\tOrdinal0 [0x00814160+82272]\n\tOrdinal0 [0x008156E6+87782]\n\tOrdinal0 [0x008155F0+87536]\n\tGetHandleVerifier [0x00ACC781+1305121]\n\tGetHandleVerifier [0x00A14B0E+552366]\n\tGetHandleVerifier [0x00A149D6+552054]\n\tOrdinal0 [0x00971FA7+1515431]\n\tGetHandleVerifier [0x00A15036+553686]\n\tOrdinal0 [0x008F300F+995343]\n\tOrdinal0 [0x008FF65B+1046107]\n\tOrdinal0 [0x008FF7AA+1046442]\n\tOrdinal0 [0x008FE7C5+1042373]\n\tBaseThreadInitThunk [0x76396359+25]\n\tRtlGetAppContainerNamedObjectPath [0x77947A94+228]\n\tRtlGetAppContainerNamedObjectPath [0x77947A64+180]\n"}} _WD_ElementAction: {"value":{"error":"no such window","message":"target window already closed\nfrom unknown error: web ... _WD_ElementAction ==> Webdriver Exception: {"value":{"error":"no such window","message":"target window already closed\nfrom unknown error: web view not found\n (Session info: chrome=75.0.3770.100)","stacktrace":"Backtrace:\n\tOrdinal0 [0x00963C43+1457219]\n\tOrdinal0 [0x008DC471+902257]\n\tOrdinal0 [0x0087D54F+513359]\n\tOrdinal0 [0x0086DA68+449128]\n\tOrdinal0 [0x0082FF2D+196397]\n\tOrdinal0 [0x00837446+226374]\n\tOrdinal0 [0x0082F4AB+193707]\n\tOrdinal0 [0x00814160+82272]\n\tOrdinal0 [0x008156E6+87782]\n\tOrdinal0 [0x008155F0+87536]\n\tGetHandleVerifier [0x00ACC781+1305121]\n\tGetHandleVerifier [0x00A14B0E+552366]\n\tGetHandleVerifier [0x00A149D6+552054]\n\tOrdinal0 [0x00971FA7+1515431]\n\tGetHandleVerifier [0x00A15036+553686]\n\tOrdinal0 [0x008F300F+995343]\n\tOrdinal0 [0x008FF65B+1046107]\n\tOrdinal0 [0x008FF7AA+1046442]\n\tOrdinal0 [0x008FE7C5+1042373]\n\tBaseThreadInitThunk [0x76396359+25]\n\tRtlGetAppContainerNamedObjectPath [0x77947A94+228]\n\tRtlGetAppContainerNamedObjectPath [0x77947A64+180]\n"}} +>13:26:41 AutoIt3.exe ended.rc:0 +>13:26:41 AutoIt3Wrapper Finished. >Exit code: 0 Time: 33.12 -
WebDriver UDF (W3C compliant version) - 2024/09/21
Holycow replied to Danp2's topic in AutoIt Example Scripts
#include <Constants.au3> #include "wd_core.au3" #include "wd_helper.au3" Local $sDesiredCapabilities, $sSession SetupChrome() _WD_Startup() $sSession = _WD_CreateSession($sDesiredCapabilities) _WD_Navigate($sSession, "https://www.nbcnews.com/") $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//*[@id='content']/div/div[5]/div/div/div[2]/div/section/div[2]/div/div[1]/article/div[2]/h2/a/span") _WD_ElementAction($sSession, $sElement, 'click') Sleep(3000) _WD_NewTab($sSession) _WD_Navigate($sSession, "http://yahoo.com") Sleep(3000) _WD_Attach($sSession, "nbcnews.com", "URL") Sleep(3000) _WD_Attach($sSession, "yahoo.com", "URL") Sleep(1000) _WD_Window($sSession,"close") ;close tab Sleep(3000) ;these following lines will longer work, but if they're moved above _WD_Window($sSession,"close"), they work OK $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//*[@id='hfs-header']/nav/div[2]/div[3]/div[1]/ul/li[1]/a") _WD_ElementAction($sSession, $sElement, 'click') Func SetupChrome() _WD_Option('Driver', 'C:\Users\Tri Tran\Documents\ChromeDriver\chromedriver.exe') _WD_Option('Port', 9515) _WD_Option('DriverParams', '--log-path="' & @ScriptDir & '\chrome.log"') $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":[' & """user-data-dir=C:\\ChromeAutoProfile""," & " ""disable-infobars""" & "" & '] }}}}' EndFunc ;------partial log--------------------------------------------------------------------- __WD_Get: StatusCode=200; $iResult = 0; $sResponseText={"value":"https://www.yahoo.com/"}... _WD_Action: {"value":"https://www.yahoo.com/"} __WD_Delete: URL=HTTP://127.0.0.1:9515/session/09ae64ce672ad64e4454647c9a4e27fe/window __WD_Delete: StatusCode=200; ResponseText={"value":["CDwindow-9E1340F16BF28DDB2E2911BDE2B2720A"]} _WD_Window: {"value":["CDwindow-9E1340F16BF28DDB2E2911BDE2B2720A"]}... __WD_Post: URL=HTTP://127.0.0.1:9515/session/09ae64ce672ad64e4454647c9a4e27fe/element; $sData={"using":"xpath","value":"//*[@id='hfs-header']/nav/div[2]/div[3]/div[1]/ul/li[1]/a"} __WD_Post: StatusCode=404; ResponseText={"value":{"error":"no such window","message":"target window already closed\nfrom unknown error: web view not found\n (Session info: chrome=75.0.3770.100)","stacktrace":"Backtrace:\n\tOrdinal0 [0x00963C43+1457219]\n\tOrdinal0 [0x008DC471+902257]\n\tOrdinal0 [0x0087D54F+513359]\n\tOrdinal0 [0x0086DA68+449128]\n\tOrdinal0 [0x0082FF2D+196397]\n\tOrdinal0 [0x00837446+226374]\n\tOrdinal0 [0x0082F4AB+193707]\n\tOrdinal0 [0x00814160+82272]\n\tOrdinal0 [0x008156E6+87782]\n\tOrdinal0 [0x008155F0+87536]\n\tGetHandleVerifier [0x00ACC781+1305121]\n\tGetHandleVerifier [0x00A14B0E+552366]\n\tGetHandleVerifier [0x00A149D6+552054]\n\tOrdinal0 [0x00971FA7+1515431]\n\tGetHandleVerifier [0x00A15036+553686]\n\tOrdinal0 [0x008F300F+995343]\n\tOrdinal0 [0x008FF65B+1046107]\n\tOrdinal0 [0x008FF7AA+1046442]\n\tOrdinal0 [0x008FE7C5+1042373]\n\tBaseThreadInitThunk [0x76396359+25]\n\tRtlGetAppContainerNamedObjectPath [0x77947A94+228]\n\tRtlGetAppContainerNamedObjectPath [0x77947A64+180]\n"}} _WD_FindElement: {"value":{"error":"no such window","message":"target window already closed\nfrom unknown error: web view not found\n (Session info: chrome=75.0.3770.100)","stacktrace":"Backtrace:\n\tOrdinal0 [0x00963C43+1457219]\n\tOrdinal0 [0x008DC471+902257]\n\tOrdinal0 [0x0087D54F+513359]\n\tOrdinal0 [0x0086DA68+449128]\n\tOrdinal0 [0x0082FF2D+196397]\n\tOrdinal0 [0x00837446+226374]\n\tOrdinal0 [0x0082F4AB+193707]\n\tOrdinal0 [0x00814160+82272]\n\tOrdinal0 [0x008156E6+87782]\n\tOrdinal0 [0x008155F0+87536]\n\tGetHandleVerifier [0x00ACC781+1305121]\n\tGetHandleVerifier [0x00A14B0E+552366]\n\tGetHandleVerifier [0x00A149D6+552054]\n\tOrdinal0 [0x00971FA7+1515431]\n\tGetHandleVerifier [0x00A15036+553686]\n\tOrdinal0 [0x008F300F+995343]\n\tOrdinal0 [0x008FF65B+1046107]\n\tOrdinal0 [0x008FF7AA+1046442]\n\tOrdinal0 [0x008FE7C5+1042373]\n\tBaseThreadInitThunk [0x76396359+25]\n\tRtlGetAppContainerNamedObjectPath [0x77947A94+228]\n\tRtlGetAppContainerNamedObjectPath [0x77947A64+180]\n"}} _WD_FindElement ==> Webdriver Exception: HTTP status = 404 __WD_Post: URL=HTTP://127.0.0.1:9515/session/09ae64ce672ad64e4454647c9a4e27fe/element//click; $sData={"id":""} __WD_Post: StatusCode=404; ResponseText={"value":{"error":"no such window","message":"target window already closed\nfrom unknown error: web view not found\n (Session info: chrome=75.0.3770.100)","stacktrace":"Backtrace:\n\tOrdinal0 [0x00963C43+1457219]\n\tOrdinal0 [0x008DC471+902257]\n\tOrdinal0 [0x0087D54F+513359]\n\tOrdinal0 [0x0086DA68+449128]\n\tOrdinal0 [0x0082FF2D+196397]\n\tOrdinal0 [0x00837446+226374]\n\tOrdinal0 [0x0082F4AB+193707]\n\tOrdinal0 [0x00814160+82272]\n\tOrdinal0 [0x008156E6+87782]\n\tOrdinal0 [0x008155F0+87536]\n\tGetHandleVerifier [0x00ACC781+1305121]\n\tGetHandleVerifier [0x00A14B0E+552366]\n\tGetHandleVerifier [0x00A149D6+552054]\n\tOrdinal0 [0x00971FA7+1515431]\n\tGetHandleVerifier [0x00A15036+553686]\n\tOrdinal0 [0x008F300F+995343]\n\tOrdinal0 [0x008FF65B+1046107]\n\tOrdinal0 [0x008FF7AA+1046442]\n\tOrdinal0 [0x008FE7C5+1042373]\n\tBaseThreadInitThunk [0x76396359+25]\n\tRtlGetAppContainerNamedObjectPath [0x77947A94+228]\n\tRtlGetAppContainerNamedObjectPath [0x77947A64+180]\n"}} _WD_ElementAction: {"value":{"error":"no such window","message":"target window already closed\nfrom unknown error: web ... _WD_ElementAction ==> Webdriver Exception: {"value":{"error":"no such window","message":"target window already closed\nfrom unknown error: web view not found\n (Session info: chrome=75.0.3770.100)","stacktrace":"Backtrace:\n\tOrdinal0 [0x00963C43+1457219]\n\tOrdinal0 [0x008DC471+902257]\n\tOrdinal0 [0x0087D54F+513359]\n\tOrdinal0 [0x0086DA68+449128]\n\tOrdinal0 [0x0082FF2D+196397]\n\tOrdinal0 [0x00837446+226374]\n\tOrdinal0 [0x0082F4AB+193707]\n\tOrdinal0 [0x00814160+82272]\n\tOrdinal0 [0x008156E6+87782]\n\tOrdinal0 [0x008155F0+87536]\n\tGetHandleVerifier [0x00ACC781+1305121]\n\tGetHandleVerifier [0x00A14B0E+552366]\n\tGetHandleVerifier [0x00A149D6+552054]\n\tOrdinal0 [0x00971FA7+1515431]\n\tGetHandleVerifier [0x00A15036+553686]\n\tOrdinal0 [0x008F300F+995343]\n\tOrdinal0 [0x008FF65B+1046107]\n\tOrdinal0 [0x008FF7AA+1046442]\n\tOrdinal0 [0x008FE7C5+1042373]\n\tBaseThreadInitThunk [0x76396359+25]\n\tRtlGetAppContainerNamedObjectPath [0x77947A94+228]\n\tRtlGetAppContainerNamedObjectPath [0x77947A64+180]\n"}} +>11:34:24 AutoIt3.exe ended.rc:0 +>11:34:24 AutoIt3Wrapper Finished. >Exit code: 0 Time: 29.92 @Danp2 Here's the code that shows that after function _WD_Window($sSession,"close") is called, the $sSession is no longer valid. -
WebDriver UDF (W3C compliant version) - 2024/09/21
Holycow replied to Danp2's topic in AutoIt Example Scripts
@Danp2 If there are multiple tabs opened, and executing _WD_Window($sSession,'Close') on any existing tab would kill the session, meaning you can longer control any remaining tabs. Could you please take a look at this? -
@Danp2 - How do you connect to an existing Chrome instance? I see that you have code sample for Firefox on your GitHub Wiki but don't see one for Chrome. Could you please provide one? thanks Dan