Danp2 Posted June 5, 2020 Author Share Posted June 5, 2020 @DonChunior I haven't used that browser, so I'm not sure how much help I can be. I did have a few questions / comments -- You are using an older version of the Webdriver UDF. Please update to the latest version (0.3.0.1) There's a newer version of the WinHTTP UDF. Grab the source from here. What version of Geckodriver are you attempting to use? Why the switch from port 4444 to 9150? DonChunior 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
CYCho Posted June 7, 2020 Share Posted June 7, 2020 (edited) @Danp2, Hi, sometimes I have to run 2 independent webdriver programs concurrenntly. As the _WD_Startup in the 2nd program closes existing chromedriver.exe and its child processes, the first program stops functioning when the 2nd program is initiated. So I put the following code in the 2nd program. If Not ProcessExists("chromedriver.exe") Then _WD_Startup() EndIf Apparently this works. But I'd like to have your input as to the viability of this approach. Edited June 7, 2020 by CYCho zPlayer - A Small Audio and Video Player Time Sync + SystemTimeAdjustment Link to comment Share on other sites More sharing options...
Danp2 Posted June 7, 2020 Author Share Posted June 7, 2020 @CYCho That seems appropriate to me. In fact, it might be good to make this an option built into _WD_Startup. CYCho 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
DonChunior Posted June 8, 2020 Share Posted June 8, 2020 On 6/5/2020 at 2:06 PM, Danp2 said: @DonChunior I haven't used that browser, so I'm not sure how much help I can be. I did have a few questions / comments -- You are using an older version of the Webdriver UDF. Please update to the latest version (0.3.0.1) There's a newer version of the WinHTTP UDF. Grab the source from here. What version of Geckodriver are you attempting to use? Why the switch from port 4444 to 9150? @Danp2, thanks for your advice. I've updated the UDFs to the latest versions. For the Geckodriver I use the latest version 0.26.0 (64 bit). Last but not least, I made the Tor Browser start with the following code: _WD_Option('Driver', 'geckodriver.exe') _WD_Option('Port', 4444) _WD_Startup() Local $sSession = _WD_CreateSession('{"capabilities": {"alwaysMatch": {"moz:firefoxOptions": {"binary": "C:\\Program Files\\Tor Browser\\Browser\\firefox.exe", "args": ["-profile", "C:\\Program Files\\Tor Browser\\Browser\\TorBrowser\\Data\\Browser\\profile.default"]}}}}') However, I still get error messages in the console output: _WDStartup: OS: WIN_10 WIN32_NT 18362 _WDStartup: AutoIt: 3.3.14.5 _WDStartup: WD.au3: 0.3.0.1 _WDStartup: WinHTTP: 1.6.4.2 _WDStartup: Driver: geckodriver.exe _WDStartup: Params: _WDStartup: Port: 4444 __WD_Post: URL=HTTP://127.0.0.1:4444/session; $sData={"capabilities": {"alwaysMatch": {"moz:firefoxOptions": {"binary": "C:\\Program Files\\Tor Browser\\Browser\\firefox.exe", "args": ["-profile", "C:\\Program Files\\Tor Browser\\Browser\\TorBrowser\\Data\\Browser\\profile.default"]}}}} __WD_Post: StatusCode=0; ResponseText=0... __WD_Post ==> Send / Recv error _WD_CreateSession: 0 _WD_CreateSession ==> Webdriver Exception: HTTP status = 0 So the solution was to pass the Tor default profile as argument. Do you have an idea how to get rid of them❓ Link to comment Share on other sites More sharing options...
Danp2 Posted June 8, 2020 Author Share Posted June 8, 2020 @DonChunior If you check the Geckodriver console, does it provide any additional details? DonChunior 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
nooneclose Posted June 8, 2020 Share Posted June 8, 2020 @Danp2 does the new Microsoft Edge affect how WebDriver works with it? Link to comment Share on other sites More sharing options...
Danp2 Posted June 8, 2020 Author Share Posted June 8, 2020 @nooneclose Should work fine as long as you have the proper webdriver. nooneclose 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
DonChunior Posted June 9, 2020 Share Posted June 9, 2020 On 6/8/2020 at 2:28 PM, Danp2 said: @DonChunior If you check the Geckodriver console, does it provide any additional details? Here's the output of the Geckodriver console: 1591707385254 geckodriver DEBUG Listening on 127.0.0.1:4444 1591707385717 webdriver::server DEBUG -> POST /session {"capabilities": {"alwaysMatch": {"moz:firefoxOptions": {"binary": "C:\\Program Files\\Tor Browser\\Browser\\firefox.exe", "args": ["-profile", "C:\\Program Files\\Tor Browser\\Browser\\TorBrowser\\Data\\Browser\\profile.default"]}}}} 1591707385767 mozrunner::runner INFO Running command: "C:\\Program Files\\Tor Browser\\Browser\\firefox.exe" "-marionette" "-profile" "C:\\Program Files\\Tor Browser\\Browser\\TorBrowser\\Data\\Browser\\profile.default" "-foreground" "-no-remote" 1591707385777 geckodriver::marionette DEBUG Waiting 60s to connect to browser on 127.0.0.1:54414 1591707446918 mozrunner::runner DEBUG Killing process 10812 1591707446921 webdriver::server DEBUG <- 500 Internal Server Error {"value":{"error":"timeout","message":"connection refused","stacktrace":""}} Link to comment Share on other sites More sharing options...
Danp2 Posted June 9, 2020 Author Share Posted June 9, 2020 @DonChunior It seems that geckodriver isn't able to connect to the browser instance. As I mentioned before, I'm not familiar with this browser. Are you sure that TorBrowser supports Marionette / webdriver protocol? Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
DonChunior Posted June 9, 2020 Share Posted June 9, 2020 4 minutes ago, Danp2 said: @DonChunior It seems that geckodriver isn't able to connect to the browser instance. As I mentioned before, I'm not familiar with this browser. Are you sure that TorBrowser supports Marionette / webdriver protocol? I can't say for sure, but I assume so, since Tor Browser 9.5 is based on Firefox 68.9.0esr. Link to comment Share on other sites More sharing options...
Danp2 Posted June 9, 2020 Author Share Posted June 9, 2020 @DonChunior Looks like you need to tell geckodriver to use the correct port -- _WD_Option('DriverParams', '--log trace --marionette-port 2828') DonChunior 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
nooneclose Posted June 9, 2020 Share Posted June 9, 2020 @Danp2 is there a way to not have webdriver close all my existing Microsoft Edge pages and tabs? When I run this code: ; Edge (standard) _WD_Option('Driver', 'MicrosoftWebDriver.exe') _WD_Option('Port', 17556) _WD_Option('DriverParams', '--verbose') $sDesiredCapabilities = '{"capabilities":{}}' ;Start the WebDriver.exe console _WD_Startup() ; Hide the WebDriver Console _WD_ConsoleVisible(True) If @error <> $_WD_ERROR_Success Then Exit -1 EndIf $sSession = _WD_CreateSession($sDesiredCapabilities) ; Navigates to the Maximo login page _WD_Navigate($sSession, "https://maximoapp.pcci.edu/maximo/webclient/login/login.jsp?appservauth=true") ; Maximizes the page _WD_Window($sSession, "Maximize") it closes all of my existing Edge pages and any tabs I had open. Link to comment Share on other sites More sharing options...
Danp2 Posted June 9, 2020 Author Share Posted June 9, 2020 @nooneclose This is likely the result of it using a new profile each time you launch the browser with the webdriver. You can likely specify your existing profile, but I haven't looked into how to do this with Edge (could be the same as Chrome). nooneclose 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
nooneclose Posted June 9, 2020 Share Posted June 9, 2020 thank you. I will check that out Link to comment Share on other sites More sharing options...
DonChunior Posted June 10, 2020 Share Posted June 10, 2020 23 hours ago, Danp2 said: @DonChunior Looks like you need to tell geckodriver to use the correct port -- _WD_Option('DriverParams', '--log trace --marionette-port 2828') @Danp2, thank you very much for the decisive hint! With the following code, the Tor browser will now start as desired: _WD_Option('Driver', 'geckodriver.exe') _WD_Option('DriverParams', '--marionette-port 2828') _WD_Option('Port', 4444) _WD_Startup() Local $sSession = _WD_CreateSession('{"capabilities": {"alwaysMatch": {"moz:firefoxOptions": {"binary": "C:\\Program Files\\Tor Browser\\Browser\\firefox.exe", "args": ["-profile", "C:\\Program Files\\Tor Browser\\Browser\\TorBrowser\\Data\\Browser\\profile.default"]}}}}') Link to comment Share on other sites More sharing options...
nooneclose Posted June 11, 2020 Share Posted June 11, 2020 (edited) @Danp2 How do I go about clicking on unseen links. There is a menu that only appears when the user hovers their mouse over a portion of the main menu. See pictures below. Before hovering the mouse over: After hovering the mouse over: I am trying to get my script to click on 'Physical Count' but everything I have tried failed. Even The code below failed. _WD_LinkClickByText($sSession, "Physical Count") If I can not use the standard _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//a[@id='m74daaf83_ns_menu_AM55_HEADER_sub_PHYSCNTADJ_OPTION_a']") _WD_ElementAction($sSession, $wPsyCount, 'click') how would I go about achieving this? If you want to see the HTML code I have to work with DM me. too much to post here. Edited June 11, 2020 by nooneclose grammar Link to comment Share on other sites More sharing options...
Danp2 Posted June 11, 2020 Author Share Posted June 11, 2020 1 hour ago, nooneclose said: The code below failed It would be useful if you showed the results from the Scite output panel so that we can determine why it failed. Was the element not found? Or was the error due to a non-interactable element? How can we guide you without these necessary details? 🙄 P.S. You likely will need to use "actions" to force the menu to appear. See DemoActions in wd_demo.au3 for an example. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
nooneclose Posted June 12, 2020 Share Posted June 12, 2020 (edited) @Danp2 my bad. Here is the output from the Scite: __WD_Post: URL=HTTP://?/session/cbbda3c6857fdb412a4beab05d978cce/element; $sData={"using":"xpath","value":"//a[@id='m30dc4336_tfrow_[C:7]_txt-tb']"} __WD_Post: StatusCode=404; ResponseText={"value":{"error":"no such element","message":"no such element: Unable to locate element: {\"method\... _WD_FindElement: {"value":{"error":"no such element","message":"no such element: Unable to locate element: {\"method\":\"xpath\",\"selector\":\"//a[@id='m30dc4336_tfrow_[C:7]_txt-tb']\"}\n (Session info: chrome=83.0.4103.97)","stacktrace":"Backtrace:\n\tOrdinal0 [0x005D9563+2725219]\n\tOrdinal0 [0x004D8551+1672529]\n\tOrdinal0 [0x003C0359+525145]\n\tOrdinal0 [0x00359755+104277]\n\tOrdinal0 [0x003753C0+218048]\n\tOrdinal0 [0x0036AAD0+174800]\n\tOrdinal0 [0x00373D7C+212348]\n\tOrdinal0 [0x0036A94B+174411]\n\tOrdinal0 [0x00352528+75048]\n\tOrdinal0 [0x003535A0+79264]\n\tOrdinal0 [0x00353539+79161]\n\tOrdinal0 [0x004ED607+1758727]\n\tGetHandleVerifier [0x006F6546+1050150]\n\tGetHandleVerifier [0x006F6291+1049457]\n\tGetHandleVerifier [0x007010D7+1094071]\n\tGetHandleVerifier [0x006F6B46+1051686]\n\tOrdinal0 [0x004E5B06+1727238]\n\tOrdinal0 [0x004EEB7B+1764219]\n\tOrdinal0 [0x004EECE3+1764579]\n\tOrdinal0 [0x00504C05+1854469]\n\tBaseThreadInitThunk [0x75A16359+25]\n\tRtlGetAppContainerNamedObjectPath [0x77E77C24+228]\n\tRtlGetAppContainerNamedObjectPath [0x77E77BF4+180]\n"}} _WD_FindElement ==> No match: HTTP status = 404 __WD_Post: URL=HTTP://?/session/cbbda3c6857fdb412a4beab05d978cce/element; $sData={"using":"xpath","value":"//a[@id='m74daaf83_ns_menu_AM55_HEADER_sub_PHYSCNTADJ_OPTION_a']"} __WD_Post: StatusCode=200; ResponseText={"value":{"element-6066-11e4-a52e-4f735466cecf":"817ceafa-5d5b-4235-a6e8-63f95a5e41d4"}}... _WD_FindElement: {"value":{"element-6066-11e4-a52e-4f735466cecf":"817ceafa-5d5b-4235-a6e8-63f95a5e41d4"}} __WD_Post: URL=HTTP://?/session/cbbda3c6857fdb412a4beab05d978cce/element/817ceafa-5d5b-4235-a6e8-63f95a5e41d4/click; $sData={"id":"817ceafa-5d5b-4235-a6e8-63f95a5e41d4"} __WD_Post: StatusCode=400; ResponseText={"value":{"error":"element not interactable","message":"element not interactable\n (Session info: c... _WD_ElementAction: {"value":{"error":"element not interactable","message":"element not interactable\n (Session info: c... _WD_ElementAction ==> Element interaction issue: {"value":{"error":"element not interactable","message":"element not interactable\n (Session info: chrome=83.0.4103.97)","stacktrace":"Backtrace:\n\tOrdinal0 [0x005D9563+2725219]\n\tOrdinal0 [0x004D8551+1672529]\n\tOrdinal0 [0x003C0202+524802]\n\tOrdinal0 [0x0035A0BA+106682]\n\tOrdinal0 [0x003543B1+82865]\n\tOrdinal0 [0x0036AA9D+174749]\n\tOrdinal0 [0x003541F6+82422]\n\tOrdinal0 [0x0036ACE1+175329]\n\tOrdinal0 [0x00373D7C+212348]\n\tOrdinal0 [0x0036A94B+174411]\n\tOrdinal0 [0x00352528+75048]\n\tOrdinal0 [0x003535A0+79264]\n\tOrdinal0 [0x00353539+79161]\n\tOrdinal0 [0x004ED607+1758727]\n\tGetHandleVerifier [0x006F6546+1050150]\n\tGetHandleVerifier [0x006F6291+1049457]\n\tGetHandleVerifier [0x007010D7+1094071]\n\tGetHandleVerifier [0x006F6B46+1051686]\n\tOrdinal0 [0x004E5B06+1727238]\n\tOrdinal0 [0x004EEB7B+1764219]\n\tOrdinal0 [0x004EECE3+1764579]\n\tOrdinal0 [0x00504C05+1854469]\n\tBaseThreadInitThunk [0x75A16359+25]\n\tRtlGetAppContainerNamedObjectPath [0x77E77C24+228]\n\tRtlGetAppContainerNamedObjectPath [0x77E77BF4+180]\n"}} __WD_Post: URL=HTTP://?/session/cbbda3c6857fdb412a4beab05d978cce/element; $sData={"using":"partial link text","value":"Physical Count"} __WD_Post: StatusCode=404; ResponseText={"value":{"error":"no such element","message":"no such element: Unable to locate element: {\"method\... _WD_FindElement: {"value":{"error":"no such element","message":"no such element: Unable to locate element: {\"method\":\"partial link text\",\"selector\":\"Physical Count\"}\n (Session info: chrome=83.0.4103.97)","stacktrace":"Backtrace:\n\tOrdinal0 [0x005D9563+2725219]\n\tOrdinal0 [0x004D8551+1672529]\n\tOrdinal0 [0x003C0359+525145]\n\tOrdinal0 [0x00359755+104277]\n\tOrdinal0 [0x003753C0+218048]\n\tOrdinal0 [0x0036AAD0+174800]\n\tOrdinal0 [0x00373D7C+212348]\n\tOrdinal0 [0x0036A94B+174411]\n\tOrdinal0 [0x00352528+75048]\n\tOrdinal0 [0x003535A0+79264]\n\tOrdinal0 [0x00353539+79161]\n\tOrdinal0 [0x004ED607+1758727]\n\tGetHandleVerifier [0x006F6546+1050150]\n\tGetHandleVerifier [0x006F6291+1049457]\n\tGetHandleVerifier [0x007010D7+1094071]\n\tGetHandleVerifier [0x006F6B46+1051686]\n\tOrdinal0 [0x004E5B06+1727238]\n\tOrdinal0 [0x004EEB7B+1764219]\n\tOrdinal0 [0x004EECE3+1764579]\n\tOrdinal0 [0x00504C05+1854469]\n\tBaseThreadInitThunk [0x75A16359+25]\n\tRtlGetAppContainerNamedObjectPath [0x77E77C24+228]\n\tRtlGetAppContainerNamedObjectPath [0x77E77BF4+180]\n"}} _WD_FindElement ==> No match: HTTP status = 404 _WD_LinkClickByText ==> No match Here is the output from the Chrome webdriver window: DevTools listening on ws://?/devtools/browser/6f666135-245b-4f84-ae17-7bdfadb3d720 [12032:11960:0612/075721.363:ERROR:device_event_log_impl.cc(208)] [07:57:21.363] Bluetooth: bluetooth_adapter_winrt.cc:1060 Getting Default Adapter failed. I looked at the actions in the demo file. Do they move the mouse to click or something? because I cannot guarantee the web-page to be opened the same every time. here is the HTML: <a id="m74daaf83_ns_menu_AM55_HEADER_sub_PHYSCNTADJ_OPTION_a" role="menuitem" tabindex="-1" draggable="false" clickid="undefined" eventtype="PHYSCNTADJ" href="javascript: topLevelMenus['m74daaf83_ns_MC'].menuClick({"id":"PHYSCNTADJ_OPTION","text":"Physical Count","mxevent":"PHYSCNTADJ","target":"inventor","event":"PHYSCNTADJ"});" aria-labelledby="m74daaf83_ns_menu_AM55_HEADER_sub_PHYSCNTADJ_OPTION_a_tnode" xpath="1" style=""><img class="menuimg" alt="" src="menus/blank.gif"><span id="m74daaf83_ns_menu_AM55_HEADER_sub_PHYSCNTADJ_OPTION_a_tnode">Physical Count</span></a> Edited June 12, 2020 by nooneclose missing info Link to comment Share on other sites More sharing options...
Danp2 Posted June 12, 2020 Author Share Posted June 12, 2020 3 minutes ago, nooneclose said: _WD_FindElement ==> No match: Can't click on what you can't find. 😀 Quote _WD_ElementAction ==> Element interaction issue This is what I was guessing the problem was. Quote I looked at the actions in the demo file. Do they move the mouse to click or something? because I cannot guarantee the web-page to be opened the same every time Yes, you use it to simulate mouse movement among other things. How the web page is opened / rendered shouldn't matter as long as the target element exists. The alternative is to find a way to programmatically trigger the menu to popup so that the click action can occur. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
nooneclose Posted June 12, 2020 Share Posted June 12, 2020 @Danp2 I do not know if I made progress or not but I think I got it to find this element but it didnt click on it. __WD_Post: URL=HTTP://127.0.0.1:9515/session/28f4d06d7c3c5f791b93aeab473ebf2e/element; $sData={"using":"xpath","value":"//a[@id='m74daaf83_ns_menu_AM55_HEADER_sub_PHYSCNTADJ_OPTION_a']"} __WD_Post: StatusCode=200; ResponseText={"value":{"element-6066-11e4-a52e-4f735466cecf":"b2b970bc-81f2-4de4-9557-1f770ac0a926"}}... _WD_FindElement: {"value":{"element-6066-11e4-a52e-4f735466cecf":"b2b970bc-81f2-4de4-9557-1f770ac0a926"}} _WD_Action ==> Invalid data type: (Back|Forward|Refresh|Url|Title|Actions) $sCommand=>b2b970bc-81f2-4de4-9557-1f770ac0a926 I tried this: ConsoleWrite("Frames=" & _WD_GetFrameCount($sSession) & @CRLF) ConsoleWrite("TopWindow=" & _WD_IsWindowTop($sSession) & @CRLF) $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//iframe[@id='iframeResult']") _WD_FrameEnter($sSession, $sElement) $wPsyCount = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//a[@id='m74daaf83_ns_menu_AM55_HEADER_sub_PHYSCNTADJ_OPTION_a']") _WD_Action($sSession, $wPsyCount, 'click') that is the element that contains the javascript link. is this right for actions? $sAction &= $sElement & '","' & $_WD_ELEMENT_ID & '":"' & $sElement & '"}},{"button":1,"type":"pointerDown"},{"button":1,"type":"pointerUp"}]}]}' Link to comment Share on other sites More sharing options...
Recommended Posts