sergiobaiao Posted December 11, 2023 Share Posted December 11, 2023 Hi there, I'm using AutoIT with webdriver to provide remote apps (aka RDP Applications) which perform an autologin to a website. There's an web app that i need to use and i don't want my colaborators to see the web app login and passwords. What i've acomplished until now is: Created the autoit compiled exe file, put on a folder with the chromedriver.exe and data.ini for each user. (chromedriver.exe and the autoit compiled exe are hardlinks, to make them easier to upgrade) Created the remote apps on Remote Desktop console, distributed the .rdp files for each user If i go user by user, one at a time, it successfully connects to my RDP server, opens chrome at the designated website and perform the auto login process. The problem happens when i login a new user with the old one still logged in. It "restores" the previous "session", with the old one already logged in, and just opens a new browser window and do nothing. This also happens if the user already have an open chrome windows. How can i have "multiple sessions" with the au3WebDriver? This is the code i'm using: expandcollapse popup#include <FileConstants.au3> #include "wd_testing_helper.au3" #include <MsgBoxConstants.au3> #include <WinAPIFiles.au3> _Main() Func _Main() Local Const $sFileName = '.\dados.ini' Local $hFileOpen = FileOpen($sFileName, $FO_READ) Global $seMail = IniRead($sFileName, "DadosLogin", "Email", "") Global $sPwd = IniRead($sFileName, "DadosLogin", "Senha", "") Global $sBrowser = IniRead($sFileName, "DadosLogin", "Browser", "Chrome") If $hFileOpen = -1 Then MsgBox($MB_SYSTEMMODAL, "", "Erro ao abrir arquivo de configuração. Verifique se o arquivo dados.ini existe.") _WD_CleanUp() Return False EndIf Local $bIsInitialized = Null $bIsInitialized = _WD_Initialization($sBrowser, False, False) If $bIsInitialized = Null Then Return _OpenBrowser() ;_WD_CleanUp() EndFunc ;==>_Main Func _OpenBrowser() ;Local Const $sArrayHeader = 'Absolute Identifiers > _WD_FrameEnter|Relative Identifiers > _WD_FrameEnter|FRAME attributes|URL|Body ElementID|IsHidden|MatchedElements' #Region - navigation Local $s_URL = 'https://painel.assertivasolucoes.com.br/login' ; place here website URL which you plan to automate _WD_Navigate($__g_sSession, $s_URL) If @error Then Return SetError(@error, @extended, 0) #EndRegion - navigation #Region - wait until the page has finished loading _WD_LoadWait($__g_sSession) If @error Then Return SetError(@error, @extended, 0) #EndRegion - wait until the page has finished loading #Region - Email Field by Path Local $eMailPath = '//*[@id="email"]' Local $eMailElement = _WD_FindElement($__g_sSession, $_WD_LOCATOR_ByXPath, $eMailPath) If @error Then Return SetError(@error, @extended, 0) _WD_ElementAction($__g_sSession, $eMailElement, 'value', $seMail) If @error Then Return SetError(@error, @extended, 0) #EndRegion - Email Field #Region - Password Field Local $PwdPath = '//*[@id="password"]' Local $PwdElement = _WD_FindElement($__g_sSession, $_WD_LOCATOR_ByXPath, $PwdPath) If @error Then Return SetError(@error, @extended, 0) _WD_ElementAction($__g_sSession, $PwdElement, 'value', $sPwd) _WD_ElementActionEx($__g_sSession, $PwdElement, 'hide') If @error Then Return SetError(@error, @extended, 0) #EndRegion - Password Field #Region - Login Button Local $LoginButtonPath = '//*[@id="btn-entrar"]' Local $LoginButtonElement = _WD_FindElement($__g_sSession, $_WD_LOCATOR_ByXPath, $LoginButtonPath) If @error Then Return SetError(@error, @extended, 0) _WD_ElementAction($__g_sSession, $LoginButtonElement, 'click') If @error Then Return SetError(@error, @extended, 0) #EndRegion - Login Button EndFunc ;==>_OpenBrowser Link to comment Share on other sites More sharing options...
Danp2 Posted December 12, 2023 Share Posted December 12, 2023 It's not possible to give you a definitive answer with the limited information provided, but I would suggest that you read my prior answer to a similar question. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
sergiobaiao Posted December 12, 2023 Author Share Posted December 12, 2023 Hi Danp2, What else do you need to better understand the problem? All i wanted to accomplish is : Have multiple copies of the compiled .exe , one folder for each user Run multiple copies simultaneously, despite the user. For example, if student-01 opens webapp.exe twice, it would open two different browser windows, each with it's own session. Actually, if i open webapp.exe for the first time, it works. If i keep the window open and run webapp.exe again, it would only create a new window from the same session, and doesn't run the automation. Link to comment Share on other sites More sharing options...
Danp2 Posted December 12, 2023 Share Posted December 12, 2023 Hi @sergiobaiao, I understand what you want to do. Did you check out the prior answer that I referenced above? You are likely to find some additional discussions if you use the forum search feature to locate the keywords DRIVERDETECT and DRIVERCLOSE. You are using some custom functions (ie: _WD_Initialization and _WD_CleanUp) for which you haven't shown us the code. Without this code, we can only make semi-educated guesses at what you are doing behind the scenes. 🔮 Dan Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
sergiobaiao Posted December 12, 2023 Author Share Posted December 12, 2023 (edited) Oh, those functions are being called from the include: #include "wd_testing_helper.au3" which in fact includes #include "wd_helper.au3" #include "wd_capabilities.au3" and none of those files were modified. i saw the post you referenced but really didn't understood. I have very little experience with code, and i'm just in a test-error-retry journey on this Edited December 12, 2023 by sergiobaiao Link to comment Share on other sites More sharing options...
Danp2 Posted December 12, 2023 Share Posted December 12, 2023 Sergio, wd_testing_helper.au3 must contain some additional code beyond those two #include lines because the functions I mentioned earlier are not part of the Webdriver UDF. FWIW, the Webdriver UDF is targeted towards the more advanced coding. Adding RDP to the mix will only complicate things for you. I suggest that you takes some time to get this working correctly on your local workstation before you introduce RDP. I've tried to point you in the right direction based upon my understanding of the issue. Please take some time to understand how those _WD_Option settings work, and then let me know if you still have questions. Regards, Dan Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
sergiobaiao Posted December 12, 2023 Author Share Posted December 12, 2023 Dan, RDP is completely outside the context. It's and "after all" I'm trying it locally. If i do the DRIVERCLOSE won't it close the browser window? btw, this is the code of my wd_testing_helper.au3: expandcollapse popup#include <MsgBoxConstants.au3> #include <String.au3> #include <Array.au3> #include "wd_helper.au3" #include "wd_capabilities.au3" Global $__g_sSession #Region - WD SETUP Func _WD_Initialization($sBrowser, $bHeadless = False, $bLogToFile = True) $_WD_HTTPTimeOuts[1] = 1000 ; Connect timeout is now one second ; $_WD_DEBUG = $_WD_DEBUG_None ; details are not provided only set @error and @extended $_WD_DEBUG = $_WD_DEBUG_Error ; Gives minimized level of details ; $_WD_DEBUG = $_WD_DEBUG_Info ; Gives you optimized level of details #REMARK about $_WD_DEBUG_Full usage ; it will also sent yours sensitive/protected/personal data to the log ; $_WD_DEBUG = $_WD_DEBUG_Full ; Gives you the greatest level of details Local $sTimeStamp = @YEAR & '-' & @MON & '-' & @MDAY & '_' & @HOUR & @MIN & @SEC If $bLogToFile Then Local $sLogFile = @ScriptDir & "\Log\" & $sTimeStamp & ' - ' & $sBrowser & ".log" _WD_Option('console', $sLogFile) ConsoleWrite("- Logs will be stored in:" & @CRLF) ConsoleWrite('"' & $sLogFile & '"' & @CRLF) EndIf Local $s_Download_dir = @ScriptDir & "\Au3WebDriver_DownloadDir" Local $sCapabilities = '' Switch $sBrowser Case 'firefox' _WD_UpdateDriver('firefox') $sCapabilities = _WD_SetupGecko($bHeadless, $s_Download_dir) Case 'chrome' #Region - Chrome driver update Local $sBrowserVersion = _WD_GetBrowserVersion($sBrowser) If Not @error And $sBrowser = "chrome" Then Local $i_Check = _VersionCompare("115.0.0.0", $sBrowserVersion) If Not @error And $i_Check = 1 Then $sBrowser = "chrome_legacy" EndIf #EndRegion - Chrome driver update $sCapabilities = _WD_SetupChrome($bHeadless, $s_Download_dir, $bLogToFile) Case 'msedge' _WD_UpdateDriver('msedge') $sCapabilities = _WD_SetupEdge($bHeadless, $s_Download_dir, $bLogToFile) Case 'opera' _WD_UpdateDriver('opera') $sCapabilities = _WD_SetupOpera($bHeadless, $s_Download_dir, $bLogToFile) Case 'msedgeie' _WD_UpdateDriver('msedgeie', Default, False) $sCapabilities = _WD_SetupEdgeIEMode($bHeadless, $s_Download_dir, $bLogToFile) EndSwitch _WD_CapabilitiesDump(@ScriptLineNumber) ; dump current Capabilities setting to console - only for testing _WD_Startup() $__g_sSession = _WD_CreateSession($sCapabilities) If Not @error Then _WD_Window($__g_sSession, "maximize") MsgBox($MB_TOPMOST, "AVISO", "Todos os acessos são monitorados e gravados !") EndFunc ;==>_WD_Initialization Func _WD_CleanUp() ;MsgBox($MB_TOPMOST, "TEST #" & @ScriptLineNumber, "Wait before end - to have possibility to check logs, and browser state") _WD_DeleteSession($__g_sSession) _WD_Shutdown() EndFunc ;==>_WD_CleanUp Func _WD_SetupGecko($bHeadless, $s_Download_dir = '') ;~ Local $sTimeStamp = @YEAR & '-' & @MON & '-' & @MDAY & '_' & @HOUR & @MIN & @SEC _WD_Option('Driver', 'geckodriver.exe') _WD_Option('Port', _WD_GetFreePort()) _WD_Option('DriverParams', '--log trace --port=' & $_WD_PORT) _WD_CapabilitiesStartup() _WD_CapabilitiesAdd('alwaysMatch', 'firefox') _WD_CapabilitiesAdd('browserName', 'firefox') _WD_CapabilitiesAdd('acceptInsecureCerts', True) If $bHeadless Then _WD_CapabilitiesAdd('args', '--headless') _WD_CapabilitiesAdd('args', '-profile') _WD_CapabilitiesAdd('args', @LocalAppDataDir & '\Mozilla\Firefox\Profiles\WD_Testing_Profile') ; https://stackoverflow.com/questions/33695690/webdriver-set-initial-url ;~ _WD_CapabilitiesAdd('prefs', 'rowser.startup.homepage', 'about:blank') ;~ _WD_CapabilitiesAdd('prefs', 'startup.homepage_welcome_url', 'about:blank') ;~ _WD_CapabilitiesAdd('prefs', 'startup.homepage_welcome_url.additional', 'about:blank') ; avoid updates _WD_CapabilitiesAdd('prefs', 'browser.search.update', False) _WD_CapabilitiesAdd('prefs', 'extensions.update.autoUpdate', False) _WD_CapabilitiesAdd('prefs', 'extensions.update.autoUpdateEnabled', False) _WD_CapabilitiesAdd('prefs', 'extensions.update.enabled', False) _WD_CapabilitiesAdd('prefs', 'update_notifications.enabled', False) _WD_CapabilitiesAdd('prefs', 'update.showSlidingNotification', False) _WD_CapabilitiesAdd('prefs', 'app.update.auto', False) _WD_CapabilitiesAdd('prefs', 'app.update.enabled', False) ; How to prevent Firefox to auto-check “remember decision” in certificates choice? ; https://discourse.mozilla.org/t/how-to-prevent-firefox-to-auto-check-remember-decision-in-certificates-choice/88062 _WD_CapabilitiesAdd("prefs", "security.remember_cert_checkbox_default_setting", False) If $s_Download_dir Then _WD_CapabilitiesAdd("prefs", "pdfjs.disabled", True) _WD_CapabilitiesAdd("prefs", "browser.download.folderList", 2) _WD_CapabilitiesAdd("prefs", "browser.download.dir", $s_Download_dir) _WD_CapabilitiesAdd("prefs", "browser.helperApps.neverAsk.saveToDisk", "application/zip, application/pdf, application/octet-stream, application/xml, text/xml, text/plain") _WD_CapabilitiesAdd("prefs", "browser.helperApps.neverAsk.openFile", "application/zip, application/pdf, application/octet-stream, application/xml, text/xml, text/plain") _WD_CapabilitiesAdd('prefs', 'browser.helperApps.alwaysAsk.force', False) _WD_CapabilitiesAdd("prefs", "browser.download.useDownloadDir", True) _WD_CapabilitiesAdd("prefs", "browser.download.alwaysOpenPanel", False) ; CLEANUP for GDPR reason _WD_CapabilitiesAdd('prefs', 'browser.helperApps.deleteTempFileOnExit', True) EndIf ; REMARKS ; When using 32bit geckodriver.exe, you may need to set 'binary' option. ; This shouldn't be needed when using 64bit geckodriver.exe, ; but at the same time setting it is not affecting the script. Local $sPath = _WD_GetBrowserPath("firefox") If Not @error Then _WD_CapabilitiesAdd('binary', $sPath) ConsoleWrite("wd_demo.au3: _WD_GetBrowserPath() > " & $sPath & @CRLF) EndIf Local $sCapabilities = _WD_CapabilitiesGet() Return $sCapabilities EndFunc ;==>SetupGecko Func _WD_SetupChrome($bHeadless, $s_Download_dir = '', $bLogToFile = False) Local $sTimeStamp = @YEAR & '-' & @MON & '-' & @MDAY & '_' & @HOUR & @MIN & @SEC _WD_Option('Driver', 'chromedriver.exe') _WD_Option('Port', _WD_GetFreePort()) Local $sDriverParams = '--verbose --log trace --port=' & $_WD_PORT If $bLogToFile Then $sDriverParams &= ' --log-path="' & @ScriptDir & '\log\' & $sTimeStamp & '_WebDriver_chrome.log"' _WD_Option('DriverParams', $sDriverParams) _WD_CapabilitiesStartup() _WD_CapabilitiesAdd('alwaysMatch', 'chrome') _WD_CapabilitiesAdd('browserName', 'chrome') _WD_CapabilitiesAdd('w3c', True) _WD_CapabilitiesAdd('acceptInsecureCerts', True) _WD_CapabilitiesAdd('args', 'user-agent', 'Mozilla/5.0 (Windows NT 10.0; Win' & StringReplace(@OSArch, 'X', '') & '; ' & @CPUArch & ') AppleWebKit/537.36 (KHTML, like Gecko) Chrome/' & _WD_GetBrowserVersion('chrome') & ' Safari/537.36') _WD_CapabilitiesAdd('args', 'user-data-dir', @LocalAppDataDir & '\Google\Chrome\User Data\WD_Testing_Profile') _WD_CapabilitiesAdd('args', '--profile-directory', Default) _WD_CapabilitiesAdd('args', 'start-maximized') _WD_CapabilitiesAdd('args', 'disable-infobars') _WD_CapabilitiesAdd('args', '--no-sandbox') _WD_CapabilitiesAdd('args', '--disable-blink-features=AutomationControlled') _WD_CapabilitiesAdd('args', '--disable-web-security') _WD_CapabilitiesAdd('args', '--allow-running-insecure-content') ; https://stackoverflow.com/a/60409220 _WD_CapabilitiesAdd('args', '--ignore-certificate-errors') ; https://stackoverflow.com/a/60409220 _WD_CapabilitiesAdd('args', '--guest') If $bHeadless Then _ _WD_CapabilitiesAdd('args', '--headless') _WD_CapabilitiesAdd('prefs', 'credentials_enable_service', False) ; https://www.autoitscript.com/forum/topic/191990-webdriver-udf-w3c-compliant-version-12272021/?do=findComment&comment=1464829 _WD_CapabilitiesAdd('prefs', 'profile.password_manager_enabled', False) ; https://sqa.stackexchange.com/a/26515/14581 #Region - downloading files If $s_Download_dir Then _WD_CapabilitiesAdd('prefs', 'download.default_directory', $s_Download_dir) ; https://scripteverything.com/download-pdf-selenium-python/ ; https://www.autoitscript.com/forum/topic/209816-download-pdf-file-while-using-webdriver/?do=findComment&comment=1514582 _WD_CapabilitiesAdd('prefs', 'download.prompt_for_download', False) _WD_CapabilitiesAdd('prefs', 'download.open_pdf_in_system_reader', False) _WD_CapabilitiesAdd('prefs', 'plugins.always_open_pdf_externally', True) _WD_CapabilitiesAdd('prefs', 'profile.default_content_settings.popups', 0) EndIf #EndRegion - downloading files _WD_CapabilitiesAdd('excludeSwitches', 'disable-popup-blocking') ; https://help.applitools.com/hc/en-us/articles/360007189411--Chrome-is-being-controlled-by-automated-test-software-notification _WD_CapabilitiesAdd('excludeSwitches', 'enable-automation') _WD_CapabilitiesAdd('excludeSwitches', 'enable-logging') _WD_CapabilitiesAdd('excludeSwitches', 'load-extension') ;~ _WD_CapabilitiesAdd('excludeSwitches', 'disable-composited-antialiasing') ; ?? https://source.chromium.org/chromium/chromium/src/+/main:cc/base/switches.cc Local $sCapabilities = _WD_CapabilitiesGet() Return $sCapabilities EndFunc ;==>SetupChrome Func _WD_SetupEdge($bHeadless, $s_Download_dir = '', $bLogToFile = False) Local $sTimeStamp = @YEAR & '-' & @MON & '-' & @MDAY & '_' & @HOUR & @MIN & @SEC _WD_Option('Driver', 'msedgedriver.exe') _WD_Option('Port', _WD_GetFreePort()) Local $sDriverParams = '--verbose --log trace --port=' & $_WD_PORT If $bLogToFile Then $sDriverParams &= ' --log-path="' & @ScriptDir & '\log\' & $sTimeStamp & '_WebDriver_msedge.log"' _WD_Option('DriverParams', $sDriverParams) _WD_CapabilitiesStartup() _WD_CapabilitiesAdd('alwaysMatch', 'msedge') ;~ _WD_CapabilitiesAdd('browserName', 'msedge') _WD_CapabilitiesAdd('w3c', True) _WD_CapabilitiesAdd('acceptInsecureCerts', True) If $bHeadless Then _WD_CapabilitiesAdd('args', '--headless') _WD_CapabilitiesAdd('args', 'user-agent', 'Mozilla/5.0 (Windows NT 10.0; Win' & StringReplace(@OSArch, 'X', '') & '; ' & @CPUArch & ') AppleWebKit/537.36 (KHTML, like Gecko) Edge/' & _WD_GetBrowserVersion('msedge') & ' Safari/537.36') _WD_CapabilitiesAdd('args', 'user-data-dir', @LocalAppDataDir & '\Microsoft\Edge\User Data\WD_Testing_Profile') _WD_CapabilitiesAdd('args', '--profile-directory', Default) _WD_CapabilitiesAdd('args', 'start-maximized') _WD_CapabilitiesAdd('args', 'disable-infobars') _WD_CapabilitiesAdd('args', '--no-sandbox') _WD_CapabilitiesAdd('args', '--disable-blink-features=AutomationControlled') _WD_CapabilitiesAdd('args', '--disable-web-security') _WD_CapabilitiesAdd('args', '--allow-running-insecure-content') ; https://stackoverflow.com/a/60409220 _WD_CapabilitiesAdd('args', '--ignore-certificate-errors') ; https://stackoverflow.com/a/60409220 _WD_CapabilitiesAdd('args', '--guest') _WD_CapabilitiesAdd('prefs', 'credentials_enable_service', False) ; https://www.autoitscript.com/forum/topic/191990-webdriver-udf-w3c-compliant-version-12272021/?do=findComment&comment=1464829 #Region - downloading files If $s_Download_dir Then _WD_CapabilitiesAdd('prefs', 'download.default_directory', $s_Download_dir) ; https://scripteverything.com/download-pdf-selenium-python/ ; https://www.autoitscript.com/forum/topic/209816-download-pdf-file-while-using-webdriver/?do=findComment&comment=1514582 _WD_CapabilitiesAdd('prefs', 'download.prompt_for_download', False) _WD_CapabilitiesAdd('prefs', 'download.open_pdf_in_system_reader', False) _WD_CapabilitiesAdd('prefs', 'plugins.always_open_pdf_externally', True) _WD_CapabilitiesAdd('prefs', 'profile.default_content_settings.popups', 0) EndIf #EndRegion - downloading files _WD_CapabilitiesAdd('excludeSwitches', 'disable-popup-blocking') ; https://help.applitools.com/hc/en-us/articles/360007189411--Chrome-is-being-controlled-by-automated-test-software-notification _WD_CapabilitiesAdd('excludeSwitches', 'enable-automation') _WD_CapabilitiesAdd('excludeSwitches', 'enable-logging') _WD_CapabilitiesAdd('excludeSwitches', 'load-extension') ;~ _WD_CapabilitiesAdd('excludeSwitches', 'disable-composited-antialiasing') ; ?? https://source.chromium.org/chromium/chromium/src/+/main:cc/base/switches.cc Local $sCapabilities = _WD_CapabilitiesGet() Return $sCapabilities EndFunc ;==>SetupEdge Func _WD_SetupOpera($bHeadless, $s_Download_dir = '', $bLogToFile = False) Local $sTimeStamp = @YEAR & '-' & @MON & '-' & @MDAY & '_' & @HOUR & @MIN & @SEC _WD_Option('Driver', 'operadriver.exe') _WD_Option('Port', _WD_GetFreePort()) Local $sDriverParams = '--verbose --log trace --port=' & $_WD_PORT If $bLogToFile Then $sDriverParams &= ' --log-path="' & @ScriptDir & '\log\' & $sTimeStamp & '_WebDriver_opera.log"' _WD_Option('DriverParams', $sDriverParams) _WD_CapabilitiesStartup() _WD_CapabilitiesAdd('alwaysMatch', 'opera') ;~ _WD_CapabilitiesAdd('browserName', 'opera') _WD_CapabilitiesAdd('w3c', True) ;~ _WD_CapabilitiesAdd('acceptInsecureCerts', True) _WD_CapabilitiesAdd('excludeSwitches', 'enable-automation') If $bHeadless Then _WD_CapabilitiesAdd('args', '--headless') _WD_CapabilitiesAdd('args', 'user-agent', 'Mozilla/5.0 (Windows NT 10.0; Win' & StringReplace(@OSArch, 'X', '') & '; ' & @CPUArch & ') AppleWebKit/537.36 (KHTML, like Gecko) Opera/' & _WD_GetBrowserVersion('opera') & ' Safari/537.36') _WD_CapabilitiesAdd('args', 'user-data-dir', @AppDataDir & '\Opera Software\WD_Testing_Profile') ; default is c:\Users\LOGIN\AppData\Roaming\Opera Software\Opera Stable\ _WD_CapabilitiesAdd('args', '--profile-directory', Default) _WD_CapabilitiesAdd('args', 'start-maximized') _WD_CapabilitiesAdd('args', 'disable-infobars') _WD_CapabilitiesAdd('args', '--no-sandbox') _WD_CapabilitiesAdd('args', '--disable-blink-features=AutomationControlled') _WD_CapabilitiesAdd('args', '--disable-web-security') _WD_CapabilitiesAdd('args', '--allow-running-insecure-content') ; https://stackoverflow.com/a/60409220 _WD_CapabilitiesAdd('args', '--ignore-certificate-errors') ; https://stackoverflow.com/a/60409220 _WD_CapabilitiesAdd('args', '--guest') If $bHeadless Then _ _WD_CapabilitiesAdd('args', '--headless') _WD_CapabilitiesAdd('prefs', 'credentials_enable_service', False) ; https://www.autoitscript.com/forum/topic/191990-webdriver-udf-w3c-compliant-version-12272021/?do=findComment&comment=1464829 #Region - downloading files If $s_Download_dir Then _WD_CapabilitiesAdd('prefs', 'download.default_directory', $s_Download_dir) ; https://scripteverything.com/download-pdf-selenium-python/ ; https://www.autoitscript.com/forum/topic/209816-download-pdf-file-while-using-webdriver/?do=findComment&comment=1514582 _WD_CapabilitiesAdd('prefs', 'download.prompt_for_download', False) _WD_CapabilitiesAdd('prefs', 'download.open_pdf_in_system_reader', False) _WD_CapabilitiesAdd('prefs', 'plugins.always_open_pdf_externally', True) _WD_CapabilitiesAdd('prefs', 'profile.default_content_settings.popups', 0) EndIf #EndRegion - downloading files _WD_CapabilitiesAdd('excludeSwitches', 'disable-popup-blocking') ; https://help.applitools.com/hc/en-us/articles/360007189411--Chrome-is-being-controlled-by-automated-test-software-notification _WD_CapabilitiesAdd('excludeSwitches', 'enable-automation') _WD_CapabilitiesAdd('excludeSwitches', 'enable-logging') _WD_CapabilitiesAdd('excludeSwitches', 'load-extension') ;~ _WD_CapabilitiesAdd('excludeSwitches', 'disable-composited-antialiasing') ; ?? https://source.chromium.org/chromium/chromium/src/+/main:cc/base/switches.cc ; REMARKS ; When using 32bit operadriver.exe, you may need to set 'binary' option. ; This shouldn't be needed when using 64bit operadriver.exe, ; but at the same time setting it is not affecting the script. Local $sPath = _WD_GetBrowserPath("opera") If Not @error Then _WD_CapabilitiesAdd('binary', $sPath) ConsoleWrite("wd_demo.au3: _WD_GetBrowserPath() > " & $sPath & @CRLF) EndIf Local $sCapabilities = _WD_CapabilitiesGet() Return $sCapabilities EndFunc ;==>SetupOpera Func _WD_SetupEdgeIEMode($bHeadless, $s_Download_dir = '', $bLogToFile = False) ; this is for MS Edge IE Mode #forceref $bHeadless, $s_Download_dir ; it is Not passed from MSEdge To IE instance, like many others capabilities Local $sTimeStamp = @YEAR & '-' & @MON & '-' & @MDAY & '_' & @HOUR & @MIN & @SEC ; https://www.selenium.dev/documentation/ie_driver_server/#required-configuration _WD_Option('Driver', 'IEDriverServer.exe') _WD_Option('Port', _WD_GetFreePort()) Local $sDriverParams = '-log-level=INFO -port=' & $_WD_PORT & ' -host=127.0.0.1' If $bLogToFile Then $sDriverParams &= ' -log-file="' & @ScriptDir & '\log\' & $sTimeStamp & '_WebDriver_EdgeIEMode.log"' _WD_Option('DriverParams', $sDriverParams) ;~ Local $sCapabilities = '{"capabilities": {"alwaysMatch": { "se:ieOptions" : { "ie.edgepath":"C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe", "ie.edgechromium":true, "ignoreProtectedModeSettings":true,"excludeSwitches": ["enable-automation"]}}}}' _WD_CapabilitiesStartup() _WD_CapabilitiesAdd('alwaysMatch', 'msedgeie') _WD_CapabilitiesAdd('w3c', True) ;~ _WD_CapabilitiesAdd('acceptInsecureCerts', True) Local $sPath = _WD_GetBrowserPath("msedge") If $sPath Then _WD_CapabilitiesAdd("ie.edgepath", $sPath) _WD_CapabilitiesAdd("ie.edgechromium", True) _WD_CapabilitiesAdd("ignoreProtectedModeSettings", True) _WD_CapabilitiesAdd("initialBrowserUrl", "https://google.com") _WD_CapabilitiesDump(@ScriptLineNumber) Local $sCapabilities = _WD_CapabilitiesGet() Return $sCapabilities EndFunc ;==>SetupEdgeIEMode #EndRegion - WD SETUP Link to comment Share on other sites More sharing options...
Danp2 Posted December 12, 2023 Share Posted December 12, 2023 2 hours ago, sergiobaiao said: If i do the DRIVERCLOSE won't it close the browser window? No. The default behavior is to close an existing webdriver instance when launching a new one. If you want to run multiple instances of the webdriver, then you need to use _WD_Option to override the default behavior. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
sergiobaiao Posted December 13, 2023 Author Share Posted December 13, 2023 16 hours ago, Danp2 said: No. The default behavior is to close an existing webdriver instance when launching a new one. If you want to run multiple instances of the webdriver, then you need to use _WD_Option to override the default behavior. So i should use DRIVERCLOSE as false and also DRIVERDETECT as false to launch multiple instances? Link to comment Share on other sites More sharing options...
Danp2 Posted December 13, 2023 Share Posted December 13, 2023 @sergiobaiao Yes, that's what I would suggest trying. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
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