Jump to content

Recommended Posts

Posted

@Danp2


I'm curious:
Why you are using:

If $_WD_DEBUG Then
        ConsoleWrite($sFuncName & ': ' & $sResponse & @CRLF)
    EndIf

instead:
 

If $_WD_DEBUG Then _
            ConsoleWrite($sFuncName & ': ' & $sResponse & @CRLF)

IMHO: If you do not plan to add more lines in this IF THE ENDIF statement then make them as SINGLE LINE, as in compiled version it will be less code.

 

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

@Danp2

Would you be so kind and add URL to W3C documentation for each functions:
I mean here:

  Quote

; Link ..........:

Expand  

This will help other's to learn how this UDF works, and I hope in next step, help to involve in development.

 

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)

To be consistent with other internall function would you change this following function name from:
__WDError
to:
__WD_Error

?

 

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

did you ever try something like this:

Global Enum _
        $_WD_ERROR_Success = 0, _        ; No error
        $_WD_ERROR_GeneralError, _       ; General error
        $_WD_ERROR_SocketError, _        ; No socket
        $_WD_ERROR_InvalidDataType, _    ; Invalid data type (IP, URL, Port ...)
        $_WD_ERROR_InvalidValue, _       ; Invalid value in function-call
        $_WD_ERROR_SendRecv, _           ; Send / Recv Error
        $_WD_ERROR_Timeout, _            ; Connection / Send / Recv timeout
        $_WD_ERROR___UNUSED, _           ;
        $_WD_ERROR_NoMatch, _            ; No match for _WDAction-find/search _WDGetElement...
        $_WD_ERROR_RetValue, _           ; Error echo from Repl e.g. _WDAction("fullscreen","true") <> "true"
        $_WD_ERROR_Exception, _          ; Exception from web driver
        $_WD_ERROR_InvalidExpression, _  ; Invalid expression in XPath query or RegEx
        $_WD_ERROR_COUTNER ;

Global Const $aWD_ERROR_DESC[$_WD_ERROR_COUTNER] = [ _
        "Success", _
        "General Error", _
        "Socket Error", _
        "Invalid data type", _
        "Invalid value", _
        "Timeout", _
        "No match", _
        "Error return value", _
        "Error TCPSend / TCPRecv", _
        "Webdriver Exception", _
        "Error TCPSend / TCPRecv", _
        "Invalid Expression" _
        ]



;~ $sMsg = $sWhere & " ==> " & $sOut & @CRLF
$sMsg = $sWhere & " ==> " & $aWD_ERROR_DESC[$i_WD_ERROR] & @CRLF

 

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

Here's another "helper" function. Please review and provide any feedback / suggestions.

Func _WD_Attach($sSession, $sString, $sMode = 'title')
    Local Const $sFuncName = "_WD_Attach"
    Local $sTabHandle = '', $lFound = False

    Local $sCurrentTab = _WDWindow($sSession, 'window')
    Local $aHandles = _WDWindow($sSession, 'handles')

    $sMode = StringLower($sMode)

    For $sTab In $aHandles

        _WDWindow($sSession, 'Switch', '{"handle":"' & $sTab & '"}')

        Switch $sMode
            Case "title", "url"
                If StringInStr(_WDAction($sSession, $sMode), $sString) > 0 Then
                    $lFound = True
                    $sTabHandle = $sTab
                    ExitLoop
                EndIf

            Case Else
                SetError(__WD_Error($sFuncName, $_WD_ERROR_InvalidDataType, "(Title|URL) $sOption=>" & $sMode))
                Return ""
        EndSwitch
    Next

    If Not $lFound Then
        ; Restore prior active tab
        _WDWindow($sSession, 'Switch', '{"handle":"' & $sCurrentTab & '"}')
        SetError(__WD_Error($sFuncName, $_WD_ERROR_NoMatch))
    EndIf

    Return $sTabHandle
EndFunc

 

Posted

Here is function _WD_CloseTab()

Func _WD_CloseTab($sSession, $lSwitch = True)
    Local $sTabHandle = ''
    Local $aHandles = _WDWindow($sSession, 'handles', '')

    If (@error = $_WD_ERROR_Success) And (UBound($aHandles) >= 2) Then

    _WDExecuteScript($sSession, 'window.close()', '{}')

        $sTabHandle = $aHandles[UBound($aHandles) - 1]

        If $lSwitch Then
            _WDWindow($sSession, 'Switch', '{"handle":"' & $sTabHandle & '"}')
         EndIf

      ElseIf (UBound($aHandles) = 1) Then

        $sTabHandle = $aHandles[0]

        If $lSwitch Then
            _WDWindow($sSession, 'Switch', '{"handle":"' & $sTabHandle & '"}')
         EndIf
    EndIf
    Return $sTabHandle
EndFunc

 

Posted

@Danp2 what about MS Edge WebDriver :

https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/

?

Whether this UDF is compatibile MS Edge ?

 

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

Please also add this link:
https://www.w3.org/TR/webdriver/

to GitHub introduction.

 

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

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...