Jump to content

Recommended Posts

Posted (edited)

@Danp2

Beautiful.  Too funny though and ironic.  I think I need to create some intelligence (just like what you created for _WD_UpdateDriver ) in my apps now that somehow checks your github code and compare them to the UDF sourcecode and download them if they are out of date.

 

Thanks again Dan and mLipok

Edited by NassauSky
Posted (edited)

@Danp2

Thanks I saw that in wd_core and found the actual function in wd_helper.  Still will take some thought on my part to figure out how to "auto" download it from github when it realizes I have an old version. Next Project ... 🙂

 

Edited by NassauSky
Posted

After new update of Chrome 115, I have problems.

I downloaded the latest UDF 1.1.0 and  latest chromeDriver 114.

The previous capabilities I used, doesn't work anymore: it doesn't create a session: err 10 (I tried also 64bit driver); instead creating a session without capabilities works.

 

#include "WebDriver-110/wd_helper.au3"
#include "WebDriver-110/wd_core.au3" 

#AutoIt3Wrapper_UseX64=Y  

global $sDesiredCapabilitiesHide, $sDesiredCapabilitiesNoSecur, $sChromeH10, $sSession= '', $sSessionH10 = '' 

$_WD_DEBUG =  $_WD_DEBUG_Info
global $errDriver = _WD_Option('Driver', 'chromedriver.exe')
ConsoleWrite( $errDriver & " _errDriv:" & @error & "_ext:" & @extended & @CRLF)  ; err:0_ext:200  = OK
 _WD_Option('Port', 9515)
 _WD_ConsoleVisible(true)

;~ global $sChromeH10                               = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["--headless --user-data-dir=C:\\Users\\' & @UserName & '\\AppData\\Local\\Google\\Chrome\\User Data\\", "--profile-directory=Default"]}}}}'
;~ global $sChromeH10                               = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["start-maximized", "disable-infobars", " --user-data-dir=C:\\Users\\' & @UserName & '\\AppData\\Local\\Google\\Chrome\\User Data\\", "--profile-directory=Default"]}}}}'
global $sChromeH10                              = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["start-maximized",  " --user-data-dir=C:\\Users\\' & @UserName & '\\AppData\\Local\\Google\\Chrome\\User Data\\", "--profile-directory=Default"]}}}}'
global $sDesiredCapabilitiesHide                = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["--auto-open-devtools-for-tabs","--user-data-dir=C:\\Users\\' & @UserName & '\\AppData\\Local\\Google\\Chrome\\User Data\\", "--profile-directory=Default"]}}}}'

;~ Local $lResult = _WD_UpdateDriver('chrome', Default, Default,True) ; update chrome driver

_WD_Startup()
If @error <> $_WD_ERROR_Success Then MsgBox(0,'','error')

    ; --------------ERR:
    $sSessionH10 = _WD_CreateSession($sChromeH10)
    ConsoleWrite( $sSessionH10 & "_errSess:" & @error & "_ext:" & @extended & @CRLF)  ; err:0_ext:200  = OK
    MsgBox(0,'','1° WIN chrome ' & $sSessionH10)

; !! MAIN WINDOW CHROME OK!!:
$sSession = _WD_CreateSession() 
ConsoleWrite( $sSession & "_errSessNorm:" & @error & "_ext:" & @extended & @CRLF)  ; err:0_ext:200  = OK
MsgBox(0,'','2° MAIN win chrome' & $sSession)

 

