Skip to content

_WD_FrameList #362

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 34 commits into from
Aug 24, 2022
Merged

_WD_FrameList #362

merged 34 commits into from
Aug 24, 2022

Conversation

mlipok
Copy link
Contributor

@mlipok mlipok commented Aug 2, 2022

Pull request

Proposed changes

was discussed here:
#354

Checklist

  • I have read and noticed the CODE OF CONDUCT document
  • I have read and noticed the CONTRIBUTING document
  • I have added necessary documentation or screenshots (if appropriate)

Types of changes

  • Bugfix (change which fixes an issue)
  • Feature (change which adds functionality)
  • Code style update (formatting, renaming)
  • Refactoring (functional, structural)
  • Documentation content changes
  • Other (please describe)

What is the current behavior?

no way to list frames list

What is the new behavior?

it is easy with _WD_FrameList

Additional context

#354 (comment)

can be tested with:

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
	ConsoleWrite(_WD_FrameList($sSession,  False) & @CRLF)

	; Example 2 - from 'https://www.w3schools.com' get frame list as array, with HTML content of each document
	Local $aFrameList = _WD_FrameList($sSession,  True, '', True)
	_ArrayDisplay($aFrameList, 'Example 2', 0, 0, Default, 'Absolute Identifiers > _WD_FrameEnter|Relative Identifiers > _WD_FrameEnter|IFRAME attributes|URL|Body ElementID|HTML')


	_WD_FrameEnter($sSession, 2)
	_WD_FrameEnter($sSession, 0)
	; Example 3 - from 'https://www.w3schools.com' get frame list as array, with relative location
	$aFrameList = _WD_FrameList($sSession, True, '', False)
	_ArrayDisplay($aFrameList, 'Example 3', 0, 0, Default, 'Absolute Identifiers > _WD_FrameEnter|Relative Identifiers > _WD_FrameEnter|IFRAME attributes|URL|Body ElementID|HTML')

	_WD_Navigate($sSession, 'https://stackoverflow.com/questions/19669786/check-if-element-is-visible-in-dom')
	_WD_LoadWait($sSession)

	; Example 4 - from 'https://stackoverflow.com' get frame list as string
	ConsoleWrite(_WD_FrameList($sSession,  False) & @CRLF)

	; Example 5 - from 'https://stackoverflow.com' get frame list as array
	#TODO this following line - NOT WORKS - should be checked
;~ 	$aFrameList = _WD_FrameList($sSession, True)
	$aFrameList = _WD_FrameList($sSession,  True, '', False)
	_ArrayDisplay($aFrameList, 'Example 5', 0, 0, Default, 'Absolute Identifiers > _WD_FrameEnter|Relative Identifiers > _WD_FrameEnter|IFRAME attributes|URL|Body ElementID|HTML')

	; Example 6 - from 'https://stackoverflow.com' get frame list as array - but only this one which contain id="question-header"
	$aFrameList = _WD_FrameList($sSession,  True, '(?i)id=.question-header.')
	_ArrayDisplay($aFrameList, 'Example 6', 0, 0, Default, 'Absolute Identifiers > _WD_FrameEnter|Relative Identifiers > _WD_FrameEnter|IFRAME attributes|URL|Body ElementID|HTML')

EndFunc   ;==>UserTesting

image

System under test

not related

@mlipok mlipok mentioned this pull request Aug 2, 2022
@mlipok
Copy link
Contributor Author

mlipok commented Aug 2, 2022

big thanks to @TheDcoder for his answer here:
https://www.autoitscript.com/forum/topic/205553-webdriver-udf-help-support-iii/?do=findComment&comment=1505451

It helps me to solve the problem with checking current frame level, which was the main problem with providing relative Identifiers for _WD_FrameEnter.

@mlipok
Copy link
Contributor Author

mlipok commented Aug 2, 2022

