Jump to content

WebDriver UDF - Help & Support (IV)


Recommended Posts

@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
Link to comment
Share on other sites

@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
Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

8 minutes ago, 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"]}}}}'

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:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Link to comment
Share on other sites

#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

 

Edited by frank10
Link to comment
Share on other sites

try to modify this code:

52 minutes ago, frank10 said:
global $sChromeH10 = _WD_SetupChrome(false, "", false)
    _WD_Startup()
    If @error <> $_WD_ERROR_Success Then MsgBox(0,'','error')
    $sSessionH10 = _WD_CreateSession($sChromeH10)

 

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:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Link to comment
Share on other sites

15 minutes ago, 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

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:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Link to comment
Share on other sites

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

 

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

54 minutes ago, 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.

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:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Link to comment
Share on other sites

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:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Link to comment
Share on other sites

1 hour ago, 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.

I tried with "Default", and now the

Quote
"--profile-directory=Default",

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.

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

Edited by frank10
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

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