Jump to content

Mozzilo

Members
  • Posts

    2
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Mozzilo's Achievements

Seeker

Seeker (1/7)

0

Reputation

  1. Thanks Danp2 for the quick reply. You have potentially saved me hours of headache. The solution was to add the line: _WD_Option('DriverClose', False) Cheers! P.S. VSCode is great. It made my coding so much quicker
  2. Hi all, I've been using AutoIT for a while now and this forum has been very useful. Thanks everyone! I hit a brick wall recently. I'm trying to update my old script so it uses Edge instead of IE. The program uses a GUI that opens the WebDriver and Edge in headless mode on startup. From the GUI, a user may run up to 6 child processes. The child processes have to navigate to different websites and look for keywords (within their own tabs) and act accordingly to findings. All that works fine if I run one child process. The trouble starts when I try to run multiple child processes. The error I get is: __WD_Post ==> Invalid session ID [15] : HTTP status = 404 _WD_Navigate ==> Invalid session ID [15] : Parameters: URL=https://www.bing.com/ I managed to run two child processes simultaneously without them conflicting with each other a few times from my GUI. The child processes were compiled. If I run them immediately one after the other they (sometimes) do not conflict with each other. However, every time I try to run the third process, the first two stop working. This gives me hope that it is possible to get it working. Here's a bit of code I have been experimenting on. I have modified the code provided by @mLipok to suit my needs and my actual code uses it. Thanks for that. #include "wd_helper.au3" #include "wd_capabilities.au3" # HOW TO TEST: ; At first run choose [Yes] to create new session Edge running instance ; At second run choose [No] to attach to active Edge running instance # TODO: ; https://github.com/operasoftware/operachromiumdriver/blob/master/docs/desktop.md --remote-debugging-port=port Global $_MY__WD_SESSION Global $__g_sDownloadDir = "" $WD_DEBUG = $_WD_DEBUG_Full _Test() Exit Func _Test() Local $iAnswer = MsgBox($MB_YESNO + $MB_TOPMOST + $MB_ICONQUESTION + $MB_DEFBUTTON2, "Question", _ "Open new sesion ?" & @CRLF & "[ NO ] = Try attach to active edge instance") If $iAnswer = $IDYES Then _Testing_CreateSession() Return ; do not process next functions Else _Testing_AttachSession() _WD_NewTab($_MY__WD_SESSION) While 1 _WD_Navigate($_MY__WD_SESSION, 'https://www.google.com/') Sleep(1000) _WD_Navigate($_MY__WD_SESSION, 'https://www.bing.com/') Sleep(1000) WEnd EndIf $iAnswer = MsgBox($MB_YESNO + $MB_TOPMOST + $MB_ICONQUESTION + $MB_DEFBUTTON2, "Question", _ "Do you want to test ?" & @CRLF & "[ NO ] = Refresh - prevent expiration") If $iAnswer = $IDYES Then _Testing_WD_Navigate() Else _Testing_Refreshing() EndIf ; CleanUp _WD_DeleteSession($_MY__WD_SESSION) _WD_Shutdown() EndFunc ;==>_Test Func _Testing_CreateSession() $_MY__WD_SESSION = _MY__WD_SetupEdge(False, $__g_sDownloadDir, False) EndFunc ;==>_Testing_CreateSession Func _Testing_AttachSession() $_MY__WD_SESSION = _MY__WD_SetupEdge(False, $__g_sDownloadDir, True) EndFunc ;==>_Testing_AttachSession Func _Testing_Refreshing() While 1 ;~ _WD_Navigate($_MY__WD_SESSION, '') _WD_Action($_MY__WD_SESSION, 'REFRESH') Local $iAnswer = MsgBox($MB_YESNO + $MB_TOPMOST + $MB_ICONQUESTION + $MB_DEFBUTTON2, "Question", "Finish refreshing?" & @CRLF & "[No] = Refresh - prevent expiration", 60) If $iAnswer = $IDYES Then Return WEnd EndFunc ;==>_Testing_Refreshing Func _Testing_WD_Navigate() _WD_Navigate($_MY__WD_SESSION, 'https://www.autoitscript.com/forum') EndFunc ;==>_Testing_WD_Navigate Func _MY__WD_SetupEdge($b_Headless, $s_Download_dir = Default, $bTryAttach = False) If $s_Download_dir = Default Then $s_Download_dir = '' ElseIf $s_Download_dir Then If FileExists($s_Download_dir) = 0 Then $s_Download_dir = '' EndIf ;_WD_UpdateDriver('Edge') If @error Then Return SetError(@error, @extended, '') _WD_Option('Driver', 'msedgedriver.exe') _WD_Option('Port', 9515) _WD_CapabilitiesStartup() ;Local $s_AttachOption = (($bTryAttach) ? ("") : (" --remote-debugging-port=9222")) ;_WD_Option('DriverParams', '--log trace' & $s_AttachOption) _WD_CapabilitiesAdd('firstMatch', 'msedge') _WD_CapabilitiesAdd('w3c', True) _WD_CapabilitiesAdd('detach', False) _WD_CapabilitiesAdd('binary', "C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe") If $bTryAttach Then _WD_CapabilitiesAdd('debuggerAddress', 'localhost:9222') Else _WD_CapabilitiesAdd('args', '--remote-debugging-port=9222') EndIf If $b_Headless Then _ _WD_CapabilitiesAdd('args', '--headless') If $s_Download_dir Then _ _WD_CapabilitiesAdd('prefs', 'download.default_directory', $s_Download_dir) _WD_CapabilitiesDump(@ScriptLineNumber & ' :WebDriver:Capabilities:') _WD_Startup() If @error Then Return SetError(@error, @extended, '') Local $s_Capabilities = _WD_CapabilitiesGet() Local $WD_SESSION = _WD_CreateSession($s_Capabilities) Return SetError(@error, @extended, $WD_SESSION) EndFunc ;==>_MY__WD_SetupEdge Console: #1: Starting process #1 "C:\Program Files (x86)\AutoIt3\AutoIt3.exe" "C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "d:\TS1959\TS1959 V2.0 DEV one server\edge_attach.au3" [PID 9300]     +>16:21:45 Starting AutoIt3Wrapper (19.1127.1402.0} from:Code.exe (1.73.1.0) Keyboard:00000809 OS:WIN_10/ CPU:X64 OS:X64 Environment(Language:0409)     >Running AU3Check (3.3.14.5) from:C:\Program Files (x86)\AutoIt3 input:d:\TS1959\TS1959 V2.0 DEV one server\edge_attach.au3     +>16:21:45 AU3Check ended.rc:0     >Running:(3.3.14.5):C:\Program Files (x86)\AutoIt3\autoit3.exe "d:\TS1959\TS1959 V2.0 DEV one server\edge_attach.au3" /errorstdout     +>Setting Hotkeys...--> Press Ctrl+Alt+Break to Restart or Ctrl+BREAK to Stop.     _WD_Option ==> Success [0] : Parameters: Option=Driver Value=msedgedriver.exe     _WD_Option ==> Success [0] : Parameters: Option=Port Value=9515     _WD_CapabilitiesAdd ==> Success [0] : Successfully used [firstMatch] with specified browser: msedge     _WD_CapabilitiesAdd ==> Success [0] : Successfully added capability     _WD_CapabilitiesAdd ==> Success [0] : Successfully added capability     _WD_CapabilitiesAdd ==> Success [0] : Successfully added capability     _WD_CapabilitiesAdd ==> Success [0] : Successfully added capability     _WD_CapabilitiesDump: JSON structure starts below: 103 :WebDriver:Capabilities:     {      "capabilities":{      "firstMatch":[      {      "ms:edgeOptions":{      "binary":"C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe",      "args":[      "--remote-debugging-port=9222"      ]      }      }      ]      }     }     _WD_CapabilitiesDump: JSON structure ends above.     _WD_IsLatestRelease ==> Success [0] : True     _WD_Startup: OS: WIN_10 WIN32_NT 19044     _WD_Startup: AutoIt: 3.3.14.5     _WD_Startup: Webdriver UDF: 0.11.0 (Up to date)     _WD_Startup: WinHTTP: 1.6.4.1 (Download latest source at <https://raw.githubusercontent.com/dragana-r/autoit-winhttp/master/WinHttp.au3>)     _WD_Startup: Driver: msedgedriver.exe (32 Bit)     _WD_Startup: Params:     _WD_Startup: Port: 9515     _WD_Startup: Command: "msedgedriver.exe"     _WD_Startup ==> Success [0]     __WD_Post ==> Success [0] : HTTP status = 200     _WD_CreateSession ==> Success [0] : 24b684615014c4a222d1738961df3d1d #2: Starting process #2 "C:\Program Files (x86)\AutoIt3\AutoIt3.exe" "C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "d:\TS1959\TS1959 V2.0 DEV one server\edge_attach.au3" [PID 5676]     +>16:21:52 Starting AutoIt3Wrapper (19.1127.1402.0} from:Code.exe (1.73.1.0) Keyboard:00000809 OS:WIN_10/ CPU:X64 OS:X64 Environment(Language:0409)     >Running AU3Check (3.3.14.5) from:C:\Program Files (x86)\AutoIt3 input:d:\TS1959\TS1959 V2.0 DEV one server\edge_attach.au3     +>16:21:53 AU3Check ended.rc:0     >Running:(3.3.14.5):C:\Program Files (x86)\AutoIt3\autoit3.exe "d:\TS1959\TS1959 V2.0 DEV one server\edge_attach.au3" /errorstdout     +>Setting Hotkeys...--> Press Ctrl+Alt+Pausebreak to Restart or Ctrl+Pausebreak to Stop.     _WD_Option ==> Success [0] : Parameters: Option=Driver Value=msedgedriver.exe     _WD_Option ==> Success [0] : Parameters: Option=Port Value=9515     _WD_CapabilitiesAdd ==> Success [0] : Successfully used [firstMatch] with specified browser: msedge     _WD_CapabilitiesAdd ==> Success [0] : Successfully added capability     _WD_CapabilitiesAdd ==> Success [0] : Successfully added capability     _WD_CapabilitiesAdd ==> Success [0] : Successfully added capability     _WD_CapabilitiesAdd ==> Success [0] : Successfully added capability     _WD_CapabilitiesDump: JSON structure starts below: 103 :WebDriver:Capabilities:     {      "capabilities":{      "firstMatch":[      {      "ms:edgeOptions":{      "binary":"C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe",      "debuggerAddress":"localhost:9222"      }      }      ]      }     }     _WD_CapabilitiesDump: JSON structure ends above.     _WD_IsLatestRelease ==> Success [0] : True     _WD_Startup: OS: WIN_10 WIN32_NT 19044     _WD_Startup: AutoIt: 3.3.14.5     _WD_Startup: Webdriver UDF: 0.11.0 (Up to date)     _WD_Startup: WinHTTP: 1.6.4.1 (Download latest source at <https://raw.githubusercontent.com/dragana-r/autoit-winhttp/master/WinHttp.au3>)     _WD_Startup: Driver: msedgedriver.exe (32 Bit)     _WD_Startup: Params:     _WD_Startup: Port: 9515     _WD_Startup: Command: "msedgedriver.exe"     _WD_Startup ==> Success [0]     __WD_Post ==> Success [0] : HTTP status = 200     _WD_CreateSession ==> Success [0] : 7ab36aeb7e89c5e4e823278c602f5d68     __WD_Get ==> Success [0] : HTTP status = 200     _WD_Window ==> Success [0] : Parameters: Command=window Option=Default     __WD_Post ==> Success [0] : HTTP status = 200     _WD_Window ==> Success [0] : Parameters: Command=new Option={"type":"tab"}     __WD_Post ==> Success [0] : HTTP status = 200     _WD_Window ==> Success [0] : Parameters: Command=Switch Option={"handle":"CDwindow-E4BC94DC56CAAAA261A726EBB16F6EEA"}     _WD_NewTab ==> Success [0] : Parameters: Switch=Default Timeout=Default URL=Default Features=Default     __WD_Post ==> Success [0] : HTTP status = 200     _WD_Navigate ==> Success [0] : Parameters: URL=https://www.google.com/ #3: Starting process #3 "C:\Program Files (x86)\AutoIt3\AutoIt3.exe" "C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "d:\TS1959\TS1959 V2.0 DEV one server\edge_attach.au3" [PID 15024]     +>16:21:59 Starting AutoIt3Wrapper (19.1127.1402.0} from:Code.exe (1.73.1.0) Keyboard:00000809 OS:WIN_10/ CPU:X64 OS:X64 Environment(Language:0409)     >Running AU3Check (3.3.14.5) from:C:\Program Files (x86)\AutoIt3 input:d:\TS1959\TS1959 V2.0 DEV one server\edge_attach.au3 #2: __WD_Post ==> Success [0] : HTTP status = 200     _WD_Navigate ==> Success [0] : Parameters: URL=https://www.bing.com/ #3: +>16:22:00 AU3Check ended.rc:0     >Running:(3.3.14.5):C:\Program Files (x86)\AutoIt3\autoit3.exe "d:\TS1959\TS1959 V2.0 DEV one server\edge_attach.au3" /errorstdout     +>Setting Hotkeys...--> Press Ctrl+Alt+Pausebreak to Restart or Ctrl+Pausebreak to Stop. #2: __WD_Post ==> Success [0] : HTTP status = 200     _WD_Navigate ==> Success [0] : Parameters: URL=https://www.google.com/ #3: _WD_Option ==> Success [0] : Parameters: Option=Driver Value=msedgedriver.exe     _WD_Option ==> Success [0] : Parameters: Option=Port Value=9515     _WD_CapabilitiesAdd ==> Success [0] : Successfully used [firstMatch] with specified browser: msedge     _WD_CapabilitiesAdd ==> Success [0] : Successfully added capability     _WD_CapabilitiesAdd ==> Success [0] : Successfully added capability     _WD_CapabilitiesAdd ==> Success [0] : Successfully added capability     _WD_CapabilitiesAdd ==> Success [0] : Successfully added capability     _WD_CapabilitiesDump: JSON structure starts below: 103 :WebDriver:Capabilities:     {      "capabilities":{      "firstMatch":[      {      "ms:edgeOptions":{      "binary":"C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe",      "debuggerAddress":"localhost:9222"      }      }      ]      }     }     _WD_CapabilitiesDump: JSON structure ends above. #2: __WD_Post ==> Invalid session ID [15] : HTTP status = 404     _WD_Navigate ==> Invalid session ID [15] : Parameters: URL=https://www.bing.com/ #3: _WD_IsLatestRelease ==> Success [0] : True     _WD_Startup: OS: WIN_10 WIN32_NT 19044     _WD_Startup: AutoIt: 3.3.14.5     _WD_Startup: Webdriver UDF: 0.11.0 (Up to date)     _WD_Startup: WinHTTP: 1.6.4.1 (Download latest source at <https://raw.githubusercontent.com/dragana-r/autoit-winhttp/master/WinHttp.au3>)     _WD_Startup: Driver: msedgedriver.exe (32 Bit)     _WD_Startup: Params:     _WD_Startup: Port: 9515     _WD_Startup: Command: "msedgedriver.exe"     _WD_Startup ==> Success [0]     __WD_Post ==> Success [0] : HTTP status = 200     _WD_CreateSession ==> Success [0] : a430641de274bdf28198f4c936786e75     __WD_Get ==> Success [0] : HTTP status = 200     _WD_Window ==> Success [0] : Parameters: Command=window Option=Default     __WD_Post ==> Success [0] : HTTP status = 200     _WD_Window ==> Success [0] : Parameters: Command=new Option={"type":"tab"}     __WD_Post ==> Success [0] : HTTP status = 200     _WD_Window ==> Success [0] : Parameters: Command=Switch Option={"handle":"CDwindow-DA41450416DD5749E8BA5D2C07DAE0AA"}     _WD_NewTab ==> Success [0] : Parameters: Switch=Default Timeout=Default URL=Default Features=Default #2: __WD_Post ==> Invalid session ID [15] : HTTP status = 404     _WD_Navigate ==> Invalid session ID [15] : Parameters: URL=https://www.google.com/ #3: __WD_Post ==> Success [0] : HTTP status = 200     _WD_Navigate ==> Success [0] : Parameters: URL=https://www.google.com/ #2: __WD_Post ==> Invalid session ID [15] : HTTP status = 404     _WD_Navigate ==> Invalid session ID [15] : Parameters: URL=https://www.bing.com/ #3: __WD_Post ==> Success [0] : HTTP status = 200     _WD_Navigate ==> Success [0] : Parameters: URL=https://www.bing.com/ #2: __WD_Post ==> Invalid session ID [15] : HTTP status = 404     _WD_Navigate ==> Invalid session ID [15] : Parameters: URL=https://www.google.com/ #3: __WD_Post ==> Success [0] : HTTP status = 200     _WD_Navigate ==> Success [0] : Parameters: URL=https://www.google.com/ #2: __WD_Post ==> Invalid session ID [15] : HTTP status = 404     _WD_Navigate ==> Invalid session ID [15] : Parameters: URL=https://www.bing.com/ #3: __WD_Post ==> Success [0] : HTTP status = 200     _WD_Navigate ==> Success [0] : Parameters: URL=https://www.bing.com/ #2: ! Program will be cancelled.     +>16:22:08 AutoIt3Wrapper Finished.     >>Exit code 0 Time: 16.194 #3: >>Exit code 0 (SIGTERM) Time: 10.194 #1: >>Exit code 0 (SIGTERM) Time: 25.173 Running on Windows 10. Edge: Version 108.0.1462.76 (Official build) (64-bit) Driver: 108.0.1462.76 Any help would be much appreciated! Include.zip msedge.log
×
×
  • Create New...