@Danp2 as you can see finally I decide to return as result both absolute and relative paths, so that I met mine and yours requirements without having to use a switch as a parameter.

@mlipok mlipok marked this pull request as ready for review August 3, 2022 13:33
@mlipok
Copy link
Contributor Author

mlipok commented Aug 3, 2022

Please review this PR

and close related ISSUE #354

@Danp2
Copy link
Owner

Danp2 commented Aug 3, 2022

I have not analyzed or run this code, but a major problem I can foresee is that of maintaining the current browsing context. If I am currently located two levels deep inside frames when calling a function, then I would expect to still be in that same "location" upon the function's return.

Have you given this any consideration? If yes, then how do you plan to address it?

@mlipok
Copy link
Contributor Author

mlipok commented Aug 3, 2022

I can foresee is that of maintaining the current browsing context. If I am currently located two levels deep inside frames when calling a function, then I would expect to still be in that same "location" upon the function's return.

Have you given this any consideration? If yes, then how do you plan to address it?

Yes of course.

I just fixed this part, as you pointed me:

I'm confused by this implementation. Why would you be calling _WD_FrameEnter with the body element as a target?

Take a look here:

au3WebDriver/wd_helper.au3

Lines 697 to 703 in 74f6fb0

If $sStartLocation Then ; Back to "calling frame"
_WD_FrameEnter($sSession, $sStartLocation)
$iErr = @error
EndIf
If $iErr Then
$sMessage = ' Was not able to check / back to "calling frame"'
EndIf

@mlipok
Copy link
Contributor Author

mlipok commented Aug 3, 2022

here is my testing script:

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
	ConsoleWrite(_WD_FrameList($sSession, False) & @CRLF)

	; Example 2 - from 'https://www.w3schools.com' get frame list as array, with HTML content of each document
	Local $aFrameList = _WD_FrameList($sSession, True, '', True)
	_ArrayDisplay($aFrameList, 'Example 2', 0, 0, Default, 'Absolute Identifiers > _WD_FrameEnter|Relative Identifiers > _WD_FrameEnter|IFRAME attributes|URL|Body ElementID|HTML')


	_WD_FrameEnter($sSession, 'null/2/0')
	If @error Then
		If @error Then MsgBox($MB_OK + $MB_TOPMOST + $MB_ICONERROR, "'null/2/0'", "@error = " & @error & @CRLF & "@extended = " & @extended)
		_WD_FrameEnter($sSession, Null)
		_WD_FrameEnter($sSession, 2)
		_WD_FrameEnter($sSession, 0)
	EndIf
	; Example 3 - from 'https://www.w3schools.com' get frame list as array, with relative location
	$aFrameList = _WD_FrameList($sSession, True, '', False)
	_ArrayDisplay($aFrameList, 'Example 3 - relative to "null/2/0"', 0, 0, Default, 'Absolute Identifiers > _WD_FrameEnter|Relative Identifiers > _WD_FrameEnter|IFRAME attributes|URL|Body ElementID|HTML')

	_WD_Navigate($sSession, 'https://stackoverflow.com/questions/19669786/check-if-element-is-visible-in-dom')
	_WD_LoadWait($sSession)

	; Example 4 - from 'https://stackoverflow.com' get frame list as string
	ConsoleWrite(_WD_FrameList($sSession, False) & @CRLF)

	; Example 5 - from 'https://stackoverflow.com' get frame list as array
	#TODO this following line - NOT WORKS - should be checked