Starting process #9
"C:\Program Files (x86)\AutoIt3\AutoIt3.exe" "C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "d:\Surface7\____AMAZON_Kindle_SelfPublishing\PROG_analisiKW\_testWD_.au3" [PID 15012]
+>10:51:45 Starting AutoIt3Wrapper (19.1127.1402.0} from:Code.exe (1.80.2.0)  Keyboard:00000410  OS:WIN_10/  CPU:X64 OS:X64  Environment(Language:0410)
>Running AU3Check (3.3.14.5)  from:C:\Program Files (x86)\AutoIt3  input:d:\Surface7\____AMAZON_Kindle_SelfPublishing\PROG_analisiKW\_testWD_.au3
+>10:51:46 AU3Check ended.rc:0
>Running:(3.3.14.5):C:\Program Files (x86)\AutoIt3\autoit3_x64.exe "d:\Surface7\____AMAZON_Kindle_SelfPublishing\PROG_analisiKW\_testWD_.au3"  /errorstdout
+>Setting Hotkeys...--> Press Ctrl+Alt+Pausebreak to Restart or Ctrl+Pausebreak to Stop.
_WD_Option ==> Success [0] : Parameters:   Option=Driver   Value=chromedriver.exe
1 _errDriv:0_ext:0
_WD_Option ==> Success [0] : Parameters:   Option=Port   Value=9515
_WD_GetFreePort ==> Success [0 / 9515] : Parameters:   MinPort=9515   MaxPort=Default
_WD_IsLatestRelease ==> Success [0] : True
_WD_Startup: OS:    WIN_10 X64 19045 
_WD_Startup: AutoIt:    3.3.14.5
_WD_Startup: Webdriver UDF: 1.1.0 (Up to date)
_WD_Startup: WinHTTP:   1.6.4.2
_WD_Startup: Driver:    chromedriver.exe (32 Bit)
_WD_Startup: Params:    
_WD_Startup: Port:  9515
_WD_Startup: Command:   "chromedriver.exe"  
_WD_Startup ==> Success [0]
__WD_Post ==> Webdriver Exception [10] : HTTP status = 500
_WD_CreateSession ==> Webdriver Exception [10]
_errSess:10_ext:0
__WD_Post ==> Success [0] : HTTP status = 200
_WD_CreateSession ==> Success [0] : dcc1b954e684ee06d386f272795dd5a8
dcc1b954e684ee06d386f272795dd5a8_errSessNorm:0_ext:0

 

Posted (edited)
  On 7/29/2023 at 8:58 AM, frank10 said:
global $sChromeH10                              = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["start-maximized",  " --user-data-dir=C:\\Users\\' & @UserName & '\\AppData\\Local\\Google\\Chrome\\User Data\\", "--profile-directory=Default"]}}}}'
global $sDesiredCapabilitiesHide                = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["--auto-open-devtools-for-tabs","--user-data-dir=C:\\Users\\' & @UserName & '\\AppData\\Local\\Google\\Chrome\\User Data\\", "--profile-directory=Default"]}}}}'
Expand  

Please use _WD_Capabilities***()

in the link below you can find an advanced usage example

https://github.com/mlipok/Au3WebDriver-testing/blob/a9375043de20645b5a861ee965d93e17fd6ab99b/wd_testing_helper.au3#L141-L181

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

I'm sorry, it doesn't work...

I changed 2 capabilities: without guest and with my current user-data dir: it opens chrome as expected, but it doesn't create the session: err10...

 

#include "WebDriver-110/wd_helper.au3"
#include "WebDriver-110/wd_core.au3" 
#include "WebDriver-110/wd_capabilities.au3" 

#AutoIt3Wrapper_UseX64=Y  

global $sDesiredCapabilitiesHide, $sDesiredCapabilitiesNoSecur, $sChromeH10, $sSession= '', $sSessionH10 = '' 

$_WD_DEBUG =  $_WD_DEBUG_Info ; False ;     You could also use $_WD_DEBUG_Error
global $errDriver = _WD_Option('Driver', 'chromedriver.exe')
ConsoleWrite( $errDriver & " _errDriv:" & @error & "_ext:" & @extended & @CRLF)  ; err:0_ext:200  = OK
 _WD_Option('Port', _WD_GetFreePort())
Local $sDriverParams = '--verbose --log trace --port=' & $_WD_PORT
_WD_Option('DriverParams', $sDriverParams)

;~ global $sChromeH10                               = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["--headless --user-data-dir=C:\\Users\\' & @UserName & '\\AppData\\Local\\Google\\Chrome\\User Data\\", "--profile-directory=Default"]}}}}'
;~ global $sChromeH10                               = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["start-maximized", "disable-infobars", " --user-data-dir=C:\\Users\\' & @UserName & '\\AppData\\Local\\Google\\Chrome\\User Data\\", "--profile-directory=Default"]}}}}'
;~  global $sChromeH10                              = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["start-maximized",  " --user-data-dir=C:\\Users\\' & @UserName & '\\AppData\\Local\\Google\\Chrome\\User Data\\", "--profile-directory=Default"]}}}}'
global $sDesiredCapabilitiesHide                = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["--auto-open-devtools-for-tabs","--user-data-dir=C:\\Users\\' & @UserName & '\\AppData\\Local\\Google\\Chrome\\User Data\\", "--profile-directory=Default"]}}}}'

