Danp2 / au3WebDriver

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

_WD_FrameList - not always takes all frames #397

Closed mlipok closed 1 year ago

mlipok commented 2 years ago

Bug report

Describe the bug

_WD_FrameList() gets list of frames which is not always complete. It is due to the fact that Not all frames document are load completly.

How to reproduce

use this following code.

Func UserTesting() ; here you can replace the code to test your stuff before you ask on the forum
    _WD_Navigate($sSession, 'https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_iframe')
    _WD_LoadWait($sSession)

    ; Example 1 - from 'https://www.w3schools.com' get frame list as string
    Local $sResult = _WD_FrameList($sSession, False)
    #forceref $sResult
    ConsoleWrite("! ---> @error=" & @error & "  @extended=" & @extended & " : Example 1" & @CRLF)
    ConsoleWrite($sResult & @CRLF)

    ; Example 2 - from 'https://www.w3schools.com' get frame list as array
    Local $aFrameList = _WD_FrameList($sSession, True)
    ConsoleWrite("! ---> @error=" & @error & "  @extended=" & @extended & " : Example 2" & @CRLF)
    _ArrayDisplay($aFrameList, 'Example 2 - w3schools.com - get frame list as array', 0, 0, Default, 'Absolute Identifiers > _WD_FrameEnter|Relative Identifiers > _WD_FrameEnter|IFRAME attributes|URL|Body ElementID|IsHidden')

    ; Example 2 - from 'https://www.w3schools.com' get frame list as array
    $aFrameList = _WD_FrameList($sSession, True)
    ConsoleWrite("! ---> @error=" & @error & "  @extended=" & @extended & " : Example 2 - again" & @CRLF)
    _ArrayDisplay($aFrameList, 'Example 2 - w3schools.com - get frame list as array - again', 0, 0, Default, 'Absolute Identifiers > _WD_FrameEnter|Relative Identifiers > _WD_FrameEnter|IFRAME attributes|URL|Body ElementID|IsHidden')
EndFunc

When first _ArrayDisplay is displayed wait at least 1 minute before you close the displayed array. Compare second _ArrayDisplay result with the frst result. Also check window.top.document.querySelectorAll('iframe') in browser console.

Expected behavior

Always full list of frames.

Screenshots

image

Additional context

none

System under test

not related

mlipok commented 2 years ago

please assign this issue to me.

btw. I will try to fix it in next few weeks, as this is not a pressing problem.

Danp2 commented 2 years ago

You may want to consider making your future "fix" conditional. By this I mean allow the existing functionality to continue to exist so that you aren't forcing all frames to fully load. This is essentially providing a list of frames for a given point in time where you can't include a frame in a list if the frame doesn't yet exist.

mlipok commented 1 year ago

After some thought. It should be assumed that some websites work dynamically. This means that the user/scripter should first bring the page to a static state.

However, if the website undergoes constant dynamic changes and the number of frames changes (e.g. advertisements appear and disappear), we are not able to ensure that the state of the website at the beginning when the function is called will be constant in time until the completion of the processing by this function , the more so that it is quite a complementary function that performs a lot of operations that can be extended in time even to many seconds.

.....

mlipok commented 1 year ago

I think that it should be taken as normal and despite everything (even in the case of an error), try to return the result that has been correctly processed so far, or even otherwise. If the given information is no longer available, leave the field empty, without returning an error.

If you initially agree with this approach, let's say let's leave this task as pending, until other tasks are completed.

mlipok commented 1 year ago

I think that it should be taken as normal and despite everything (even in the case of an error), try to return the result that has been correctly processed so far, or even otherwise. If the given information is no longer available, leave the field empty, without returning an error.

If you initially agree with this approach, let's say let's leave this task as pending, until other tasks are completed.

@Danp2 Can you confirm that you agree or do you have other opinion ?

Danp2 commented 1 year ago

Yes, I see the existing functionality as a "feature" rather than a bug since you can't gather data on an element that doesn't yet exist.

mlipok commented 1 year ago

you can't gather data on an element that doesn't yet exist

..... or disappeared during processing.