;~ 	$aFrameList = _WD_FrameList($sSession, True)
	$aFrameList = _WD_FrameList($sSession, True, '', False)
	_ArrayDisplay($aFrameList, 'Example 5', 0, 0, Default, 'Absolute Identifiers > _WD_FrameEnter|Relative Identifiers > _WD_FrameEnter|IFRAME attributes|URL|Body ElementID|HTML')

	; Example 6 - from 'https://stackoverflow.com' get frame list as array - but only this one which contain id="question-header"
	$aFrameList = _WD_FrameList($sSession, True, '(?i)id=.question-header.', False)
	_ArrayDisplay($aFrameList, 'Example 6', 0, 0, Default, 'Absolute Identifiers > _WD_FrameEnter|Relative Identifiers > _WD_FrameEnter|IFRAME attributes|URL|Body ElementID|HTML')

	_WD_FrameEnter($sSession, 'null/2')
	If @error Then
		If @error Then MsgBox($MB_OK + $MB_TOPMOST + $MB_ICONERROR, "'null/2/0'", "@error = " & @error & @CRLF & "@extended = " & @extended)
		_WD_FrameEnter($sSession, Null)
		_WD_FrameEnter($sSession, 2)
	EndIf
	; Example 7 - from 'https://stackoverflow.com' get frame list as array, with relative location
	$aFrameList = _WD_FrameList($sSession, True, '', False)
	_ArrayDisplay($aFrameList, 'Example 7v1 - relative to "null/2"', 0, 0, Default, 'Absolute Identifiers > _WD_FrameEnter|Relative Identifiers > _WD_FrameEnter|IFRAME attributes|URL|Body ElementID|HTML')

	$aFrameList = _WD_FrameList($sSession, True, '', False)
	_ArrayDisplay($aFrameList, 'Example 7v2 - should still be relative to "null/2"', 0, 0, Default, 'Absolute Identifiers > _WD_FrameEnter|Relative Identifiers > _WD_FrameEnter|IFRAME attributes|URL|Body ElementID|HTML')

EndFunc   ;==>UserTesting

and example of results which you are asking for:

image

image

@Danp2
Copy link
Owner

Danp2 commented Aug 3, 2022

Here's the code for a very simple test that I ran --

	_WD_Navigate($sSession, 'https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_iframe')
	_WD_LoadWait($sSession)

	_WD_FrameEnter($sSession, 0)
	ConsoleWrite("IsWindowTop = " & _WD_IsWindowTop($sSession) & @CRLF)

	; Example 1 - from 'https://www.w3schools.com' get frame list as string
	ConsoleWrite(_WD_FrameList($sSession, False) & @CRLF)

	ConsoleWrite("IsWindowTop = " & _WD_IsWindowTop($sSession) & @CRLF)
	return
Results

