au3WebDriver icon indicating copy to clipboard operation
au3WebDriver copied to clipboard

Frame issues

Open Danp2 opened this issue 1 year ago • 42 comments

          I ran into problems handling frames on `Chrome` , so as so far I`m not able to test this.

Will open separate issue for handling frames.

Originally posted by @mlipok in https://github.com/Danp2/au3WebDriver/issues/487#issuecomment-1658496472

Danp2 avatar Jul 31 '23 14:07 Danp2

Could you test DemoFrames from wd_demo.au3 and say if it works fine for you on each browser ?

Can you be more specific? What errors / issues should I be looking for?

Danp2 avatar Jul 31 '23 14:07 Danp2

Seems like Chrome and Edge are failing on the tests that begin here --

#Region - Testing element location in frame set and iframe collecion

Danp2 avatar Jul 31 '23 15:07 Danp2

Also, all browsers are returning -1 for this line --

Local $aLocationOfElement = _WD_FrameListFindElement($sSession, $_WD_LOCATOR_ByCSSSelector, "li.nav-item[data-bs-original-title='Home Page'] a.nav-link[href='https://www.tutorialspoint.com/index.htm']")

Danp2 avatar Jul 31 '23 15:07 Danp2

So we have confirmed issue. Are you looking on this ? I be able in next few hours.

mlipok avatar Jul 31 '23 15:07 mlipok

This is an example of what I'm seeing with Chrome --

    __WD_Post: URL=HTTP://127.0.0.1:9515/session/e28110002b6ee495e0a547c51014dc14/frame; Data={"id":0}
    __WD_Post ==> No match [8] : HTTP status = 404 ResponseText={"value":{"error":"no such frame","message":"no such frame\n  (Session info: chrome=115.0.5790.110)","stacktrace":"Backtrace:\n\tGetHandleVerifier [0x00ED1C53+49427]\n\t(No symbol) [0x00E65F41]\n\t(No symbol) [0x00D6C510]\n\t(No symbol) [0x00D71720]\n\t(No symbol) [0x00DC82AC]\n\t(No symbol) [0x00DB4A1C]\n\t(No symbol) [0x00DC6F2A]\n\t(No symbol) [0x00DB4816]\n\t(No symbol) [0x00D91127]\n\t(No symbol) [0x00D922AD]\n\tGetHandleVerifier [0x01127149+2496009]\n\tGetHandleVerifier [0x0116D572+2783794]\n\tGetHandleVerifier [0x01167491+2758993]\n\tGetHandleVerifier [0x00F511D0+571024]\n\t(No symbol) [0x00E6F96A]\n\t(No symbol) [0x00E6BD88]\n\t(No symbol) [0x00E6BE6B]\n\t(No symbol) [0x00E5EA97]\n\tBaseThreadInitThunk [0x74EA7D59+25]\n\tRtlInitializeExceptionChain [0x771FB79B+107]\n\tRtlClearBits [0x771FB71F+191]\n"}}
    _WD_Window ==> No match [8] : Parameters:   Command=frame   Option={"id":0}
    _WD_FrameEnter ==> Webdriver Exception [10] : Parameters:    Identifier=null/1/1/0 Error on ID#4 > {"id":0}

I'm not sure why this is occurring or when I will get a chance to take a closer look.

Danp2 avatar Jul 31 '23 18:07 Danp2

Working on.

mlipok avatar Jul 31 '23 20:07 mlipok

some findings: https://bugs.chromium.org/p/chromedriver/issues/list?q=frame&can=2&sort=-id

https://bugs.chromium.org/p/chromedriver/issues/detail?id=4465&q=frame&can=2&sort=-id

https://bugs.chromium.org/p/chromedriver/issues/detail?id=4509&q=frame&can=2&sort=-id

https://bugs.chromium.org/p/chromedriver/issues/detail?id=4513&q=frame&can=2&sort=-id

mlipok avatar Jul 31 '23 20:07 mlipok

I already checked: Upcoming version: 115.0.5790.110 (r1148114)

https://googlechromelabs.github.io/chrome-for-testing/#stable https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/115.0.5790.110/win32/chromedriver-win32.zip

still the same issue

mlipok avatar Jul 31 '23 20:07 mlipok

It looks like when I use $__WDVERSION = "0.8.1" Together with current chromedriver.exe DemoFrames works fine.

mlipok avatar Jul 31 '23 20:07 mlipok

it looks that DemoFrames works fine with: https://stackoverflow.com/questions/19669786/check-if-element-is-visible-in-dom and had issues on: https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_iframe

https://www.tutorialspoint.com/html/html_frames.htm#

mlipok avatar Jul 31 '23 21:07 mlipok

That's from over a year ago. 😦 I would recommend that you narrow down the cause so that it can be reproduced with a minimal set of code. Something like --

	_WD_Navigate($sSession, 'https://www.tutorialspoint.com/html/html_frames.htm#')
	_WD_LoadWait($sSession)
	$aFrameList = _WD_FrameList($sSession, True)

Even more ideal would be to eliminate _WD_FrameList and use _WD_Window commands instead.

Danp2 avatar Jul 31 '23 21:07 Danp2

I was testing also other for example au3WebDriver-0.11.0 was first with _WD_FrameList so each older version has old DemoFrames

mlipok avatar Jul 31 '23 21:07 mlipok

Even more ideal would be to eliminate _WD_FrameList and use _WD_Window commands instead.

working on

mlipok avatar Jul 31 '23 21:07 mlipok

__WD_Post: URL=HTTP://127.0.0.1:9515/session/12e26bc8a5b17bb912c5cd72a5af6df5/execute/sync; Data={"script":"function FrameAttributes(FrameIDX) { let nodes = document.querySelectorAll('iframe');    if (nodes.length)   { return nodes[FrameIDX].outerHTML; }   else   { return window.frames[FrameIDX].frameElement.outerHTML; } }; return FrameAttributes(22);", "args":[]}
__WD_Post ==> Javascript Exception [23] : HTTP status = 500 ResponseText={"value":{"error":"javascript error","message":"javascript error: Cannot read properties of undefined (reading 'outerHTML')\n  (Session info: chrome=115.0.5790.110)","stacktrace":"Backtrace:\n\tGetHandleVerifier [0x003D1C63+49427]\n\t(No symbol) [0x00365F51]\n\t(No symbol) [0x0026C64D]\n\t(No symbol) [0x0026FAA2]\n\t(No symbol) [0x00270FD2]\n\t(No symbol) [0x002C7754]\n\t(No symbol) [0x002B4A1C]\n\t(No symbol) [0x002C6F2A]\n\t(No symbol) [0x002B4816]\n\t(No symbol) [0x00291127]\n\t(No symbol) [0x002922AD]\n\tGetHandleVerifier [0x00627159+2496009]\n\tGetHandleVerifier [0x0066D582+2783794]\n\tGetHandleVerifier [0x006674A1+2758993]\n\tGetHandleVerifier [0x004511E0+571024]\n\t(No symbol) [0x0036F97A]\n\t(No symbol) [0x0036BD98]\n\t(No symbol) [0x0036BE7B]\n\t(No symbol) [0x0035EAA7]\n\tBaseThreadInitThunk [0x76597D59+25]\n\tRtlInitializeExceptionChain [0x77E7B79B+107]\n\tRtlClearBits [0x77E7B71F+191]\n"}}
_WD_ExecuteScript ==> Javascript Exception [23] : javascript error: Cannot read properties of undefined (reading 'outerHTML')

mlipok avatar Jul 31 '23 21:07 mlipok

I saw the same earlier today while testing DemoFrames. I think if you look earlier in the logs you will see the "no such frame" error like I posted above.

Danp2 avatar Jul 31 '23 21:07 Danp2

Yes. I notice no such frame _WD_FrameEnter is not able to change frames. as for now I found quick solution in this function:

https://github.com/Danp2/au3WebDriver/blob/42dda7d9a9e78b3c7cc2d419b0e84eaf1335f6a8/wd_helper.au3#L848-L863

just modify this line: https://github.com/Danp2/au3WebDriver/blob/42dda7d9a9e78b3c7cc2d419b0e84eaf1335f6a8/wd_helper.au3#L863

;~ 	If $iErr = $_WD_ERROR_Success Then
	If 1 Then

and entire DemoFrames starts to works fine.

but as you can see not all frames are accesible: image

mlipok avatar Jul 31 '23 21:07 mlipok

It looks like some frames are blocked: image image

mlipok avatar Jul 31 '23 21:07 mlipok

After testing with FireFox the one thing what comes to my mind that Chrome gives us much more information.

Because FireFox returns only #39 frames and Chrome #145 frames

image

mlipok avatar Jul 31 '23 22:07 mlipok

Because FireFox returns only #39 frames and Chrome #145 frames

I wonder if that's a function of the website where it renders the page differently based upon the browser in use. 🤔

Danp2 avatar Jul 31 '23 22:07 Danp2

I think It is possible. I think that it depends on cookies and geolocation diferences in both browsers.

mlipok avatar Jul 31 '23 22:07 mlipok

ok so currently get another issue with: https://github.com/Danp2/au3WebDriver/blob/42dda7d9a9e78b3c7cc2d419b0e84eaf1335f6a8/wd_demo.au3#L942-L948

here is my modification:

	; entering to the frame
	_WD_DebugSwitch($_WD_DEBUG_Full)
	_WD_FrameEnter($sSession, $sFrame)
	If @error Then Return SetError(@error, @extended, '')

	ClipPut(_WD_GetSource($sSession))
	MsgBox($MB_TOPMOST, "", 111)
;~ 	$aFrameList = _WD_FrameList($sSession, True, 0,100)
;~ 	_ArrayDisplay($aFrameList, 'Test 2', 0, 0, Default, $sArrayHeader)

	ConsoleWrite("- " & @ScriptLineNumber & @CRLF)
	; get <select> element by it's name
	_WD_WaitElement($sSession,  $_WD_LOCATOR_ByXPath, '//*[@name="pets"]')
	If @error Then Return SetError(@error, @extended, '')
	_WD_DebugSwitch()
	MsgBox($MB_TOPMOST, "", 222)

please note that on FireFox it puts into clipboard entire desired frame content.

and for chrome you get: <html><head></head><body></body></html>

mlipok avatar Jul 31 '23 23:07 mlipok

this following part

	; entering to the frame
	_WD_DebugSwitch($_WD_DEBUG_Full)
	_WD_FrameEnter($sSession, $sFrame)
	If @error Then Return SetError(@error, @extended, '')

	ClipPut(_WD_GetSource($sSession))
	MsgBox($MB_TOPMOST, "", 111)
;~ 	$aFrameList = _WD_FrameList($sSession, True, 0,100)
;~ 	_ArrayDisplay($aFrameList, 'Test 2', 0, 0, Default, $sArrayHeader)

	ConsoleWrite("- " & @ScriptLineNumber & @CRLF)
	; get <select> element by it's name
	_WD_WaitElement($sSession,  $_WD_LOCATOR_ByXPath, '//*[@name="pets"]')
	If @error Then Return SetError(@error, @extended, '')
	_WD_DebugSwitch()
	MsgBox($MB_TOPMOST, "", 222)

will return

! Error = 7 occurred on: DemoSelectOptions
! _WD_LastHTTPResult = 404
! _WD_LastHTTPResponse = {"value":{"error":"no such element","message":"no such element: Unable to locate element: {\"method\":\"xpath\",\"selector\":\"//*[@name=\"pets\"]\"}\n  (Session info: chrome=115.0.5790.110)","stacktrace":"Backtrace:\n\tGetHandleVerifier [0x00351C63+49427]\n\t(No symbol) [0x002E5F51]\n\t(No symbol) [0x001EC64D]\n\t(No symbol) [0x00219818]\n\t(No symbol) [0x002198DB]\n\t(No symbol) [0x002487D2]\n\t(No symbol) [0x00234A64]\n\t(No symbol) [0x00246F2A]\n\t(No symbol) [0x00234816]\n\t(No symbol) [0x00211127]\n\t(No symbol) [0x002122AD]\n\tGetHandleVerifier [0x005A7159+2496009]\n\tGetHandleVerifier [0x005ED582+2783794]\n\tGetHandleVerifier [0x005E74A1+2758993]\n\tGetHandleVerifier [0x003D11E0+571024]\n\t(No symbol) [0x002EF97A]\n\t(No symbol) [0x002EBD98]\n\t(No symbol) [0x002EBE7B]\n\t(No symbol) [0x002DEAA7]\n\tBaseThreadInitThunk [0x76597D59+25]\n\tRtlInitializeExceptionChain [0x77E7B79B+107]\n\tRtlClearBits [0x77E7B71F+191]\n"}}

until you scroll into view #frame_advanced_select_with_multiple_features and '//*[@name="pets"]

mlipok avatar Jul 31 '23 23:07 mlipok

until you scroll into view #frame_advanced_select_with_multiple_features and '//*[@name="pets"]

is there something wrong with: _WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, '//*[@name="pets"]')

I mean _WD_WaitElement by defulat should not care about element visibilty:

	If $iOptions = Default Then $iOptions = $_WD_OPTION_None

	Local Const $bVisible = BitAND($iOptions, $_WD_OPTION_Visible)
	Local Const $bEnabled = BitAND($iOptions, $_WD_OPTION_Enabled)
	Local Const $bNoMatch = BitAND($iOptions, $_WD_OPTION_NoMatch)
	Local Const $bHidden = BitAND($iOptions, $_WD_OPTION_Hidden)

mlipok avatar Jul 31 '23 23:07 mlipok

Because FireFox returns only #39 frames and Chrome #145 frames

I wonder if that's a function of the website where it renders the page differently based upon the browser in use. 🤔

I think renderer currently in Chrome 115 stops to reneder/process iframes that are not visible, and thus using webedriver any frame/iframe element must be scrolled into view to be possible to enter the frame.

EDIT: Going to bed. Please analyze all my post/statment gvien here and give me back some answer/adivce.

mlipok avatar Jul 31 '23 23:07 mlipok

DemoSelectOptions

Honestly, I think there is something odd with that website as I am unable to open any of the frames in a separate tab.

Danp2 avatar Aug 01 '23 17:08 Danp2

Today I'm little tired. Going rest. Will back tomorrow.

mlipok avatar Aug 01 '23 17:08 mlipok

until you scroll into view #frame_advanced_select_with_multiple_features and '//*[@name="pets"]

It seems like the Chromium based browsers aren't loading the frame until it is scrolled into view (AKA lazy loading). In my testing, I was able to solve this by adding the following prior to entering the frame, which forcibly scrolls the frame into view --

	_WD_ElementActionEx($sSession, $sFrame, 'hover')

Danp2 avatar Aug 01 '23 22:08 Danp2

hm... it means that I should suplement _WD_FrameList accordingly

mlipok avatar Aug 02 '23 06:08 mlipok

A few thoughts / suggestions --

  • Maybe you could make it optional? Otherwise, the webpage would be forced to unnecessarily scroll to each frame.
  • Perhaps you could use _WD_GetSource to detect an empty frame and then react accordingly
  • It would be good to research further to confirm that this is the only reason that DemoFrames / _WD_FrameList is failing

Danp2 avatar Aug 02 '23 12:08 Danp2

A few thoughts / suggestions --

  • Maybe you could make it optional? Otherwise, the webpage would be forced to unnecessarily scroll to each frame.

that was immediately one of my assumptions

  • Perhaps you could use _WD_GetSource to detect an empty frame and then react accordingly

good point.

  • It would be good to research further to confirm that this is the only reason that DemoFrames / _WD_FrameList is failing

will work on all of this

mlipok avatar Aug 02 '23 12:08 mlipok