Jump to content

Gladson

Members
  • Posts

    3
  • Joined

  • Last visited

Gladson's Achievements

Seeker

Seeker (1/7)

0

Reputation

  1. Hello! Thanks for the quick reply! I'm a bit new to this stuff so let me ask for further help. I have a SetupChrome function that is called whenever the program starts. That's where I need to add this new line I suppose, but how can I use this change later to attach to the same sessions instead of creating a new one? Func SetupChrome() _WD_Option('Driver', 'chromedriver.exe') Local $iPort = _WD_GetFreePort(5555, 5600) _WD_Option('Port', $iPort) _WD_Option('DriverParams', '--port=' & $iPort & ' --verbose --log-path="' & @ScriptDir & '\chrome.log"') _WD_Startup() If @error Then ConsoleWrite("ERROR: _WD_Startup") Return False EndIf _WD_CapabilitiesStartup() _WD_CapabilitiesAdd('alwaysMatch', 'chrome') _WD_CapabilitiesAdd('w3c', True) _WD_CapabilitiesAdd('excludeSwitches', 'enable-automation') Local $sCapabilities = _WD_CapabilitiesGet() Local $WD_SESSION = _WD_CreateSession($sCapabilities) If @error Then ConsoleWrite("ERROR: _WD_CreateSession") Return False EndIf _WD_Window($WD_SESSION, 'maximize') Return $WD_SESSION EndFunc Global $sSession = SetupChrome() ; ... ; <do my stuff> ; ...
  2. Hello So I have an automation program using Autoit/WebDriver in order to automate some actions using Chrome. I know WebDriver can't attach to an existing Chrome instance that was opened by regular means, but can it reattach to a Chrome window that was previously created by WebDriver itself? My program runs 24x7 but every now and then it closes and I have to restart it. In fact, I have a monitor that re-launches the program as soon as it detects it's down, but the bad news is that whenever it happens, a new Chrome instance is created and I have to go though the log-in process of the system, and that includes a 2 factor authentication. When it happens during the night, it remains off until next morning when an actual person validates the 2 factor authentication. Once a new instance is created, is there any information I could store so I could check it and reattach later, if needed? Maybe the session_id returned by _WD_CreateSession() in a txt file that I could read later, or the handle of window, something like that. I would like to able to check, whenever the program is started, "is the previous session still active? if so, attach to it and resume, if not, create a new session from scratch". Is that possible?
  3. Hello, I've been using AutoIt V3 for a long time but I'm struggling on creating a function to generate a list (an array) of all currently open IE windows. I need the PID, handle, url and title, this is what I've been trying: #include <Array.au3> #include <IE.au3> Func _GetIEList() Local $arrayReturn[1][4] = [["PID", "HWND", "URL", "TITLE"]] ; Lists IE windows Local $listIE = WinList("[REGEXPTITLE:(?i)(.*Internet Explorer.*)]") _ArrayDisplay($listIE, "IE Windows") Local $aProcessList = ProcessList("iexplore.exe") _ArrayDisplay($aProcessList, "IE Processes") For $i=1 To Ubound($listIE)-1 Local $oIE_temp = _IEAttach($listIE[$i][1], "hwnd") If @error == 0 Then Local $aFill[1][4] = [[WinGetProcess($listIE[$i][1]), $listIE[$i][1], _IEPropertyGet($oIE_temp, "locationurl"), $listIE[$i][0]]] _ArrayAdd($arrayReturn, $aFill) EndIf Next Return $arrayReturn EndFunc Local $testReturn = _GetIEList() _ArrayDisplay($testReturn, "Function Return") I list all IE windows with WinList to get their handles and try to associate them with the PID list generated by ProcessList. However, the results are kind of strange sometimes. Not all open windows are shown on $testReturn, PIDs or handles are duplicated, it's a mess. Is there any easier and more trustworthy way of generating this array with the info I need?
×
×
  • Create New...