+ wd_demo.au3: Running: UserTesting
__WD_Post ==> Success [0] : HTTP status = 200
_WD_Navigate ==> Success [0] : Parameters:   URL=https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_iframe
_WD_LoadWait ==> Success [0] : Parameters:    Delay=Default    Timeout=Default    Element=Default
__WD_Post ==> Success [0] : HTTP status = 200
_WD_Window ==> Success [0] : Parameters:   Command=frame   Option={"id":0}
_WD_FrameEnter ==> Success [0] : Parameters:    Identifier=0
__WD_Post ==> Success [0] : HTTP status = 200
_WD_ExecuteScript ==> Success [0]
_WD_IsWindowTop ==> Success [0]
IsWindowTop = False
__WD_Post ==> Success [0] : HTTP status = 200
_WD_ExecuteScript ==> Success [0]
__WD_Post ==> Success [0] : HTTP status = 200
_WD_Window ==> Success [0] : Parameters:   Command=frame   Option={"id":null}
_WD_FrameEnter ==> Success [0] : Parameters:    Identifier=
__WD_Post ==> Success [0] : HTTP status = 200
_WD_ExecuteScript ==> Success [0]
__WD_Post ==> Success [0] : HTTP status = 200
_WD_ExecuteScript ==> Success [0]
__WD_Post ==> Success [0] : HTTP status = 200
_WD_ExecuteScript ==> Success [0]
_WD_GetFrameCount ==> Success [0]
__WD_Post ==> Success [0] : HTTP status = 200
_WD_ExecuteScript ==> Success [0]
__WD_Post ==> Success [0] : HTTP status = 200
_WD_Window ==> Success [0] : Parameters:   Command=frame   Option={"id":null}
_WD_FrameEnter ==> Success [0] : Parameters:    Identifier=
__WD_Post ==> Success [0] : HTTP status = 200
_WD_Window ==> Success [0] : Parameters:   Command=frame   Option={"id":0}
_WD_FrameEnter ==> Success [0] : Parameters:    Identifier=0
__WD_Post ==> Success [0] : HTTP status = 200
_WD_ExecuteScript ==> Success [0]
__WD_Post ==> Success [0] : HTTP status = 200
_WD_ExecuteScript ==> Success [0]
__WD_Post ==> Success [0] : HTTP status = 200
_WD_ExecuteScript ==> Success [0]
_WD_GetFrameCount ==> Success [0]
__WD_Post ==> Success [0] : HTTP status = 200
_WD_ExecuteScript ==> Success [0]
__WD_Post ==> Success [0] : HTTP status = 200
_WD_Window ==> Success [0] : Parameters:   Command=frame   Option={"id":null}
_WD_FrameEnter ==> Success [0] : Parameters:    Identifier=
__WD_Post ==> Success [0] : HTTP status = 200
_WD_Window ==> Success [0] : Parameters:   Command=frame   Option={"id":0}
_WD_FrameEnter ==> Success [0] : Parameters:    Identifier=0
__WD_Post ==> Success [0] : HTTP status = 200
_WD_Window ==> Success [0] : Parameters:   Command=frame   Option={"id":0}
_WD_FrameEnter ==> Success [0] : Parameters:    Identifier=0
__WD_Post ==> Success [0] : HTTP status = 200
_WD_ExecuteScript ==> Success [0]
__WD_Post ==> Success [0] : HTTP status = 200
_WD_ExecuteScript ==> Success [0]
__WD_Post ==> Success [0] : HTTP status = 200
_WD_ExecuteScript ==> Success [0]
_WD_GetFrameCount ==> Success [0]
__WD_Post ==> Success [0] : HTTP status = 200
_WD_ExecuteScript ==> Success [0]
__WD_Post ==> Success [0] : HTTP status = 200
_WD_Window ==> Success [0] : Parameters:   Command=frame   Option={"id":null}
_WD_FrameEnter ==> Success [0] : Parameters:    Identifier=
__WD_Post ==> Success [0] : HTTP status = 200
_WD_Window ==> Success [0] : Parameters:   Command=frame   Option={"id":0}
_WD_FrameEnter ==> Success [0] : Parameters:    Identifier=0
__WD_Post ==> Success [0] : HTTP status = 200
_WD_Window ==> Success [0] : Parameters:   Command=frame   Option={"id":0}
_WD_FrameEnter ==> Success [0] : Parameters:    Identifier=0
__WD_Post ==> Success [0] : HTTP status = 200
_WD_Window ==> Success [0] : Parameters:   Command=frame   Option={"id":0}
_WD_FrameEnter ==> Success [0] : Parameters:    Identifier=0
__WD_Post ==> Success [0] : HTTP status = 200
_WD_ExecuteScript ==> Success [0]
__WD_Post ==> Success [0] : HTTP status = 200
_WD_ExecuteScript ==> Success [0]
__WD_Post ==> Success [0] : HTTP status = 200
_WD_ExecuteScript ==> Success [0]
_WD_GetFrameCount ==> Success [0]
__WD_FrameList_Internal ==> Success [0]
__WD_Post ==> Success [0] : HTTP status = 200
_WD_Window ==> Success [0] : Parameters:   Command=parent   Option={}
_WD_FrameLeave ==> Success [0]
__WD_FrameList_Internal ==> Success [0]
__WD_Post ==> Success [0] : HTTP status = 200
_WD_Window ==> Success [0] : Parameters:   Command=parent   Option={}
_WD_FrameLeave ==> Success [0]
__WD_FrameList_Internal ==> Success [0]
__WD_Post ==> Success [0] : HTTP status = 200
_WD_Window ==> Success [0] : Parameters:   Command=parent   Option={}
_WD_FrameLeave ==> Success [0]
__WD_FrameList_Internal ==> Success [0]
__WD_Post ==> No match [8] : HTTP status = 404
_WD_Window ==> No match [8] : Parameters:   Command=frame   Option={"id":{"element-6066-11e4-a52e-4f735466cecf":"null/0"}}
_WD_FrameEnter ==> Webdriver Exception [10] : Parameters:    Identifier=null/0
_WD_FrameList ==> Webdriver Exception [10] : Parameters:    ReturnAsArray=False   Filter=   ReturnHTML=False Was not able to check / back to "calling frame"
null|null||https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_iframe|9dc14e90-b58b-40ab-be92-ecd1dd65a3b3|
null/0||<iframe id="iframeResult" name="iframeResult" allowfullscreen="true" frameborder="0"></iframe>|https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_iframe|15069330-e0f9-4795-a5de-df31054a7d77|
null/0/0|0|<iframe src="https://www.w3schools.com" title="W3Schools Free Online Web Tutorials">
</iframe>|https://www.w3schools.com/|4bd19bb2-7460-46f8-a256-96ebe875303e|
null/0/0/0|0/0|<iframe src="/howto/tryhow_js_slideshow_ifr.htm" id="howto_iframe"></iframe>|https://www.w3schools.com/howto/tryhow_js_slideshow_ifr.htm|8b09ff58-ba52-4b85-944f-92a3504ec44b|
__WD_Post ==> Success [0] : HTTP status = 200
_WD_ExecuteScript ==> Success [0]
_WD_IsWindowTop ==> Success [0]
IsWindowTop = True
+ wd_demo.au3: Finished: UserTesting
__WD_Delete ==> Success [0] : HTTP status = 200
_WD_DeleteSession ==> Success [0] : WebDriver session deleted