;~ Local $lResult = _WD_UpdateDriver('chrome', Default, Default,True) ; update chrome driver

    ; --------------ERR:
    global $sChromeH10 = _WD_SetupChrome(false, "", false)
    _WD_Startup()
    If @error <> $_WD_ERROR_Success Then MsgBox(0,'','error')
    $sSessionH10 = _WD_CreateSession($sChromeH10)
    ConsoleWrite( $sSessionH10 & "_errSess:" & @error & "_ext:" & @extended & @CRLF)  ; err:0_ext:200  = OK
    MsgBox(0,'','1° WIN chrome ' & $sSessionH10)

; !! MAIN WINDOW CHROME OK!!:
$sSession = _WD_CreateSession() 
ConsoleWrite( $sSession & "_errSessNorm:" & @error & "_ext:" & @extended & @CRLF)  ; err:0_ext:200  = OK
MsgBox(0,'','2° MAIN win chrome' & $sSession)


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', 'user-data-dir', @LocalAppDataDir & '\Google\Chrome\User Data\')
    _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
Starting process #24
"C:\Program Files (x86)\AutoIt3\AutoIt3.exe" "C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "d:\Surface7\____AMAZON_Kindle_SelfPublishing\PROG_analisiKW\_testWD_.au3" [PID 12392]
+>11:38:16 Starting AutoIt3Wrapper (19.1127.1402.0} from:Code.exe (1.80.2.0)  Keyboard:00000410  OS:WIN_10/  CPU:X64 OS:X64  Environment(Language:0410)
>Running AU3Check (3.3.14.5)  from:C:\Program Files (x86)\AutoIt3  input:d:\Surface7\____AMAZON_Kindle_SelfPublishing\PROG_analisiKW\_testWD_.au3
+>11:38:17 AU3Check ended.rc:0
>Running:(3.3.14.5):C:\Program Files (x86)\AutoIt3\autoit3_x64.exe "d:\Surface7\____AMAZON_Kindle_SelfPublishing\PROG_analisiKW\_testWD_.au3"  /errorstdout
+>Setting Hotkeys...--> Press Ctrl+Alt+Pausebreak to Restart or Ctrl+Pausebreak to Stop.
_WD_Option ==> Success [0] : Parameters:   Option=Driver   Value=chromedriver.exe
1 _errDriv:0_ext:0
_WD_GetFreePort ==> Success [0 / 64001] : Parameters:   MinPort=Default   MaxPort=Default
_WD_Option ==> Success [0] : Parameters:   Option=Port   Value=64001
_WD_Option ==> Success [0] : Parameters:   Option=DriverParams   Value=--verbose --log trace --port=64001
_WD_Option ==> Success [0] : Parameters:   Option=Driver   Value=chromedriver.exe
_WD_GetFreePort ==> Success [0 / 64001] : Parameters:   MinPort=Default   MaxPort=Default
_WD_Option ==> Success [0] : Parameters:   Option=Port   Value=64001
_WD_Option ==> Success [0] : Parameters:   Option=DriverParams   Value=--verbose --log trace --port=64001
_WD_CapabilitiesAdd ==> Success [0] : Successfully used [alwaysMatch]  with specified browser: chrome
_WD_CapabilitiesAdd ==> Success [0] : Successfully added capability
_WD_CapabilitiesAdd ==> Success [0] : Successfully added capability
_WD_CapabilitiesAdd ==> Success [0] : Successfully added capability
_WD_GetBrowserPath ==> Success [0 / 0] : Parameters:    Browser=chrome
_WD_GetBrowserVersion ==> Success [0 / 0] : Parameters:    Browser=chrome
_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_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_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_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_GetFreePort ==> Success [0 / 64001] : Parameters:   MinPort=64001   MaxPort=Default
_WD_IsLatestRelease ==> Success [0] : True
_WD_Startup: OS:    WIN_10 X64 19045 
_WD_Startup: AutoIt:    3.3.14.5
_WD_Startup: Webdriver UDF: 1.1.0 (Up to date)
_WD_Startup: WinHTTP:   1.6.4.2
_WD_Startup: Driver:    chromedriver.exe (32 Bit)
_WD_Startup: Params:    --verbose --log trace --port=64001
_WD_Startup: Port:  64001
_WD_Startup: Command:   "chromedriver.exe" --verbose --log trace --port=64001 
_WD_Startup ==> Success [0]
__WD_Post ==> Webdriver Exception [10] : HTTP status = 500
_WD_CreateSession ==> Webdriver Exception [10]
_errSess:10_ext:0
__WD_Post ==> Success [0] : HTTP status = 200
_WD_CreateSession ==> Success [0] : 4cdac429faf3df9e949c0c937f827909
4cdac429faf3df9e949c0c937f827909_errSessNorm:0_ext:0

 

