-
Notifications
You must be signed in to change notification settings - Fork 23
_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
_WD_FrameList #362
Conversation
big thanks to @TheDcoder for his answer here: It helps me to solve the problem with checking current frame level, which was the main problem with providing relative Identifiers for |
@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. |
Please review this PR and close related ISSUE #354 |
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? |
Yes of course. I just fixed this part, as you pointed me:
Take a look here: Lines 697 to 703 in 74f6fb0
|
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: |
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
Comments
|
fixed in my WIP version
exaclty
will check when I end refactoring |
fixed on further changes
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:
|
Now I have a question. |
I hope to allow the user to check on which FRAME the given element exists. |
so we should change _WD_FrameEnter($sSession, 'null/2/0') to: _WD_FrameEnter($sSession, 'null/0') |
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: |
after this: _WD_LoadWait error not handled I have such Ex3 result |
This comment was marked as off-topic.
This comment was marked as off-topic.
as so far this #384 is only error handling improvements so I still wait on your decision about |
|
Thanks
Because |
I mention about this problem here: #385 (comment) |
For this reason currently But for this stage please leave it as it is. |
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? |
You should dig into this further to better understand the reason for the difference in behavior.
This is ugly "fix" |
@mlipok Those screenshots aren't even from the same examples. |
my mistake. sorry. take a look for my recent 2 screenshots. |
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.
Wouldn't it make more sense here to detect a timeout and ignore that? |
Good point |
Please take a look on: |
As TODO in the future: _WD_FrameList should return information about visibility of the frame for example: @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. |
Pull request
Proposed changes
was discussed here:
#354
Checklist
Types of changes
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:
System under test
not related