Comments

  • Logs should be less verbose when in "Info" mode
  • Some errors are occurring with _WD_FrameEnter due to Identifier=null/0. I'm guessing this is due to pending changes to _WD_FrameEnter that aren't part of this PR
  • IsWindowTop = False before calling your function but True afterwards

@mlipok
Copy link
Contributor Author

mlipok commented Aug 3, 2022

Comments

  • Logs should be less verbose when in "Info" mode

fixed in my WIP version

  • Some errors are occurring with _WD_FrameEnter due to Identifier=null/0. I'm guessing this is due to pending changes to _WD_FrameEnter that aren't part of this PR

exaclty

  • IsWindowTop = False before calling your function but True afterwards

will check when I end refactoring $sFilter

@mlipok
Copy link
Contributor Author

mlipok commented Aug 3, 2022

Comments

  • Logs should be less verbose when in "Info" mode

fixed in my WIP version

fixed on further changes

  • IsWindowTop = False before calling your function but True afterwards

will check when I end refactoring $sFilter

uisng this commit: further changes

and

	$_WD_DEBUG = $_WD_DEBUG_Error
	ConsoleWrite("> " & @ScriptLineNumber & " IsWindowTop = " & _WD_IsWindowTop($sSession) & @CRLF)
	_WD_FrameEnter($sSession, 'null/2')
	If @error Then
		If @error Then MsgBox($MB_OK + $MB_TOPMOST + $MB_ICONERROR, "'null/2/0'", "@error = " & @error & @CRLF & "@extended = " & @extended)
		_WD_FrameEnter($sSession, Null)
		_WD_FrameEnter($sSession, 2)
	EndIf
	ConsoleWrite("> " & @ScriptLineNumber & " IsWindowTop = " & _WD_IsWindowTop($sSession) & @CRLF)

	; Example 7 - from 'https://stackoverflow.com' get frame list as array, with relative location
	$aFrameList = _WD_FrameList($sSession, True, '', False)
	_ArrayDisplay($aFrameList, 'Example 7v1 - relative to "null/2"', 0, 0, Default, 'Absolute Identifiers > _WD_FrameEnter|Relative Identifiers > _WD_FrameEnter|IFRAME attributes|URL|Body ElementID|HTML')
	ConsoleWrite("> " & @ScriptLineNumber & " IsWindowTop = " & _WD_IsWindowTop($sSession) & @CRLF)

	$aFrameList = _WD_FrameList($sSession, True, '', False)
	_ArrayDisplay($aFrameList, 'Example 7v2 - should still be relative to "null/2"', 0, 0, Default, 'Absolute Identifiers > _WD_FrameEnter|Relative Identifiers > _WD_FrameEnter|IFRAME attributes|URL|Body ElementID|HTML')
	ConsoleWrite("> " & @ScriptLineNumber & " IsWindowTop = " & _WD_IsWindowTop($sSession) & @CRLF)