Posted

1. in the last post: Did you put correct code ?
2. please post code as code and output as quote (not as a part of code)

image.png

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted (edited)
#include "WebDriver-110/wd_helper.au3"
#include "WebDriver-110/wd_core.au3" 
#include "WebDriver-110/wd_capabilities.au3" 

#AutoIt3Wrapper_UseX64=Y  

global $sDesiredCapabilitiesHide, $sDesiredCapabilitiesNoSecur, $sChromeH10, $sSession= '', $sSessionH10 = '' 

$_WD_DEBUG =  $_WD_DEBUG_Info ; False ;     You could also use $_WD_DEBUG_Error
global $errDriver = _WD_Option('Driver', 'chromedriver.exe')
ConsoleWrite( $errDriver & " _errDriv:" & @error & "_ext:" & @extended & @CRLF)  ; err:0_ext:200  = OK
 _WD_Option('Port', _WD_GetFreePort())
Local $sDriverParams = '--verbose --log trace --port=' & $_WD_PORT
_WD_Option('DriverParams', $sDriverParams)

;~ global $sChromeH10                               = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["--headless --user-data-dir=C:\\Users\\' & @UserName & '\\AppData\\Local\\Google\\Chrome\\User Data\\", "--profile-directory=Default"]}}}}'
;~ global $sChromeH10                               = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["start-maximized", "disable-infobars", " --user-data-dir=C:\\Users\\' & @UserName & '\\AppData\\Local\\Google\\Chrome\\User Data\\", "--profile-directory=Default"]}}}}'
;~  global $sChromeH10                              = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["start-maximized",  " --user-data-dir=C:\\Users\\' & @UserName & '\\AppData\\Local\\Google\\Chrome\\User Data\\", "--profile-directory=Default"]}}}}'
;~ global $sDesiredCapabilitiesHide                 = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["--auto-open-devtools-for-tabs","--user-data-dir=C:\\Users\\' & @UserName & '\\AppData\\Local\\Google\\Chrome\\User Data\\", "--profile-directory=Default"]}}}}'

;~ Local $lResult = _WD_UpdateDriver('chrome', Default, Default,True) ; update chrome driver


    ; --------------ERR:
    global $sChromeH10 = _WD_SetupChrome(false, "", false)
    _WD_Startup()
    If @error <> $_WD_ERROR_Success Then MsgBox(0,'','error')
    $sSessionH10 = _WD_CreateSession($sChromeH10)
    ConsoleWrite( $sSessionH10 & "_errSess:" & @error & "_ext:" & @extended & @CRLF)  ; err:0_ext:200  = OK
    MsgBox(0,'','1° WIN chrome ' & $sSessionH10)



; !! MAIN WINDOW CHROME OK!!:
$sSession = _WD_CreateSession() 
ConsoleWrite( $sSession & "_errSessNorm:" & @error & "_ext:" & @extended & @CRLF)  ; err:0_ext:200  = OK
MsgBox(0,'','2° MAIN win chrome' & $sSession)


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', 'user-data-dir', @LocalAppDataDir & '\Google\Chrome\User Data\')
    _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

 

my output with sSessionH10 Err 10:

  Quote

Starting process #1

"C:\Program Files (x86)\AutoIt3\AutoIt3.exe" "C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "d:\Surface7\____AMAZON_Kindle_SelfPublishing\PROG_analisiKW\_testWD_.au3" [PID 10816]

+>12:21:29 Starting AutoIt3Wrapper (19.1127.1402.0} from:Code.exe (1.80.2.0)  Keyboard:00000410  OS:WIN_10/  CPU:X64 OS:X64  Environment(Language:0410)

>Running AU3Check (3.3.14.5)  from:C:\Program Files (x86)\AutoIt3  input:d:\Surface7\____AMAZON_Kindle_SelfPublishing\PROG_analisiKW\_testWD_.au3

+>12:21:29 AU3Check ended.rc:0

