dgendrud Posted September 23, 2023 Posted September 23, 2023 I have not been successful in getting WD Attach to work with Firefox browser, I understand it should work with Firefox. The code and element in this test code works correctly in retrieving a column of data when the site is opened with webdriver. I copied this section of working code directly from another working script (where the site is opened with webdriver). When I run this code on the same site, but open it manually and attach, the element is not found. I have tried several other sites & elements with the same result - element not found. I think, based on the geckodriver output, that the "WD attach" is working. I would like some direction on how to solve this issue. Thanks Doug WDattachTesting.au3 Geckodriver and console outputs.docx
Danp2 Posted September 23, 2023 Posted September 23, 2023 I'll try to look at your attachments later, but wanted to comment on the usage of _WD_Attach. This function works with all supported browsers. Where you may be running into trouble is attempting to attach to a browser instance that was opened separately. Latest Webdriver UDF Release Webdriver Wiki FAQs
dgendrud Posted September 24, 2023 Author Posted September 24, 2023 Ok, Thanks. I have a situation where I access my brokerage account website and sign in it always works fine. If I open a Firefox browser window in Web driver and navigate to the same sign in site and put a "wait to sign in MsgBox to stop the script", the navigation works to access the sign in site but when I try to sign in it won't accept my username and password. Maybe there is a solution to that, but I think I need to access and sign in to the site manually with Firefox, and then attach to it after signin. Comments? This is my bank/brokerage account so maybe the security is unusually high??
Danp2 Posted September 24, 2023 Posted September 24, 2023 Quote _WD_Startup: Webdriver UDF: 1.1.1 (Update available) Please update to the latest release of the UDF Quote _WD_Attach ==> No match [8] : Parameters: Search=High-Growth Mode=Title This is telling you that it couldn't find a tab with that title. Change your $_WD_DEBUG to $_WD_DEBUG_Full to obtain a more detailed log in the Scite console Latest Webdriver UDF Release Webdriver Wiki FAQs
dgendrud Posted September 24, 2023 Author Posted September 24, 2023 Still trying to attach to an already open website. I updated the Webdriver UDF and changed the debug to (1). I setup a simple test to access a single element text on the Yahoo Finance website. Navigating to this site using Webdriver and accessing the element text works. However going to this site manually using Firefox and trying to attach and access the element does not. Maybe I'm missing what the "_WD_Attach" is intended for? The attach command shows a no match (8) WDattachTesting_Yahoo.au3
Danp2 Posted September 24, 2023 Posted September 24, 2023 It sounds like you are trying to attach to a browser instance that wasn't opened using Webdriver. This won't work unless you launched the browser using special parameters. Check out the Wiki FAQ section for more details. Latest Webdriver UDF Release Webdriver Wiki FAQs
dgendrud Posted September 25, 2023 Author Posted September 25, 2023 Yes, I had looked through that FAQ before, it looked complicated and I didn't study it enough to figure out that it was the answer. I have run it a few times now, and am working to modify it for my application. It seems this will work for me, I will know soon. Thanks again for the advice, don't know if I would have eventually got back there on my own!
dgendrud Posted September 25, 2023 Author Posted September 25, 2023 I'm working on modifying this FAQ example script, but I don't see that it actually attaches to an existing browser tab (not originally navigated to with webdriver). It still navigates to the site, after creating the firefox browsing instance window. This seems no different than just creating a session and navigating directly to the site desired. See my minimal modifications, I only modified the Firefox binary location and the desired site to attach to, and changed the WD_Navigate to WD_Attach, which does not work. I have the desired site open in a tab, and I get a no-match (8) error, with either Title or UDF method. My basic issue is that If I navigate to my bank/brokerage account using a script, it will not let me sign in. I assume it knows a script, or something similar, is being used. I have several other trading type sites (zacks.com for example) that I can navigate to with the script and sign in with no issue. But not my bank. Attach_sample.au3
Danp2 Posted September 25, 2023 Posted September 25, 2023 (edited) There are some sites that will detect the presence of Webdriver and refuse to be automated. There may be a way to bypass their checks, but let's deal with that later. Since we can't fully test your process, it could be helpful to see the full console output. Be sure to add this at the top of your script -- $_WD_DEBUG = $_WD_DEBUG_Full Edit: It worked fine in my testing. I manually opened multiple tabs (the PNC website and Google) in between runs. Here's my console output -- expandcollapse popup>"C:\Program Files (x86)\AutoIt3\SciTE\..\AutoIt3.exe" "C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "C:\Users\danpo\Downloads\Attach_sample.au3" /UserParams @@ Debug(63) : $RunBySciTE = True >Error code: 0 +>08:38:25 Starting AutoIt3Wrapper (23.402.1150.0) from:SciTE.exe (5.3.5.0) Keyboard:00000409 OS:WIN_11/2009 CPU:X64 OS:X64 Environment(Language:0409) CodePage:0 utf8.auto.check:4 +> SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE UserDir => C:\Users\danpo\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper SCITE_USERHOME => C:\Users\danpo\AppData\Local\AutoIt v3\SciTE >Running AU3Check (3.3.16.1) from:C:\Program Files (x86)\AutoIt3 input:C:\Users\danpo\Downloads\Attach_sample.au3 +>08:38:26 AU3Check ended. rc:0 >Running:(3.3.16.1):C:\Program Files (x86)\AutoIt3\autoit3.exe "C:\Users\danpo\Downloads\Attach_sample.au3" +>Setting Hotkeys...--> Press Ctrl+Alt+Break to Restart. --> Press Ctrl+BREAK to Stop. _WD_GetBrowserPath ==> Success [0 / 2] : Parameters: Browser=firefox _WD_GetBrowserVersion ==> Success [0 / 2] : Parameters: Browser=firefox _WD_GetWebDriverVersion ==> Success [0 / 0] : Parameters: Dir=C:\Users\danpo\Downloads\ EXE=geckodriver.exe __WD_GetLatestWebdriverInfo ==> Success [0 / 0] _WD_UpdateDriver ==> Success [0 / 0] : DriverCurrent = 0.33.0 : DriverLatest = 0.33.0 _WD_Option ==> Success [0] : Parameters: Option=Driver Value=geckodriver.exe _WD_Option ==> Success [0] : Parameters: Option=Port Value=4444 _WD_Option ==> Success [0] : Parameters: Option=DefaultTimeout Value=1000 _WD_Option ==> Success [0] : Parameters: Option=DriverParams Value=--log trace --marionette-port 2828 --connect-existing _WD_GetFreePort ==> Success [0 / 4444] : Parameters: MinPort=4444 MaxPort=Default _WD_IsLatestRelease ==> Success [0] : True _WD_Startup: OS: WIN_11 X64 22621 _WD_Startup: AutoIt: 3.3.16.1 _WD_Startup: Webdriver UDF: 1.2.0 (Up to date) _WD_Startup: WinHTTP: 1.6.4.2 _WD_Startup: Driver: geckodriver.exe (32 Bit) _WD_Startup: Params: --log trace --marionette-port 2828 --connect-existing _WD_Startup: Port: 4444 _WD_Startup: Command: "geckodriver.exe" --log trace --marionette-port 2828 --connect-existing _WD_Startup ==> Success [0] __WD_Post: URL=HTTP://127.0.0.1:4444/session; Data={"capabilities":{}} __WD_Post ==> Success [0] : HTTP status = 200 ResponseText={"value":{"sessionId":"0aea8d99-d71e-4a1d-844a-4f9b96589158","capabilities":{"acceptInsecureCerts":false,"browserName":"firefox","browserVersion":"117.0.1","moz:accessibilityChecks":false,"moz:buildID":"20230912013654","moz:geckodriverVersion":"0.33.0","moz:headless":false,"moz:platformVersion":"10.0","moz:processID":34052,"moz:profile":"C:\\Users\\danpo\\AppData\\Local\\Mozilla\\Firefox\\Profiles\\WD_Testing_Profile","moz:shutdownTimeout":60000,"moz:webdriverClick":true,"moz:windowless":false,"pageLoadStrategy":"normal","platformName":"windows","proxy":{},"setWindowRect":true,"strictFileInteractability":false,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000},"unhandledPromptBehavior":"dismiss and notify"}}} _WD_CreateSession ==> Success [0] : 0aea8d99-d71e-4a1d-844a-4f9b96589158 __WD_Get: URL=HTTP://127.0.0.1:4444/session/0aea8d99-d71e-4a1d-844a-4f9b96589158/window/handles __WD_Get ==> Success [0] : HTTP status = 200 ResponseText={"value":["833a8cba-f03d-4433-83d9-07e927e5f2bf","fc91fc95-7ba4-43ed-8da7-9d6681a31dcf"]} _WD_Window ==> Success [0] : Parameters: Command=handles Option=Default __WD_Get: URL=HTTP://127.0.0.1:4444/session/0aea8d99-d71e-4a1d-844a-4f9b96589158/window __WD_Get ==> Success [0] : HTTP status = 200 ResponseText={"value":"fc91fc95-7ba4-43ed-8da7-9d6681a31dcf"} _WD_Window ==> Success [0] : Parameters: Command=window Option=Default __WD_Post: URL=HTTP://127.0.0.1:4444/session/0aea8d99-d71e-4a1d-844a-4f9b96589158/window; Data={"handle":"833a8cba-f03d-4433-83d9-07e927e5f2bf"} __WD_Post ==> Success [0] : HTTP status = 200 ResponseText={"value":null} _WD_Window ==> Success [0] : Parameters: Command=Switch Option={"handle":"833a8cba-f03d-4433-83d9-07e927e5f2bf"} __WD_Get: URL=HTTP://127.0.0.1:4444/session/0aea8d99-d71e-4a1d-844a-4f9b96589158/title __WD_Get ==> Success [0] : HTTP status = 200 ResponseText={"value":"PNC Personal Banking"} _WD_Action ==> Success [0] : Parameters: Command=Title Option=Default _WD_Attach ==> Success [0] : Parameters: Search=Banking Mode=Title __WD_Post: URL=HTTP://127.0.0.1:4444/session/0aea8d99-d71e-4a1d-844a-4f9b96589158/refresh; Data={} __WD_Post ==> Success [0] : HTTP status = 200 ResponseText={"value":null} _WD_Action ==> Success [0] : Parameters: Command=REFRESH Option=Default __WD_Delete: URL=HTTP://127.0.0.1:4444/session/0aea8d99-d71e-4a1d-844a-4f9b96589158 __WD_Delete ==> Success [0] : HTTP status = 200 ResponseText={"value":null} _WD_DeleteSession ==> Success [0] : WebDriver session deleted +>08:38:51 AutoIt3 ended. rc:0 +>08:38:51 AutoIt3Wrapper Finished. >Exit code: 0 Time: 25.7 Edited September 25, 2023 by Danp2 Latest Webdriver UDF Release Webdriver Wiki FAQs
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