au3WebDriver
au3WebDriver copied to clipboard
Frame issues
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
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?
Seems like Chrome and Edge are failing on the tests that begin here --
#Region - Testing element location in frame set and iframe collecion
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']")
So we have confirmed issue. Are you looking on this ? I be able in next few hours.
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.
Working on.
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
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
It looks like when I use $__WDVERSION = "0.8.1"
Together with current chromedriver.exe DemoFrames
works fine.
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#
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.
I was testing also other for example au3WebDriver-0.11.0 was first with _WD_FrameList
so each older version has old DemoFrames
Even more ideal would be to eliminate
_WD_FrameList
and use_WD_Window
commands instead.
working on
__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')
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.
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:
It looks like some frames are blocked:
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
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 It is possible. I think that it depends on cookies and geolocation diferences in both browsers.
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>
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"]
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)
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.
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.
Today I'm little tired. Going rest. Will back tomorrow.
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')
hm... it means that I should suplement _WD_FrameList
accordingly
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
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