Danp2 / au3WebDriver

Web Driver UDF for AutoIt
MIT License
107 stars 21 forks source link

invalid argument calling frameEnter function #474

Closed hychul11 closed 1 year ago

hychul11 commented 1 year ago

Bug report

Describe the bug

invalid argument erro occur calling FrameEnter function on edge

1) get frame object using xpath

2) call WD_FrameEnter($sSession, frameobject)

error occurs (invalid argument)

edge driver Version: 113.0.1774.9 edge version : 113.0.1774.42

It's working on edge 113 and edge driver 112

Danp2 commented 1 year ago

@hychul11 Thanks for the report. I was able to reproduce the issue using both Chrome and Edge.

Note that Firefox doesn't exhibit this behavior, so that it may be an issue with Chromium base browsers.

Danp2 commented 1 year ago

Issue is caused by this section of code --

https://github.com/Danp2/au3WebDriver/blob/3a7921ca112830f6ccc2b2929d65df2b4126ea8c/wd_helper.au3#L574-L579

Danp2 commented 1 year ago

Using FF, a valid GUID is returned --

    __WD_Post: URL=HTTP://127.0.0.1:4444/session/d5fd23c4-a00c-4fb4-b784-7f15ed8facdc/element; Data={"using":"xpath","value":"\/\/iframe[@id='iframeResult']"}
    __WD_Post ==> Success [0] : HTTP status = 200 ResponseText={"value":{"element-6066-11e4-a52e-4f735466cecf":"c8f18d90-22c9-4884-8150-743805919ec6"}}

Using Chrome, this is what is being returned --

    __WD_Post: URL=HTTP://127.0.0.1:9515/session/3836e36e0c33ae73e0efec03ec38f90c/element; Data={"using":"xpath","value":"\/\/iframe[@id='iframeResult']"}
    __WD_Post ==> Success [0] : HTTP status = 200 ResponseText={"value":{"element-6066-11e4-a52e-4f735466cecf":"F6074E713BC3AB1F060CBB67F45E9E30_element_12"}}
Danp2 commented 1 year ago

I took a quick look at this section of the W3C specs, and I don't see where there is a requirement for the node id to be a valid GUID. It simply states --

The WebDriver node id is a globally unique string representing a handle to a DOM node in a specific WebDriver session.

So, I believe the solution is to remove the _WinAPI_GUIDFromString check that was added in https://github.com/Danp2/au3WebDriver/commit/3a7921ca112830f6ccc2b2929d65df2b4126ea8c (see also https://github.com/Danp2/au3WebDriver/pull/363)

mlipok commented 1 year ago

will take a look ASAP

Danp2 commented 1 year ago

@hychul11 I've posted a proposed fix for this issue here. You can test by downloading the file and replacing your existing copy of wd_helper.au3. Please respond here with your results after testing.

hychul11 commented 1 year ago

I tested it and it worked fine. Thanks for your quick fix!

mlipok commented 1 year ago

I checked this (compared):

__WD_Post ==> Success [0] : HTTP status = 200 ResponseText={"value":{"element-6066-11e4-a52e-4f735466cecf":"c8f18d90-22c9-4884-8150-743805919ec6"}}
__WD_Post ==> Success [0] : HTTP status = 200 ResponseText={"value":{"element-6066-11e4-a52e-4f735466cecf":"F6074E713BC3AB1F060CBB67F45E9E30_element_12"}}

We can still think about this case in this way:

__WD_Post ==> Success [0] : HTTP status = 200 ResponseText={"value":{"element-6066-11e4-a52e-4f735466cecf":"c8f18d90-22c9-4884-8150-743805919ec6"}}
__WD_Post ==> Success [0] : HTTP status = 200 ResponseText={"value":{"element-6066-11e4-a52e-4f735466cecf":"F6074E71-3BC3-AB1F-060C-BB67F45E9E30_element_12"}}

and we can always do it this way:

_Example()
Func _Example()
    Local $vIdentifier = "F6074E713BC3AB1F060CBB67F45E9E30_element_12"
    _WinAPI_GUIDFromString("{" & $vIdentifier & "}")
    If @error Then _WinAPI_GUIDFromString("{" & StringRegExpReplace($vIdentifier,"(.{8})(.{4})(.{4})(.{4})(.{12})(.+)", "$1-$2-$3-$4-$5") & "}")
    If @error Then ConsoleWrite("! ---> @error=" & @error & "  @extended=" & @extended & " : " & @ScriptLineNumber & @CRLF)
EndFunc
mlipok commented 1 year ago

Is this issue occurs because there was a change in ChromeDriver ?

I'm starting to wonder how this will affect _WD_GetElementByRegEx()

Danp2 commented 1 year ago

"F6074E713BC3AB1F060CBB67F45E9E30_element_12" >> "F6074E71-3BC3-AB1F-060C-BB67F45E9E30_element_12"

@mlipok I believe this is the wrong approach because the specs require a unique string, not a GUID. Plus there isn't a guarantee that the format currently being returned by Chrome & Edge will remain constant, so your suggested change could lead to future problems.

Danp2 commented 1 year ago

Is this issue occurs because there was a change in ChromeDriver?

IDK, but it shouldn't be too difficult to perform some tests to find the answer. Because both Chrome and Edge are affected, I wonder if it could be due to a change in the Chromium source. 🤔

Edit: Found this recent change to the Chromium source that may be related.

I'm starting to wonder how this will affect _WD_GetElementByRegEx()

I don't understand where this concern is coming from. Can you be more specific?

mlipok commented 1 year ago

I juat start 2 day vacation over this weekend Will check deeply ASAP

Danp2 commented 1 year ago

@mlipok Any further feedback before I close this out?

mlipok commented 1 year ago

I'm fine with your change.