>Running:(3.3.14.5):C:\Program Files (x86)\AutoIt3\autoit3_x64.exe "d:\Surface7\____AMAZON_Kindle_SelfPublishing\PROG_analisiKW\_testWD_.au3"  /errorstdout

+>Setting Hotkeys...--> Press Ctrl+Alt+Pausebreak to Restart or Ctrl+Pausebreak to Stop.

_WD_Option ==> Success [0] : Parameters:   Option=Driver   Value=chromedriver.exe

1 _errDriv:0_ext:0

_WD_GetFreePort ==> Success [0 / 64000] : Parameters:   MinPort=Default   MaxPort=Default

_WD_Option ==> Success [0] : Parameters:   Option=Port   Value=64000

_WD_Option ==> Success [0] : Parameters:   Option=DriverParams   Value=--verbose --log trace --port=64000

_WD_Option ==> Success [0] : Parameters:   Option=Driver   Value=chromedriver.exe

_WD_GetFreePort ==> Success [0 / 64000] : Parameters:   MinPort=Default   MaxPort=Default

_WD_Option ==> Success [0] : Parameters:   Option=Port   Value=64000

_WD_Option ==> Success [0] : Parameters:   Option=DriverParams   Value=--verbose --log trace --port=64000

_WD_CapabilitiesAdd ==> Success [0] : Successfully used [alwaysMatch]  with specified browser: chrome

_WD_CapabilitiesAdd ==> Success [0] : Successfully added capability

_WD_CapabilitiesAdd ==> Success [0] : Successfully added capability

_WD_CapabilitiesAdd ==> Success [0] : Successfully added capability

_WD_GetBrowserPath ==> Success [0 / 0] : Parameters:    Browser=chrome

_WD_GetBrowserVersion ==> Success [0 / 0] : Parameters:    Browser=chrome

_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_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_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_CapabilitiesAdd ==> Success [0] : Successfully added capability

_WD_CapabilitiesAdd ==> Success [0] : Successfully added capability

_WD_CapabilitiesAdd ==> Success [0] : Successfully added capability

_WD_GetFreePort ==> Success [0 / 64000] : Parameters:   MinPort=64000   MaxPort=Default

_WD_IsLatestRelease ==> Success [0] : True

_WD_Startup: OS:    WIN_10 X64 19045

_WD_Startup: AutoIt:    3.3.14.5

_WD_Startup: Webdriver UDF: 1.1.0 (Up to date)

_WD_Startup: WinHTTP:   1.6.4.2

_WD_Startup: Driver:    chromedriver.exe (32 Bit)

_WD_Startup: Params:    --verbose --log trace --port=64000

_WD_Startup: Port:  64000

_WD_Startup: Command:   "chromedriver.exe" --verbose --log trace --port=64000

_WD_Startup ==> Success [0]

__WD_Post ==> Send / Recv error [6] : HTTP status = 0

_WD_CreateSession ==> Webdriver Exception [10]

_errSess:10_ext:0

__WD_Post ==> Success [0] : HTTP status = 200

_WD_CreateSession ==> Success [0] : 0ced39e22c7823e987b267b76430e5d9

0ced39e22c7823e987b267b76430e5d9_errSessNorm:0_ext:0

Expand  

 

Edited by frank10
Posted

try to modify this code:

  On 7/29/2023 at 9:42 AM, frank10 said:
global $sChromeH10 = _WD_SetupChrome(false, "", false)
    _WD_Startup()
    If @error <> $_WD_ERROR_Success Then MsgBox(0,'','error')
    $sSessionH10 = _WD_CreateSession($sChromeH10)

 

Expand  

in this way:

Global $sChromeH10 = _WD_SetupChrome(false, "", false)
_WD_DebugSwitch($_WD_DEBUG_Full)
_WD_Startup()

If @error <> $_WD_ERROR_Success Then MsgBox(0,'','error')
$sSessionH10 = _WD_CreateSession($sChromeH10)

_WD_DebugSwitch()

and put here logs.

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted (edited)
  On 7/29/2023 at 10:22 AM, frank10 said:
;~ global $sChromeH10                               = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["--headless --user-data-dir=C:\\Users\\' & @UserName & '\\AppData\\Local\\Google\\Chrome\\User Data\\", "--profile-directory=Default"]}}}}'
;~ global $sChromeH10                               = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["start-maximized", "disable-infobars", " --user-data-dir=C:\\Users\\' & @UserName & '\\AppData\\Local\\Google\\Chrome\\User Data\\", "--profile-directory=Default"]}}}}'
;~  global $sChromeH10                              = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["start-maximized",  " --user-data-dir=C:\\Users\\' & @UserName & '\\AppData\\Local\\Google\\Chrome\\User Data\\", "--profile-directory=Default"]}}}}'
;~ global $sDesiredCapabilitiesHide                 = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["--auto-open-devtools-for-tabs","--user-data-dir=C:\\Users\\' & @UserName & '\\AppData\\Local\\Google\\Chrome\\User Data\\", "--profile-directory=Default"]}}}}'

;~ Local $lResult = _WD_UpdateDriver('chrome', Default, Default,True) ; update chrome driver
Expand  

and do not pollute this thread with commented sphaghetti ;)

 

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted
  Quote

Starting process #2

"C:\Program Files (x86)\AutoIt3\AutoIt3.exe" "C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "d:\Surface7\____AMAZON_Kindle_SelfPublishing\PROG_analisiKW\_testWD_.au3" [PID 9572]

+>12:42:17 Starting AutoIt3Wrapper (19.1127.1402.0} from:Code.exe (1.80.2.0)  Keyboard:00000410  OS:WIN_10/  CPU:X64 OS:X64  Environment(Language:0410)

>Running AU3Check (3.3.14.5)  from:C:\Program Files (x86)\AutoIt3  input:d:\Surface7\____AMAZON_Kindle_SelfPublishing\PROG_analisiKW\_testWD_.au3

+>12:42:17 AU3Check ended.rc:0

>Running:(3.3.14.5):C:\Program Files (x86)\AutoIt3\autoit3_x64.exe "d:\Surface7\____AMAZON_Kindle_SelfPublishing\PROG_analisiKW\_testWD_.au3"  /errorstdout

+>Setting Hotkeys...--> Press Ctrl+Alt+Pausebreak to Restart or Ctrl+Pausebreak to Stop.

_WD_Option ==> Success [0] : Parameters:   Option=Driver   Value=chromedriver.exe

1 _errDriv:0_ext:0

_WD_GetFreePort ==> Success [0 / 64001] : Parameters:   MinPort=Default   MaxPort=Default

_WD_Option ==> Success [0] : Parameters:   Option=Port   Value=64001

_WD_Option ==> Success [0] : Parameters:   Option=DriverParams   Value=--verbose --log trace --port=64001

_WD_Option ==> Success [0] : Parameters:   Option=Driver   Value=chromedriver.exe

_WD_GetFreePort ==> Success [0 / 64001] : Parameters:   MinPort=Default   MaxPort=Default

_WD_Option ==> Success [0] : Parameters:   Option=Port   Value=64001

_WD_Option ==> Success [0] : Parameters:   Option=DriverParams   Value=--verbose --log trace --port=64001

_WD_CapabilitiesAdd ==> Success [0] : Successfully used [alwaysMatch]  with specified browser: chrome

_WD_CapabilitiesAdd ==> Success [0] : Successfully added capability

_WD_CapabilitiesAdd ==> Success [0] : Successfully added capability

_WD_CapabilitiesAdd ==> Success [0] : Successfully added capability

_WD_GetBrowserPath ==> Success [0 / 0] : Parameters:    Browser=chrome

_WD_GetBrowserVersion ==> Success [0 / 0] : Parameters:    Browser=chrome

_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_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_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_CapabilitiesAdd ==> Success [0] : Successfully added capability

_WD_CapabilitiesAdd ==> Success [0] : Successfully added capability

_WD_CapabilitiesAdd ==> Success [0] : Successfully added capability

_WD_DebugSwitch:  /  stack size: 1

_WD_GetFreePort ==> Success [0 / 64001] : Parameters:   MinPort=64001   MaxPort=Default

_WD_IsLatestRelease ==> Success [0] : True

_WD_Startup: OS:    WIN_10 X64 19045

_WD_Startup: AutoIt:    3.3.14.5

_WD_Startup: Webdriver UDF: 1.1.0 (Up to date)

_WD_Startup: WinHTTP:   1.6.4.2

_WD_Startup: Driver:    chromedriver.exe (32 Bit)

_WD_Startup: Params:    --verbose --log trace --port=64001

_WD_Startup: Port:  64001

_WD_Startup: Command:   "chromedriver.exe" --verbose --log trace --port=64001

_WD_Startup ==> Success [0]