I get this results:

> 970 IsWindowTop = True
> 977 IsWindowTop = False
> 982 IsWindowTop = False
> 986 IsWindowTop = False

@mlipok
Copy link
Contributor Author

mlipok commented Aug 6, 2022

Now I have a question.
Would you like to see here an option to filter with $_WD_LOCATOR_ByXPath and $_WD_LOCATOR_ByCSSSelector and not only with RegExp pattern ?

@mlipok
Copy link
Contributor Author

mlipok commented Aug 6, 2022

Now I have a question. Would you like to see here an option to filter with $_WD_LOCATOR_ByXPath and $_WD_LOCATOR_ByCSSSelector and not only with RegExp pattern ?

I hope to allow the user to check on which FRAME the given element exists.

@mlipok
Copy link
Contributor Author

mlipok commented Aug 24, 2022

so we should change

_WD_FrameEnter($sSession, 'null/2/0')

to:

_WD_FrameEnter($sSession, 'null/0')

@mlipok
Copy link
Contributor Author

mlipok commented Aug 24, 2022

This site is very strange because

I had to stop checking for error after LoadWait

_WD_LoadWait($sSession, 100, 10 * 1000)
; intentionally do not check for error here

$iErr = @error
If 0 And @error Then
	$sMessage = 'Error occured on "' & $sLevel & '" level when waiting for a browser page load to complete'
Else

because Ex1 was always succesfull but Ex2 in most cases end due to LoadWait timeout.

After I stop checking I get such results:

image

@mlipok
Copy link
Contributor Author

mlipok commented Aug 24, 2022

after this: _WD_LoadWait error not handled
and using: demo: null/2/0 > null/0

I have such Ex3 result

image

@mlipok

This comment was marked as off-topic.

@mlipok
Copy link
Contributor Author

mlipok commented Aug 24, 2022

it would be helpfull to change _WD_LoadWait behavior on the fly without touching capabilities.
If you agree then I open separate Issue for this.

as so far this #384 is only error handling improvements so I still wait on your decision about on the fly feature.

@Danp2
Copy link
Owner

Danp2 commented Aug 24, 2022

