Jump to content

Recommended Posts

Posted
  On 1/27/2018 at 1:02 AM, Danp2 said:

Trying to think this through and wondering if we really need separate functions for gathering sets of links, tables, images, etc.

Anyone care to share their opinion on this?

Expand  

I decided to go a different direction with this and enhanced _WD_FindElement to return an array of element IDs. IMO, this eliminates the need for any of the aforementioned functions to retrieve different element types.

Latest version is up on GH -- https://github.com/Danp2/WebDriver/releases/latest

Posted

I think this is a good extended feature, 

But there should be also possibility to easy switch from IE.au3 or from FF.au3 to WedDriver.

So I propose to create FindElementEx ...

 

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
  On 1/28/2018 at 10:19 PM, junkew said:

Lets see if we can make a small wrapper around findelement similar as i did with uiawrappers

Expand  

Sounds good. Look forward to your submission. :thumbsup:

  On 1/28/2018 at 10:33 PM, mLipok said:

I think this is a good extended feature, 

Expand  

Yes, this could be a good "helper" function

  On 1/28/2018 at 10:33 PM, mLipok said:

But there should be also possibility to easy switch from IE.au3 or from FF.au3 to WedDriver.

Expand  

I don't expect there to be a one-to-one translation for each function in the existing UDFs. As I mentioned in #63 above, _WD_FindElement is supports multiple selection types and you can replace many different function calls from the existing UDFs with this single command.

I am starting to rewrite one of my main scripts, which supports both IE and Firefox, to use this new WD script. As I proceed, I expect to run into issues that will lead me to rewrite some things and also give ideas where additional "helper" functions would be useful.

One example of this is that I started running into issues with COM errors due to the use of the WinHttpRequest object. As such, I am currently replacing related code with calls to @trancexx's WinHttp UDF.

Posted (edited)

I'm not talking about one to one conversion.
But at least functions should be comparable in naming, and basic functionality.

btw.
I think @trancexx WInHttp UDF is a great UDF for automating many web sites, but if you want to do UDF for specific webservice then I am an advocate of internal / independent solutions.
You can see what I mean in my TeamViewerAPI UDF, CrowdinAPI UDF, GHAPI UDF.

In case of WebDriver I think the problem is also WinHttp UDF license, which is different then this UDF.

 

Edited by mLipok

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

  Reveal hidden contents

Signature last update: 2023-04-24

Posted (edited)
  On 1/28/2018 at 11:33 PM, Danp2 said:

@mLipok Is there a way to deal with the situation when there are multiple UDFs that each want to install their own error handler?

Expand  

You mean COM Error Handler ? >> Yes. Define them locally for each function using COM Object.
Take a look in my XML ADO or other UDF.

 

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


@Danp2 I would look for this COM error problems but in next few days I will be busy with other projects.

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)

Here is a quick shot:

Func __WD_Delete($sURL)
    Local Const $sFuncName = "__WD_Delete"
    Local $sResponseText = __WD_HttpSender("DELETE", $sURL, $sFuncName, False, 5)

    Return $sResponseText
EndFunc   ;==>__WD_Delete

Func __WD_HttpSender($sCommand, $sURL, $sFuncName, $bParam, $iWait = 5)
    Local $oErrorHandler = ObjEvent("AutoIt.Error", __WD_ErrFunc)

    Local $oHTTP = ObjCreate("winhttp.winhttprequest.5.1")
    $oHTTP.Open($sCommand, $sURL, $bParam)
    $oHTTP.SetRequestHeader("Content-Type", "application/json;charset=utf-8")
    $oHTTP.Send()

    ; wait until response is ready
    $oHTTP.WaitForResponse($iWait)

    $_WD_HTTPRESULT = $oHTTP.Status

    Local $sResponseText = $oHTTP.ResponseText
    If $_WD_DEBUG Then _
            ConsoleWrite($sFuncName & ': StatusCode=' & $_WD_HTTPRESULT & "; ResponseText=" & $sResponseText & @CRLF)

    If $_WD_HTTPRESULT <> 200 Then _
            SetError(__WD_Error($sFuncName, $_WD_ERROR_Exception, $sResponseText))

    Return $oHTTP.ResponseText
EndFunc   ;==>__WD_HttpSender

Func __WD_ErrFunc(ByRef $oError)
    If $_WD_DEBUG Then ConsoleWrite( _
            @ScriptName & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _
            @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _
            @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _
            @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _
            @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _
            @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _
            @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _
            @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _
            @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _
            @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF)
EndFunc   ;==>__WD_ErrFunc

 

EDIT: Snippet is changed.

btw.
ObjCreate("winhttp.winhttprequest.5.1") should be also local - look in my proposal.

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

It should work as far as you not get any POP UP window, but I want to ask you did you try ?

 

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
  On 1/30/2018 at 12:44 AM, Danp2 said:

there's no way to prevent other UDFs from trampling on the error handler or to properly restore error handling setup by a prior UDF or the main application.

Expand  

This was just a quick shot.

Did you look in my ADO UDF ?

 

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)

TVAPI UDF is a good concept/exmaple how to manage HTTP statuses...

_TVAPI_GET_Status()
_TVAPI_GET_StatusText()
_TVAPI_GET_ResponseText()
 

But TVAPI UDF and GHAPI UDF is bad if you look how I manage COM Errors
 

Global $oErrorHandler = ObjEvent("AutoIt.Error", "_TVAPI_ErrFunc")

 

For COM Error Handling example with feature / possibility of transferring the error handling from the internal error handling in user own way (manage from main script), look in ADO UDF for:

Local $oADO_COM_ErrorHandler = ObjEvent("AutoIt.Error", __ADO_ComErrorHandler_InternalFunction)

and:
 

Func __ADO_ComErrorHandler_InternalFunction(ByRef $oCOMError)
    ; Do nothing special, just check @error after suspect functions.
    #forceref $oCOMError
    Local $sUserFunction = _ADO_COMErrorHandler_UserFunction()
    If IsFunc($sUserFunction) Then $sUserFunction($oCOMError)
EndFunc   ;==>__ADO_ComErrorHandler_InternalFunction

 

 

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

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...