__WD_Post: URL=HTTP://127.0.0.1:64001/session; Data={

    "capabilities":{

        "alwaysMatch":{

            "browserName":"chrome",

            "acceptInsecureCerts":true,

            "goog:chromeOptions":{

                "w3c":true,

                "args":[

                    "user-agent=Mozilla\/5.0 (Windows NT 10.0; Win64; X64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/115.0.5790.110 Safari\/537.36",

                    "user-data-dir=C:\\Users\\fsemi\\AppData\\Local\\Google\\Chrome\\User Data\\",

                    "--profile-directory",

                    "start-maximized",

                    "disable-infobars",

                    "--no-sandbox",

                    "--disable-blink-features=AutomationControlled",

                    "--allow-running-insecure-content",

                    "--ignore-certificate-errors"

                ],

                "prefs":{

                    "credentials_enable_service":false,

                    "profile.password_manager_enabled":false

                },

                "excludeSwitches":[

                    "disable-popup-blocking",

                    "enable-automation",

                    "enable-logging",

                    "load-extension"

                ]

            }

        }

    }

}

__WD_Post ==> Send / Recv error [6] : HTTP status = 0 ResponseText=WinHTTP request timed out before Webdriver

_WD_CreateSession ==> Webdriver Exception [10]

_WD_DebugSwitch:  /  stack size: 0

_errSess:10_ext:0

__WD_Post ==> Success [0] : HTTP status = 200

_WD_CreateSession ==> Success [0] : 76f06abadcfca6d6673181685887352b

76f06abadcfca6d6673181685887352b_errSessNorm:0_ext:0

+>12:43:11 AutoIt3.exe ended.rc:0

+>12:43:11 AutoIt3Wrapper Finished.

>>Exit code 0 Time: 54.403

 

Expand  

 

Posted

The problem seems to be in this line:
 

_WD_CapabilitiesAdd('args', 'user-data-dir', @LocalAppDataDir & '\Google\Chrome\User Data\')

Instead of the old one:

_WD_CapabilitiesAdd('args', 'user-data-dir', @LocalAppDataDir & '\Google\Chrome\User Data\WD_Testing_Profile')

With the testing profile, it works but it opens a blank browser, instead with the first row it opens chrome with my last session tabs, and that's what I want and previously worked fine.

Posted (edited)
  On 7/29/2023 at 12:26 PM, Danp2 said:

I think at least part of your issue may lie here because it looks incorrect in the args output. Default is an AutoIt keyword and needs to be enclosed in quotes to be treated as a string instead.

Expand  

hm... I think you found a bug in my GitHub examples:

https://github.com/mlipok/Au3WebDriver-testing/blob/a9375043de20645b5a861ee965d93e17fd6ab99b/wd_testing_helper.au3#L141-L181


It is because according to:

Func _WD_CapabilitiesAdd($key, $value1 = Default, $value2 = Default)
    Local Const $sFuncName = "_WD_CapabilitiesAdd"

    If $value1 = Default Then $value1 = ''
    If $value2 = Default Then $value2 = ''

this line:

_WD_CapabilitiesAdd('args', '--profile-directory', Default)

is equivalent to:

_WD_CapabilitiesAdd('args', '--profile-directory', '')

And I think this should be used/coded the way you mention:

_WD_CapabilitiesAdd('args', '--profile-directory', 'Default')

 

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted (edited)

in the link below you can notice quite good discussion about related issues.

https://superuser.com/questions/377186/how-do-i-start-chrome-using-a-specified-user-profile

And here my question arise:  What differences in usage are between 

--profile-directory

--user-data-dir

 

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted (edited)
  On 7/29/2023 at 12:26 PM, Danp2 said:

I think at least part of your issue may lie here because it looks incorrect in the args output. Default is an AutoIt keyword and needs to be enclosed in quotes to be treated as a string instead.

Expand  

I tried with "Default", and now the

  Quote
"--profile-directory=Default",
Expand  

is correct.  But the session doesn't work anyway: same Err 10.

Here it says if it's the Default profile, it's not even necessary to use "--profile-directory":

  Quote

There's a super easy way to identify the profile directory: go to chrome://version and check the Profile Path. Assuming you are seeing /path/to/your/PROFILE, use --user-data-dir=/path/to/your --profile-directory=PROFILE. If your user data directory is the default location (the last paragraph in the answer) you can omit it.

Expand  

But even without the "--profile-directory" the session doesn't work.

Edited by frank10
Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...