#include #include "..\wd_helper.au3" ; for wd_helper.au3 take a look: https://github.com/Danp2/WebDriver #REMARK this following line I use for testing, while _wd_Capabilities.au3 UDF is in early Beta version stage #AutoIt3Wrapper_AutoIt3Dir="z:\AutoItPortable\AutoIt_3_3_14_5" #Region - _wd_Capabilities.au3 UDF - UDF Header - early version #CS Core functions: _WD_Capabilities_Startup() _WD_Capabilities_Add() _WD_Capabilities_GetJSON() Yep, there is no more need to use _WD_Capabilities_Argument()  _WD_Capabilities_Preference() etc..... Internal functions: __WD_Capabilities_CreateObject() __WD_Capabilities_SwitchParameters() __WD_Capabilities_JSONNotation() Helper Functions: _WD_Capabilities_GetPrettyJSON() _WD_Capabilities_JSONToConsole() _WD_Capabilities_APIToConsole() _WD_Capabilities_APIDisplay() #CE #TODO _WD_CreateSession: {"value":{"error":"session not created","message":"Unable to find a matching set of capabilities","stacktrace":""}} #EndRegion - _wd_Capabilities.au3 UDF - UDF Header - early version #Region - _wd_Capabilities.au3 UDF - Global's declarations Global Enum _ $_WD_CAPS__STANDARD__Type, _ $_WD_CAPS__STANDARD__FirstIdx, _ $_WD_CAPS__STANDARD__STRINGORBOOL, _ $_WD_CAPS__STANDARD__PROXY, _ $_WD_CAPS__STANDARD__TIMEOUTS, _ $_WD_CAPS__SPECIFICVENDOR__ObjectName, _ $_WD_CAPS__SPECIFICVENDOR__OPTS, _ $_WD_CAPS__SPECIFICVENDOR__ARGS, _ $_WD_CAPS__SPECIFICVENDOR__PREFS, _ $_WD_CAPS__SPECIFICVENDOR__LOG, _ $_WD_CAPS__SPECIFICVENDOR__ENV, _ $_WD_CAPS__SPECIFICVENDOR__EXCSWITCH, _ $_WD_CAPS__COUNTER Global $_WD_CAPS__API[0][$_WD_CAPS__COUNTER] Global Const $_WD_CAPS__ARRAY_HEADER_NAMES = _ "STANDARD__Type" & "|" & _ "STANDARD__FirstIdx" & "|" & _ "STANDARD__STRINGORBOOL" & "|" & _ "STANDARD__PROXY" & "|" & _ "STANDARD__TIMEOUTS" & "|" & _ "SPECIFICVENDOR__ObjectName" & "|" & _ "SPECIFICVENDOR__OPTS" & "|" & _ "SPECIFICVENDOR__ARGS" & "|" & _ "SPECIFICVENDOR__PREFS" & "|" & _ "SPECIFICVENDOR__LOG" & "|" & _ "SPECIFICVENDOR__ENV" & "|" & _ "SPECIFICVENDOR__EXCSWITCH" & "|" & _ "" Global $_WD_CAPS__OBJECT Global $_WD_CAPS__CURRENTIDX = -1 #EndRegion - _wd_Capabilities.au3 UDF - Global's declarations #Region - _wd_Capabilities.au3 UDF - examples Global Const $_EXAMPLE_DRIVER_FIREFOX = @ScriptDir & '\..\geckodriver.exe' ; CHANGE TO PROPER FILE FULL PATH Global Const $_EXAMPLE_DRIVER_CHROME = @ScriptDir & '\..\chromedriver.exe' ; CHANGE TO PROPER FILE FULL PATH Global Const $_EXAMPLE_DRIVER_EDGE = @ScriptDir & '\..\msedgedriver.exe' ; CHANGE TO PROPER FILE FULL PATH Global Const $_EXAMPLE_PROFILE_FIREFOX = @LocalAppDataDir & '\Mozilla\Firefox\Profiles\WD_Testing_Profile' ; CHANGE TO PROPER DIRECTORY PATH Global Const $_EXAMPLE_PROFILE_CHROME = @LocalAppDataDir & '\Google\Chrome\User Data\Default' ; CHANGE TO PROPER DIRECTORY PATH Global Const $_EXAMPLE_PROFILE_EDGE = @LocalAppDataDir & 'TODO_______TODO' ; CHANGE TO PROPER DIRECTORY PATH Global Const $_EXAMPLE_DOWNLOAD_DIR = @UserProfileDir & '\Downloads\WD_Testing_download' ; CHANGE TO PROPER DIRECTORY PATH Global Const $_EXAMPLE_OPTION_RUN_BROWSER = ( _ $IDYES = MsgBox($MB_YESNO + $MB_TOPMOST + $MB_ICONQUESTION + $MB_DEFBUTTON1, 'Question', _ 'Do you want to test with running browsers ?' & @CRLF & _ '' & @CRLF & _ ' [YES] = Run browser' & @CRLF & _ ' [NO] = only put $s_Capabilities_JSON to console') _ ) Global Const $_EXAMPLE_OPTION_CHOOSEN_DRIVER = (($_EXAMPLE_OPTION_RUN_BROWSER) ? (_WD_Capabilities_Example_ChooseDriver()) : ('')) Global Const $_EXAMPLE_OPTION_HEADLESS = ($_EXAMPLE_OPTION_RUN_BROWSER And _ ($IDYES = MsgBox($MB_YESNO + $MB_TOPMOST + $MB_ICONQUESTION + $MB_DEFBUTTON1, 'Question', _ 'Do you want to test with headless mode ?' & @CRLF & _ '' & @CRLF & _ ' [YES] = Run browser in headless mode' & @CRLF & _ ' [NO] = Run browser in "visible" mode') _ ) _ ) Global Const $_EXAMPLE_OPTION_PROXY = _ ($IDYES = MsgBox($MB_YESNO + $MB_TOPMOST + $MB_ICONQUESTION + $MB_DEFBUTTON1, 'Question', _ 'Do you want to test with connection buffered via Proxy server ?' & @CRLF & _ '' & @CRLF & _ ' [YES] = use Proxy' & @CRLF & _ ' [NO] = direct coonection') _ ) Global Const $_EXAMPLE_OPTION_ALLCAPS = _ ($IDYES = MsgBox($MB_YESNO + $MB_TOPMOST + $MB_ICONQUESTION + $MB_DEFBUTTON1, 'Question', _ 'Do you want to test with Capabilities for all "firstMatch" ?' & @CRLF & _ '' & @CRLF & _ ' [YES] = test "firstMatch" Capabilites for all browser toogether' & @CRLF & _ ' [NO] = test only "firstMatch" desired for specified browser') _ ) _WD_Capabilities_Example() Exit Func _WD_Capabilities_Example() _WD_Capabilities_Startup() ConsoleWrite("! @ScriptLineNumber = " & @ScriptLineNumber & @CRLF) #Region - _WD_Capabilities_Example() ... "alwaysMatch" section _WD_Capabilities_Add('alwaysMatch') _WD_Capabilities_Add('acceptInsecureCerts', True) _WD_Capabilities_Add('timeouts', 'implicit', 4) _WD_Capabilities_Add('timeouts', 'script', 300) _WD_Capabilities_Add('timeouts', 'pageLoad', 30000) If $_EXAMPLE_OPTION_PROXY Then _WD_Capabilities_Add('proxy', 'proxyType', 'manual') _WD_Capabilities_Add('proxy', 'proxyAutoconfigUrl', '127.0.0.1') ; change '127.0.0.1' to your own 'proxyAutoconfigUrl' host _WD_Capabilities_Add('proxy', 'ftpProxy', '127.0.0.1') ; change '127.0.0.1' to your own 'ftpProxy' host _WD_Capabilities_Add('proxy', 'httpProxy', '127.0.0.1') ; change '127.0.0.1' to your own 'httpProxy' host _WD_Capabilities_Add('proxy', 'noProxy', 'www.w3.org') ; an example url which should not to bo opened via proxy server _WD_Capabilities_Add('proxy', 'noProxy', 'www.autoitscript.com') ; an example url which should not to bo opened via proxy server _WD_Capabilities_Add('proxy', 'noProxy', 'www.google.com') ; an example url which should not to bo opened via proxy server _WD_Capabilities_Add('proxy', 'noProxy', 'www.google.pl') ; an example url which should not to bo opened via proxy server _WD_Capabilities_Add('proxy', 'sslProxy', '127.0.0.1') ; change '127.0.0.1' to your own 'sslProxy' host _WD_Capabilities_Add('proxy', 'socksProxy', '127.0.0.1') ; change '127.0.0.1' to your own 'socksProxy' host _WD_Capabilities_Add('proxy', 'socksVersion', 1) EndIf #TODO check why 'WIN10' have issue when using FireFox ;~ _WD_Capabilities_Add('platformName', 'WIN10') ; https://stackoverflow.com/a/45621125/5314940 _WD_Capabilities_JSONToConsole(@ScriptLineNumber) #EndRegion - _WD_Capabilities_Example() ... "alwaysMatch" section #Region - _WD_Capabilities_Example() ... "firstMatch" section for Microsoft Edge If $_EXAMPLE_OPTION_ALLCAPS Or $_EXAMPLE_OPTION_CHOOSEN_DRIVER = $_EXAMPLE_DRIVER_EDGE Then ; https://docs.microsoft.com/en-us/microsoft-edge/webdriver-chromium/capabilities-edge-options ConsoleWrite("! @ScriptLineNumber = " & @ScriptLineNumber & @CRLF) _WD_Capabilities_Add('firstMatch', 'edge') _WD_Capabilities_JSONToConsole(@ScriptLineNumber) #TODO CHECK .... "invalid argument: entry 0 of 'firstMatch' is invalid\nfrom invalid argument: unrecognized capability: browsername" ;~ _WD_Capabilities_Add('browsername', 'edge') #TODO CHECK .... How to use 'WIN10' ;~ _WD_Capabilities_Add('platformName', 'WIN10') _WD_Capabilities_Add('w3c', True) #TODO CHECK .... How to use 'maxInstances' ;~ _WD_Capabilities_Add('maxInstances', 1) ; https://stackoverflow.com/a/45621125/5314940 If $_EXAMPLE_OPTION_HEADLESS Then _ _WD_Capabilities_Add('args', '--headless') _WD_Capabilities_Add('prefs', 'plugins.always_open_pdf_externally', True) ; https://www.autoitscript.com/forum/topic/205553-webdriver-udf-help-support-iii/?do=findComment&comment=1482786 _WD_Capabilities_Add('prefs', 'edge.sleeping_tabs.enabled', False) ; https://www.autoitscript.com/forum/topic/205553-webdriver-udf-help-support-iii/?do=findComment&comment=1482798 _WD_Capabilities_JSONToConsole(@ScriptLineNumber) EndIf #EndRegion - _WD_Capabilities_Example() ... "firstMatch" section for Microsoft Edge #Region - _WD_Capabilities_Example() ... "firstMatch" section for Microsoft Google Chrome If $_EXAMPLE_OPTION_ALLCAPS Or $_EXAMPLE_OPTION_CHOOSEN_DRIVER = $_EXAMPLE_DRIVER_CHROME Then ConsoleWrite("! @ScriptLineNumber = " & @ScriptLineNumber & @CRLF) _WD_Capabilities_Add('firstMatch', 'chrome') #TODO ADD REMARK about: "firstMatch key shadowed a value in alwaysMatch" _WD_Capabilities_Add('browserName', 'chrome') ;~ _WD_Capabilities_Add('platformName', 'WIN10') _WD_Capabilities_Add('w3c', True) #TODO check how to use 'binary' # _WD_Capabilities_Add('binary', 'c:\Program Files (x86)\Mozilla Firefox\firefox.exe') If $_EXAMPLE_OPTION_HEADLESS Then _ _WD_Capabilities_Add('args', '--headless') _WD_Capabilities_Add('args', 'start-maximized') _WD_Capabilities_Add('args', 'disable-infobars') _WD_Capabilities_Add('args', 'user-data-dir', $_EXAMPLE_PROFILE_CHROME) _WD_Capabilities_Add('args', '--profile-directory', Default) _WD_Capabilities_Add('excludeSwitches', 'disable-popup-blocking') ; https://help.applitools.com/hc/en-us/articles/360007189411--Chrome-is-being-controlled-by-automated-test-software-notification _WD_Capabilities_Add('excludeSwitches', 'enable-automation') _WD_Capabilities_Add('excludeSwitches', 'load-extension') _WD_Capabilities_JSONToConsole(@ScriptLineNumber) EndIf #EndRegion - _WD_Capabilities_Example() ... "firstMatch" section for Microsoft Google Chrome #Region - _WD_Capabilities_Example() ... "firstMatch" section for FireFox If $_EXAMPLE_OPTION_ALLCAPS Or $_EXAMPLE_OPTION_CHOOSEN_DRIVER = $_EXAMPLE_DRIVER_FIREFOX Then ConsoleWrite("! @ScriptLineNumber = " & @ScriptLineNumber & @CRLF) _WD_Capabilities_Add('firstMatch', 'firefox') _WD_Capabilities_Add('browserName', 'firefox') If $_EXAMPLE_OPTION_HEADLESS Then _ _WD_Capabilities_Add('args', '--headless') _WD_Capabilities_Add('args', '-profile') _WD_Capabilities_Add('args', $_EXAMPLE_PROFILE_FIREFOX) _WD_Capabilities_Add('prefs', 'download.default_directory', @ScriptDir) _WD_Capabilities_Add('prefs', 'dom.ipc.processCount', 8) _WD_Capabilities_Add('prefs', 'javascript.options.showInConsole', False) _WD_Capabilities_Add('prefs', 'browser.toolbars.bookmarks.visibility', 'always') ; check about:config _WD_Capabilities_Add('prefs', 'app.update.download.attempts', 0) ; check about:config _WD_Capabilities_Add('prefs', 'browser.safebrowsing.downloads.enabled', False) ; check about:config _WD_Capabilities_Add('prefs', 'browser.safebrowsing.downloads.enabled', False) ; check about:config ; https://tarunlalwani.com/post/change-profile-settings-at-runtime-firefox-selenium/ # 0 means to download to the desktop, 1 means to download to the default "Downloads" directory, 2 means to use the directory _WD_Capabilities_Add('prefs', 'browser.download.folderList', 2) _WD_Capabilities_Add('prefs', 'browser.download.manager.showWhenStarting', False) _WD_Capabilities_Add('prefs', 'browser.download.dir', $_EXAMPLE_DOWNLOAD_DIR) _WD_Capabilities_Add('prefs', 'browser.helperApps.neverAsk.saveToDisk', 'application/x-gzip') _WD_Capabilities_Add('prefs', 'browser.helperApps.neverAsk.saveToDisk', 'application/zip') _WD_Capabilities_Add('log', 'level', 'trace') _WD_Capabilities_Add('env', 'MOZ_LOG', 'nsHttp:5') _WD_Capabilities_Add('env', 'MOZ_LOG_FILE', $_EXAMPLE_PROFILE_FIREFOX & '\log') _WD_Capabilities_JSONToConsole(@ScriptLineNumber) EndIf #EndRegion - _WD_Capabilities_Example() ... "firstMatch" section for FireFox _WD_Capabilities_APIToConsole(@ScriptLineNumber) _WD_Capabilities_APIDisplay(@ScriptLineNumber) If Not $_EXAMPLE_OPTION_RUN_BROWSER Then Return _WD_Option('Driver', $_EXAMPLE_OPTION_CHOOSEN_DRIVER) If $_EXAMPLE_OPTION_CHOOSEN_DRIVER = $_EXAMPLE_DRIVER_FIREFOX Then _WD_Option('Port', 4444) If $_EXAMPLE_OPTION_CHOOSEN_DRIVER = $_EXAMPLE_DRIVER_CHROME Then _WD_Option('Port', 9515) If $_EXAMPLE_OPTION_CHOOSEN_DRIVER = $_EXAMPLE_DRIVER_EDGE Then _WD_Option('Port', 9515) _WD_Startup() Local $s_Capabilities_JSON = _WD_Capabilities_GetPrettyJSON() Local $WD_SESSION = _WD_CreateSession($s_Capabilities_JSON) If Not @Compiled Then MsgBox($MB_OK + $MB_TOPMOST + $MB_ICONINFORMATION, "Information #" & @ScriptLineNumber, "Waiting before _WD_Shutdown()") _WD_DeleteSession($WD_SESSION) _WD_Shutdown() EndFunc ;==>_WD_Capabilities_Example Func _WD_Capabilities_Example_ChooseDriver() Local $_CHOOSEN_DRIVER = '' If $IDYES = MsgBox($MB_YESNO + $MB_TOPMOST + $MB_ICONQUESTION + $MB_DEFBUTTON1, "Question", _ "Do you want to use FireFox browser") Then $_CHOOSEN_DRIVER = $_EXAMPLE_DRIVER_FIREFOX ElseIf $IDYES = MsgBox($MB_YESNO + $MB_TOPMOST + $MB_ICONQUESTION + $MB_DEFBUTTON1, "Question", _ "Do you want to use Google Chrome browser") Then $_CHOOSEN_DRIVER = $_EXAMPLE_DRIVER_CHROME ElseIf $IDYES = MsgBox($MB_YESNO + $MB_TOPMOST + $MB_ICONQUESTION + $MB_DEFBUTTON1, "Question", _ "Do you want to use Miscrosoft Edge browser") Then $_CHOOSEN_DRIVER = $_EXAMPLE_DRIVER_EDGE EndIf If Not FileExists($_CHOOSEN_DRIVER) Then MsgBox($MB_OK + $MB_TOPMOST + $MB_ICONERROR, "! Error occurred", _ "WebDriver file:" & @CRLF & _ $_CHOOSEN_DRIVER & @CRLF & _ "Not exist !" & @CRLF & _ "") Exit EndIf ConsoleWrite("> USING: " & $_CHOOSEN_DRIVER & @CRLF) Return $_CHOOSEN_DRIVER EndFunc ;==>_WD_Capabilities_Example_ChooseDriver #EndRegion - _wd_Capabilities.au3 UDF - examples #Region - _wd_Capabilities.au3 UDF - core functions Func _WD_Capabilities_Startup() $_WD_CAPS__OBJECT = '' EndFunc ;==>_WD_Capabilities_Startup Func _WD_Capabilities_Add($key, $value1 = '', $value2 = '') If $value1 = Default Then $value1 = 'default' If $value2 = Default Then $value2 = 'default' If StringInStr('alwaysMatch|firstMatch', $key) Then $_WD_CAPS__CURRENTIDX = __WD_Capabilities_CreateObject($key, $value1) Return SetError(@error, @extended, $_WD_CAPS__CURRENTIDX) EndIf #TODO use $value2 for "noProxy" https://www.w3.org/TR/webdriver/#dfn-page-load-strategy #TODO use $value2 for https://www.w3.org/TR/webdriver/#timeouts Local $s_Notation = '' If $key = 'excludeSwitches' Then ; for adding "excludeSwitches" capability in specific/vendor capabilities : ........ $s_Notation = __WD_Capabilities_JSONNotation($_WD_CAPS__SPECIFICVENDOR__EXCSWITCH) ElseIf $key = 'timeouts' Then ; for adding "proxy" capability in standard capability : https://www.w3.org/TR/webdriver/#capabilities $s_Notation = __WD_Capabilities_JSONNotation($_WD_CAPS__STANDARD__TIMEOUTS) $s_Notation &= '[' & $value1 & ']' ; here is specified keyName in {timeouts} JSON OBJECT __WD_Capabilities_SwitchParameters($key, $value1, $value2) ; as the notation was modified now parameters should be switched ElseIf $key = 'proxy' Then ; for adding "proxy" capability in standard capabilities : https://www.w3.org/TR/webdriver/#dfn-proxy-configuration $s_Notation = __WD_Capabilities_JSONNotation($_WD_CAPS__STANDARD__PROXY) If $value1 = 'noProxy' Then ; for add string to "noProxy" JSON ARRAY in standard capabilities : https://www.w3.org/TR/webdriver/#dfn-proxy-configuration $_WD_CAPS__API[$_WD_CAPS__CURRENTIDX][$_WD_CAPS__STANDARD__PROXY] += 1 ; default is -1 so first should be 0 Local $i_Current_noProxy = $_WD_CAPS__API[$_WD_CAPS__CURRENTIDX][$_WD_CAPS__STANDARD__PROXY] $s_Notation &= '[noProxy][' & $i_Current_noProxy & ']' ; here is specified which one of [noProxy] JSON ARRAY element should be used Else $s_Notation &= '[' & $value1 & ']' ; here is specified keyName in {proxy} JSON OBJECT EndIf __WD_Capabilities_SwitchParameters($key, $value1, $value2) ; as the notation was modified now parameters should be switched ;~ If Not @Compiled Then ConsoleWrite("- IFNC: " & @ScriptLineNumber & ' $s_Notation =' & $s_Notation & @CRLF) ElseIf $key = 'w3c' Or $key = 'maxInstances' Then ; for adding "w3c" capability in specific/vendor capabilities : ........ $s_Notation = __WD_Capabilities_JSONNotation($_WD_CAPS__SPECIFICVENDOR__OPTS) $s_Notation &= '[' & $key & ']' ;~ If Not @Compiled Then ConsoleWrite("- IFNC: " & @ScriptLineNumber & ' $s_Notation =' & $s_Notation & @CRLF) ElseIf $key = 'args' Then ; for adding "args" capability in specific/vendor capabilities : ........ $s_Notation = __WD_Capabilities_JSONNotation($_WD_CAPS__SPECIFICVENDOR__ARGS) __WD_Capabilities_SwitchParameters($key, $value1, $value2) ; as the notation was modified now parameters should be switched If $value1 Then $value1 = $key & '=' & $value1 Else $value1 = $key EndIf If Not @Compiled Then ConsoleWrite("- IFNC: " & @ScriptLineNumber & ' $s_Notation =' & $s_Notation & @CRLF) If Not @Compiled Then ConsoleWrite("- IFNC: " & @ScriptLineNumber & ' $s_Notation =' & $s_Notation & ' = ' & $value1 & @CRLF) ElseIf $key = 'prefs' Then ; for adding "prefs" capability in specific/vendor capabilities : ........ $s_Notation = __WD_Capabilities_JSONNotation($_WD_CAPS__SPECIFICVENDOR__PREFS) __WD_Capabilities_SwitchParameters($key, $value1, $value2) ; as the notation was modified now parameters should be switched $s_Notation &= '[' & $key & ']' ;~ If Not @Compiled Then ConsoleWrite("- IFNC: " & @ScriptLineNumber & ' $s_Notation =' & $s_Notation & @CRLF) ElseIf $key = 'log' Then ; for adding "log" capability in specific/vendor capabilities : ........ $s_Notation = __WD_Capabilities_JSONNotation($_WD_CAPS__SPECIFICVENDOR__LOG) __WD_Capabilities_SwitchParameters($key, $value1, $value2) ; as the notation was modified now parameters should be switched $s_Notation &= '[' & $key & ']' ;~ If Not @Compiled Then ConsoleWrite("- IFNC: " & @ScriptLineNumber & ' $s_Notation =' & $s_Notation & @CRLF) ElseIf $key = 'env' Then ; for adding "env" capability in specific/vendor capabilities : ........ $s_Notation = __WD_Capabilities_JSONNotation($_WD_CAPS__SPECIFICVENDOR__ENV) __WD_Capabilities_SwitchParameters($key, $value1, $value2) ; as the notation was modified now parameters should be switched $s_Notation &= '[' & $key & ']' ;~ If Not @Compiled Then ConsoleWrite("- IFNC: " & @ScriptLineNumber & ' $s_Notation =' & $s_Notation & @CRLF) ElseIf $value2 = '' Then ; for string/boolean value type in standard capability : https://www.w3.org/TR/webdriver/#capabilities $s_Notation = __WD_Capabilities_JSONNotation($_WD_CAPS__STANDARD__STRINGORBOOL) $s_Notation &= '[' & $key & ']' Else ; not supported option Return SetError(1) EndIf If @error Then Return SetError(@error, @extended, $s_Notation) Json_Put($_WD_CAPS__OBJECT, $s_Notation, $value1) ;~ If Not @compiled Then ConsoleWrite("> $s_Notation - " & $s_Notation & @CRLF) EndFunc ;==>_WD_Capabilities_Add Func _WD_Capabilities_GetJSON() Local $Data2 = Json_Encode($_WD_CAPS__OBJECT) Local $Data1 = Json_Decode($Data2) Local $Json2 = Json_Encode($Data1, $Json_UNQUOTED_STRING) Return $Json2 EndFunc ;==>_WD_Capabilities_GetJSON #EndRegion - _wd_Capabilities.au3 UDF - core functions #Region - _wd_Capabilities.au3 UDF - internal functions Func __WD_Capabilities_CreateObject($s_MatchType, $s_Browser_type = '') ; $s_MatchType = 'alwaysMatch' Or 'firstMatch' #Region - parameters validation ;~ ConsoleWrite("! @ScriptLineNumber = " & @ScriptLineNumber & @CRLF) If Not StringInStr('alwaysMatch|firstMatch', $s_MatchType) Then _ Return SetError(1) ;~ ConsoleWrite("! @ScriptLineNumber = " & @ScriptLineNumber & @CRLF) ;~ MsgBox($MB_OK + $MB_TOPMOST + $MB_ICONINFORMATION, "Information #" & @ScriptLineNumber, "$s_Browser_type = " & $s_Browser_type & @CRLF & "$s_MatchType = " & $s_MatchType) Local $s_SpecificOptions_KeyName = '' If StringInStr($s_Browser_type, 'chrome') Then $s_SpecificOptions_KeyName = 'goog:chromeOptions' ElseIf StringInStr($s_Browser_type, 'firefox') Then $s_SpecificOptions_KeyName = 'moz:firefoxOptions' ElseIf StringInStr($s_Browser_type, 'edge') Then $s_SpecificOptions_KeyName = 'ms:edgeOptions' ElseIf $s_MatchType = 'alwaysMatch' And $s_Browser_type = '' Then $s_SpecificOptions_KeyName = '' ElseIf $s_MatchType = 'firstMatch' And $s_Browser_type = '' Then Return SetError(2) EndIf #EndRegion - parameters validation #Region - reindexing API Local $i_API_Recent_Size = UBound($_WD_CAPS__API), $i_API_New_Size = $i_API_Recent_Size + 1, $i_API_New_IDX = $i_API_New_Size - 1 ReDim $_WD_CAPS__API[$i_API_New_Size][$_WD_CAPS__COUNTER] ConsoleWrite("! @ScriptLineNumber = " & @ScriptLineNumber & @CRLF) #EndRegion - reindexing API #Region - new "MATCH" Initialization $_WD_CAPS__API[$i_API_New_IDX][$_WD_CAPS__STANDARD__Type] = $s_MatchType Local Static $i_FirstMatch_Counter = -1 If $s_MatchType = 'firstMatch' Then $i_FirstMatch_Counter += 1 ; default is -1 so first should be 0 $_WD_CAPS__API[$i_API_New_IDX][$_WD_CAPS__STANDARD__FirstIdx] = $i_FirstMatch_Counter EndIf $_WD_CAPS__API[$i_API_New_IDX][$_WD_CAPS__STANDARD__STRINGORBOOL] = Null $_WD_CAPS__API[$i_API_New_IDX][$_WD_CAPS__STANDARD__PROXY] = -1 ; used for indexing ...... "noProxy" : [JSON ARRRAY] $_WD_CAPS__API[$i_API_New_IDX][$_WD_CAPS__SPECIFICVENDOR__ObjectName] = $s_SpecificOptions_KeyName $_WD_CAPS__API[$i_API_New_IDX][$_WD_CAPS__SPECIFICVENDOR__OPTS] = Null $_WD_CAPS__API[$i_API_New_IDX][$_WD_CAPS__SPECIFICVENDOR__ARGS] = -1 ; used for indexing ...... "args" : [JSON ARRRAY] $_WD_CAPS__API[$i_API_New_IDX][$_WD_CAPS__SPECIFICVENDOR__PREFS] = Null $_WD_CAPS__API[$i_API_New_IDX][$_WD_CAPS__SPECIFICVENDOR__LOG] = Null $_WD_CAPS__API[$i_API_New_IDX][$_WD_CAPS__SPECIFICVENDOR__ENV] = Null $_WD_CAPS__API[$i_API_New_IDX][$_WD_CAPS__SPECIFICVENDOR__EXCSWITCH] = -1 ; used for indexing ...... "excludeSwitches" : [JSON ARRRAY] $_WD_CAPS__CURRENTIDX = $i_API_New_IDX ; set last API IDX as CURRENT API IDX #EndRegion - new "MATCH" Initialization Local $s_Information = _ "$s_Browser_type = " & $s_Browser_type & @CRLF & _ "$s_MatchType = " & $s_MatchType & @CRLF & _ "$s_SpecificOptions_KeyName = " & $s_SpecificOptions_KeyName & @CRLF & _ "$i_FirstMatch_Counter = " & $i_FirstMatch_Counter & @CRLF & _ "$_WD_CAPS__CURRENTIDX = " & $_WD_CAPS__CURRENTIDX & @CRLF & _ '' #forceref $s_Information ;~ If Not @compiled Then MsgBox($MB_OK + $MB_TOPMOST + $MB_ICONINFORMATION, "Information #" & @ScriptLineNumber, $s_Information) ;~ ConsoleWrite("! @ScriptLineNumber = " & @ScriptLineNumber & @CRLF) Return $_WD_CAPS__CURRENTIDX ; return current API IDX EndFunc ;==>__WD_Capabilities_CreateObject Func __WD_Capabilities_SwitchParameters(ByRef $key, ByRef $value1, ByRef $value2) $key = $value1 $value1 = $value2 $value2 = '' EndFunc ;==>__WD_Capabilities_SwitchParameters Func __WD_Capabilities_JSONNotation($i_BUILDER_TYPE) ;~ MsgBox($MB_OK + $MB_TOPMOST + $MB_ICONINFORMATION, "Information #" & @ScriptLineNumber, "$_WD_CAPS__CURRENTIDX = " & $_WD_CAPS__CURRENTIDX & ' Ubound = ' & UBound($_WD_CAPS__API)) Local $s_CurrentMatch_Type = '[' & $_WD_CAPS__API[$_WD_CAPS__CURRENTIDX][$_WD_CAPS__STANDARD__Type] & ']' If $s_CurrentMatch_Type = '[firstMatch]' Then $s_CurrentMatch_Type &= '[' & $_WD_CAPS__API[$_WD_CAPS__CURRENTIDX][$_WD_CAPS__STANDARD__FirstIdx] & ']' EndIf Local $s_SpecificOptions_KeyName = $_WD_CAPS__API[$_WD_CAPS__CURRENTIDX][$_WD_CAPS__SPECIFICVENDOR__ObjectName] If $s_SpecificOptions_KeyName Then $s_SpecificOptions_KeyName = '["' & $s_SpecificOptions_KeyName & '"]' If $s_SpecificOptions_KeyName = '' And $i_BUILDER_TYPE >= $_WD_CAPS__SPECIFICVENDOR__ARGS Then _ Return SetError(1, 0, '') ; ARGS, PREFS, LOG, ENV and any further are possible only when Specific/Vendor Capability was specified Local $s_Notation = '' Switch $i_BUILDER_TYPE Case $_WD_CAPS__STANDARD__STRINGORBOOL $s_Notation = '[capabilities]' & $s_CurrentMatch_Type Case $_WD_CAPS__STANDARD__PROXY $s_Notation = '[capabilities]' & $s_CurrentMatch_Type & '[proxy]' ; here is specified the name for {proxy} JSON OBJECT Case $_WD_CAPS__STANDARD__TIMEOUTS $s_Notation = '[capabilities]' & $s_CurrentMatch_Type & '[timeouts]' ; here is specified the name for {timeout} JSON OBJECT Case $_WD_CAPS__SPECIFICVENDOR__OPTS $s_Notation = '[capabilities]' & $s_CurrentMatch_Type & $s_SpecificOptions_KeyName ; here is specified the name for {SPECIFIC VENDOR NAME} JSON OBJECT Case $_WD_CAPS__SPECIFICVENDOR__ARGS $_WD_CAPS__API[$_WD_CAPS__CURRENTIDX][$_WD_CAPS__SPECIFICVENDOR__ARGS] += 1 ; default is -1 so first should be 0 Local $i_Current_Arg = $_WD_CAPS__API[$_WD_CAPS__CURRENTIDX][$_WD_CAPS__SPECIFICVENDOR__ARGS] $s_Notation = '[capabilities]' & $s_CurrentMatch_Type & $s_SpecificOptions_KeyName & '[args][' & $i_Current_Arg & ']' ; here is specified which one of [args] JSON ARRAY element should be used Case $_WD_CAPS__SPECIFICVENDOR__PREFS $s_Notation = '[capabilities]' & $s_CurrentMatch_Type & $s_SpecificOptions_KeyName & '[prefs]' ; here is specified the name for {prefs} JSON OBJECT Case $_WD_CAPS__SPECIFICVENDOR__LOG $s_Notation = '[capabilities]' & $s_CurrentMatch_Type & $s_SpecificOptions_KeyName & '[log]' ; here is specified the name for {log} JSON OBJECT Case $_WD_CAPS__SPECIFICVENDOR__ENV $s_Notation = '[capabilities]' & $s_CurrentMatch_Type & $s_SpecificOptions_KeyName & '[env]' ; here is specified the name for {env} JSON OBJECT Case $_WD_CAPS__SPECIFICVENDOR__EXCSWITCH $_WD_CAPS__API[$_WD_CAPS__CURRENTIDX][$_WD_CAPS__SPECIFICVENDOR__EXCSWITCH] += 1 ; default is -1 so first should be 0 Local $i_Current_ExcSwitch = $_WD_CAPS__API[$_WD_CAPS__CURRENTIDX][$_WD_CAPS__SPECIFICVENDOR__EXCSWITCH] $s_Notation = '[capabilities]' & $s_CurrentMatch_Type & $s_SpecificOptions_KeyName & '[excludeSwitches][' & $i_Current_ExcSwitch & ']' ; here is specified which one of [excluedSwitches] JSON ARRAY element should be used EndSwitch ;~ If Not @compiled Then ConsoleWrite("- IFNC: " & @ScriptLineNumber & ' $s_Notation =' & $s_Notation & @CRLF) Return $s_Notation EndFunc ;==>__WD_Capabilities_JSONNotation #EndRegion - _wd_Capabilities.au3 UDF - internal functions #Region - _wd_Capabilities.au3 UDF - helper functions Func _WD_Capabilities_GetPrettyJSON() Local $Json2 = _WD_Capabilities_GetJSON() Local $Data3 = Json_Decode($Json2) Local $Json3 = Json_Encode($Data3, $Json_PRETTY_PRINT, " ", ",\n", ",\n", ":") Return $Json3 EndFunc ;==>_WD_Capabilities_GetPrettyJSON Func _WD_Capabilities_JSONToConsole($s_Comment) If @Compiled Then Return ; because of GDRP reason do not throw nothing to console when compiled script ConsoleWrite(@LF & '! _WD_Capabilities: JSON START: ' & $s_Comment & @LF) ConsoleWrite(_WD_Capabilities_GetPrettyJSON()) ConsoleWrite(@LF & '! _WD_Capabilities: JSON END: ' & $s_Comment & @LF & @LF) EndFunc ;==>_WD_Capabilities_JSONToConsole Func _WD_Capabilities_APIToConsole($s_Comment) If @Compiled Then Return ; because of GDRP reason do not throw nothing to console when compiled script ConsoleWrite(@LF & '! _WD_Capabilities: API START: ' & $s_Comment & @LF) ConsoleWrite("- Ubound Rows " & UBound($_WD_CAPS__API, 1) & @CRLF) ConsoleWrite("- Ubound Cols " & UBound($_WD_CAPS__API, 2) & @CRLF) ConsoleWrite(_ArrayToString($_WD_CAPS__API) & @LF) ConsoleWrite(@LF & '! _WD_Capabilities: API END: ' & $s_Comment & @LF & @LF) EndFunc ;==>_WD_Capabilities_APIToConsole Func _WD_Capabilities_APIDisplay($s_Comment) If @Compiled Then Return ; because of GDRP reason do not throw nothing to console when compiled script Local $s_Title = $s_Comment & ' $_WD_CAPS__API Rows=' & UBound($_WD_CAPS__API, 1) & ' Cols=' & UBound($_WD_CAPS__API, 2) & @LF _ArrayDisplay($_WD_CAPS__API, $s_Title, "", Default, Default, $_WD_CAPS__ARRAY_HEADER_NAMES) EndFunc ;==>_WD_Capabilities_APIDisplay #EndRegion - _wd_Capabilities.au3 UDF - helper functions