Open Danp2 opened 2 years ago
Here is what I'm currently using to test the new bidi commands --
```autoit #include "wd_core.au3" #include "wd_capabilities.au3" #include "wd_bidi.au3" ;~ $_WD_Debug = $_WD_DEBUG_Full _WD_CapabilitiesDefine($_WD_KEYS__STANDARD_PRIMITIVE, 'webSocketUrl') _WD_CapabilitiesDefine($_WD_KEYS__STANDARD_PRIMITIVE, '"moz:debuggerAddress"') Global $url = 'https://google.com/' Global $bHeadless = False Global $sCapabilities = SetupGecko($bHeadless) ;~ Local $sCapabilities = SetupChrome($bHeadless) Global $iWebDriver_PID = _WD_Startup() Global $sSession = _WD_CreateSession($sCapabilities) If @error <> $_WD_ERROR_Success Then ConsoleWrite("Session not created..." & @error) Exit EndIf _WD_Navigate($sSession, $url) Global $sURL = _WD_BidiGetWebsocketURL($sSession) Global $hWS = _WD_BidiConnect($sURL) Global $sContext = _WD_BidiGetContextID() Global $oParams = Json_ObjCreate() Global $sResult = _WD_BidiExecute('session.status', $oParams) ;### Debug CONSOLE ↓↓↓ ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $sResult = ' & $sResult & @CRLF & '>Error code: ' & @error & @CRLF) Json_ObjPut($oParams, 'context', $sContext) $sResult = _WD_BidiExecute('browsingContext.close', $oParams) ;### Debug CONSOLE ↓↓↓ ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $sResult = ' & $sResult & @CRLF & '>Error code: ' & @error & @CRLF) $sResult = _WD_BidiDisconnect() ;### Debug CONSOLE ↓↓↓ ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $sResult = ' & $sResult & @CRLF & '>Error code: ' & @error & @CRLF) Func SetupGecko($bHeadless) _WD_Option('Driver', 'geckodriver.exe') _WD_Option('DriverParams', '--log trace') _WD_Option('Port', 4444) _WD_CapabilitiesStartup() _WD_CapabilitiesAdd('alwaysMatch', 'firefox') _WD_CapabilitiesAdd('browserName', 'firefox') _WD_CapabilitiesAdd('acceptInsecureCerts', True) _WD_CapabilitiesAdd('webSocketUrl', True) _WD_CapabilitiesAdd('"moz:debuggerAddress"', True) If $bHeadless Then _WD_CapabilitiesAdd('args', '--headless') _WD_CapabilitiesDump(@ScriptLineNumber) ; dump current Capabilities setting to console - only for testing in this demo Local $sCapabilities = _WD_CapabilitiesGet() Return $sCapabilities EndFunc ;==>SetupGecko Func SetupChrome($bHeadless) _WD_Option('Driver', 'chromedriver.exe') _WD_Option('Port', 9515) _WD_Option('DriverParams', '--verbose --log-path="' & @ScriptDir & '\chrome.log"') ;~ Local $sCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "excludeSwitches": [ "enable-automation"]}}}}' _WD_CapabilitiesStartup() _WD_CapabilitiesAdd('alwaysMatch', 'chrome') _WD_CapabilitiesAdd('w3c', True) _WD_CapabilitiesAdd('excludeSwitches', 'enable-automation') _WD_CapabilitiesAdd('webSocketUrl', True) If $bHeadless Then _WD_CapabilitiesAdd('args', '--headless') ;~ _WD_CapabilitiesDump(@ScriptLineNumber) ; dump current Capabilities setting to console - only for testing in this demo Local $sCapabilities = _WD_CapabilitiesGet() Return $sCapabilities EndFunc ;==>SetupChrome ```
Works fine for me with Firefox. Chrome responds with "not supported"
Found that calls to WinHttpWebSocketReceive would cause the process to hang when there wasn't pending data to receive. Switched to using websocat to perform all websocket activity.
Here is the latest revision of code I'm using to test the new bidi commands --
```autoit
#AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include
Note that you can right click on the Launch and Show Maps buttons to alter their functionality.
Here is the latest revision of code I'm using to test the new bidi commands --
```autoit
;~ #AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
;~ #AutoIt3Wrapper_AutoIt3Dir="C:\AutoitPortable\3.3.16.0"
#include
Note that you can right click on the Launch and Show Maps buttons to alter their functionality.
I have been successful at creating a BiDi session in Firefox without the need of geckodriver. I don't believe that this feature is currently supported by Chrome or Edge.
https://github.com/w3c/webdriver-bidi https://developer.chrome.com/blog/webdriver-bidi/ https://wiki.mozilla.org/WebDriver/RemoteProtocol/WebDriver_BiDi