@mlipok

  • I created a separate issue (see _WD_LoadWait() enhancements #385) to discuss your proposed enhancements to _WD_LoadWait.
  • Why do you need to call _WD_LoadWait inside __WD_FrameList_Internal?

@mlipok
Copy link
Contributor Author

mlipok commented Aug 24, 2022

Thanks

  • Why do you need to call _WD_LoadWait inside __WD_FrameList_Internal?

Because _WD_LoadWait which is used after navigation is not checking for all frames but only on top document.

@mlipok
Copy link
Contributor Author

mlipok commented Aug 24, 2022

  • Why do you need to call _WD_LoadWait inside __WD_FrameList_Internal?

Because _WD_LoadWait which is used after navigation is not checking for all frames but only on top document.

I mention about this problem here: #385 (comment)

@mlipok
Copy link
Contributor Author

mlipok commented Aug 24, 2022

For this reason currently _WD_LoadWait is required and in the future it should be refactored/enchanged in _WD_FrameList.

But for this stage please leave it as it is.
And if you do not have other questions or request, please to not hesitate to merge this PR.

@mlipok mlipok mentioned this pull request Aug 24, 2022
9 tasks
@Danp2
Copy link
Owner

Danp2 commented Aug 24, 2022

Why do you need to call _WD_LoadWait inside __WD_FrameList_Internal?

Because _WD_LoadWait which is used after navigation is not checking for all frames but only on top document.

But is it still required? Please think before answering. Previous revisions of _WD_FrameList returned more details about the frame, such as HTML. Was the need for calling _WD_LoadWait for each frame eliminated when those features were removed?

@mlipok
Copy link
Contributor Author

mlipok commented Aug 24, 2022

But is it still required?

results when I use _WD_LoadWait

image

image

results when I comment out _WD_LoadWait

image

image

@Danp2
Copy link
Owner

Danp2 commented Aug 24, 2022

I had to stop checking for error after LoadWait because Ex1 was always succesfull but Ex2 in most cases end due to LoadWait timeout.

You should dig into this further to better understand the reason for the difference in behavior.

If 0 And @error Then

This is ugly "fix"

@Danp2
Copy link
Owner

Danp2 commented Aug 24, 2022

@mlipok Those screenshots aren't even from the same examples.

@mlipok
Copy link
Contributor Author

mlipok commented Aug 24, 2022

I added MsgBox

MsgBox(0, "", 'Slow down internet speed to "Regular 3G" or even "Regular 2G"')
; now lets try to check frame list and using locations as path:
; go to website
_WD_Navigate($sSession, 'https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_iframe')
_WD_LoadWait($sSession)

after it popup's I changed in network tab in DevTools:
image

And I get
image

then I wait 10 second, and close _ArrayDisplay result from Example 2

And I get _ArrayDisplay result form Example 3
image

They are different as when I wait 10 seconds then document was still loading.
For this reason _WD_LoadWait is required IMHO.

@mlipok
Copy link
Contributor Author

mlipok commented Aug 24, 2022

@mlipok Those screenshots aren't even from the same examples.

my mistake. sorry. take a look for my recent 2 screenshots.

@Danp2
Copy link
Owner

Danp2 commented Aug 24, 2022

For this reason _WD_LoadWait is required IMHO.

Ok... that makes sense when you think about it, because you are wanting a complete list of all frames so you have to allow the frames to load in case they contain other frames.

You should dig into this further to better understand the reason for the difference in behavior.
This is ugly "fix"

Wouldn't it make more sense here to detect a timeout and ignore that?

@mlipok
Copy link
Contributor Author

mlipok commented Aug 24, 2022

Wouldn't it make more sense here to detect a timeout and ignore that?

Good point

@mlipok
Copy link
Contributor Author

mlipok commented Aug 24, 2022

Wouldn't it make more sense here to detect a timeout and ignore that?

Please take a look on:
LoadWait is error <> $_WD_ERROR_Timeout
and
_WD_LoadWait $iErr

@mlipok
Copy link
Contributor Author

mlipok commented Aug 24, 2022

As TODO in the future:

_WD_FrameList should return information about visibility of the frame

for example:
https://stackoverflow.com/questions/19669786/check-if-element-is-visible-in-dom

image

@Danp2 if you agree plese reference this as new issue, as I think that, for now we should focus on merging this what we have currently already developed.

@Danp2 Danp2 merged commit 00a6fdd into Danp2:master Aug 24, 2022
@mlipok mlipok deleted the ml_WD_FrameList branch August 24, 2022 21:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

List all frames
2 participants