-
Notifications
You must be signed in to change notification settings - Fork 23
Frame issues #488
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
Comments
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 --
|
Also, all browsers are returning
|
So we have confirmed issue. |
This is an example of what I'm seeing with Chrome --
I'm not sure why this is occurring or when I will get a chance to take a closer look. |
Working on. |
I already checked: https://googlechromelabs.github.io/chrome-for-testing/#stable still the same issue |
It looks like when I use |
it looks that |
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 |
I was testing also other for example au3WebDriver-0.11.0 was first with |
working on |
|
I saw the same earlier today while testing |
Yes. I notice Lines 848 to 863 in 42dda7d
just modify this line: Line 863 in 42dda7d
;~ If $iErr = $_WD_ERROR_Success Then
If 1 Then and entire |
I think It is possible. |
ok so currently get another issue with: Lines 942 to 948 in 42dda7d
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: |
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
until you scroll into view |
is there something wrong with: I mean 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) |
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: |
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. |
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 |
A few thoughts / suggestions --
|
that was immediately one of my assumptions
good point.
will work on all of this |
using: ConsoleWrite("- " & @ScriptLineNumber & @CRLF)
_WD_DebugSwitch($_WD_DEBUG_Full)
Local $sFrame = _WD_FindElement($sSession, $_WD_LOCATOR_ByCSSSelector, '#frame_advanced_select_with_multiple_features')
If @error Then Return SetError(@error, @extended, '')
_WD_ElementActionEx($sSession, $sFrame, 'hover') ; https://github.com/Danp2/au3WebDriver/issues/488#issuecomment-1661174988
If @error Then Return SetError(@error, @extended, '')
ConsoleWrite("- " & @ScriptLineNumber & @CRLF)
; change the attributes of the frame to improve the visibility of the <select> element, on which the options will be indicated
Local $sJavaScript = _
"var element = arguments[0];" & _
"element.setAttribute('height', '500');" & _
"element.setAttribute('padding', '0');"
_WD_ExecuteScript($sSession, $sJavaScript, __WD_JsonElement($sFrame), Default, Default)
If @error Then Return SetError(@error, @extended, '')
ConsoleWrite("- " & @ScriptLineNumber & @CRLF)
; entering to the frame
_WD_DebugSwitch($_WD_DEBUG_Full)
_WD_FrameEnter($sSession, $sFrame)
If @error Then Return SetError(@error, @extended, '') I get:
I suppouse that there is no way to hover over frame. ConsoleWrite("- " & @ScriptLineNumber & @CRLF)
_WD_DebugSwitch($_WD_DEBUG_Full)
Local $sFrame = _WD_FindElement($sSession, $_WD_LOCATOR_ByCSSSelector, '#frame_advanced_select_with_multiple_features')
If @error Then Return SetError(@error, @extended, '')
ConsoleWrite("- " & @ScriptLineNumber & @CRLF)
; change the attributes of the frame to improve the visibility of the <select> element, on which the options will be indicated
Local $sJavaScript = _
"var element = arguments[0];" & _
"element.setAttribute('height', '500');" & _
"element.setAttribute('padding', '0');"
_WD_ExecuteScript($sSession, $sJavaScript, __WD_JsonElement($sFrame), Default, Default)
If @error Then Return SetError(@error, @extended, '')
ConsoleWrite("- " & @ScriptLineNumber & @CRLF)
; entering to the frame
_WD_DebugSwitch($_WD_DEBUG_Full)
_WD_FrameEnter($sSession, $sFrame)
If @error Then Return SetError(@error, @extended, '')
Local $sHead = _WD_FindElement($sSession, $_WD_LOCATOR_ByCSSSelector, 'html head')
_WD_ElementActionEx($sSession, $sHead, 'hover') ; https://github.com/Danp2/au3WebDriver/issues/488#issuecomment-1661174988
_WD_LoadWait($sSession, 300) And it works |
hm... not always:
|
The trick is to use: Local $sHead = _WD_FindElement($sSession, $_WD_LOCATOR_ByCSSSelector, 'html body') instead: Local $sHead = _WD_FindElement($sSession, $_WD_LOCATOR_ByCSSSelector, 'html head') |
Here is first proposal for fix: Func _WD_FrameEnter($sSession, $vIdentifier, $bHoverBody = True, $bLoadWait = True)
Local Const $sFuncName = "_WD_FrameEnter"
If String($vIdentifier) = 'null' Then $vIdentifier = Null ; String must be used because checking 0 = 'null' is True
Local Const $bIsIdentifierNull = (IsKeyword($vIdentifier) = $KEYWORD_NULL)
Local Const $sParameters = 'Parameters: Identifier=' & ($bIsIdentifierNull ? ("Null") : ($vIdentifier) & ' HoverBody=' & $bHoverBody & ' LoadWait=' & $bLoadWait)
Local $sValue, $sMessage = '', $sOption, $sResponse, $oJSON
Local $iErr = $_WD_ERROR_Success
; must start with null or digit, must have at least one slash (may have many slashes but should not be followed one per other), must end with digit
Local Const $bIdentifierAsPath = StringRegExp($vIdentifier, "(?i)\A(?:Null|\d+)(?:\/\d+)+\Z", $STR_REGEXPMATCH)
If $bIdentifierAsPath Then
; will be processed below
ElseIf $bIsIdentifierNull Then
$sOption = '{"id":null}'
ElseIf IsInt($vIdentifier) Then
$sOption = '{"id":' & $vIdentifier & '}'
Else
$sOption = '{"id":' & __WD_JsonElement($vIdentifier) & '}'
EndIf
If Not $bIdentifierAsPath Then
$sResponse = _WD_Window($sSession, "frame", $sOption)
$iErr = @error
Else
Local $aIdentifiers = StringSplit($vIdentifier, '/')
For $i = 1 To $aIdentifiers[0]
If String($aIdentifiers[$i]) = 'null' Then
$aIdentifiers[$i] = '{"id":null}'
Else
$aIdentifiers[$i] = '{"id":' & $aIdentifiers[$i] & '}'
EndIf
$sResponse = _WD_Window($sSession, "frame", $aIdentifiers[$i])
If Not @error Then ContinueLoop
$iErr = @error
$sMessage = ' Error on ID#' & $i & ' > ' & $aIdentifiers[$i]
ExitLoop
Next
EndIf
If $iErr = $_WD_ERROR_Success Then
$oJSON = Json_Decode($sResponse)
$sValue = Json_Get($oJSON, $_WD_JSON_Value)
;*** Evaluate the response
If $sValue <> Null Then
$sValue = Json_Get($oJSON, $_WD_JSON_Error)
Else
$sValue = True
EndIf
ElseIf Not $_WD_DetailedErrors Then
$iErr = $_WD_ERROR_Exception
EndIf
If $iErr = $_WD_ERROR_Success And $bHoverBody Then
If $bLoadWait Then _WD_LoadWait($sSession, 50)
Local $sHead = _WD_FindElement($sSession, $_WD_LOCATOR_ByCSSSelector, 'html body')
_WD_ElementActionEx($sSession, $sHead, 'hover') ; https://github.com/Danp2/au3WebDriver/issues/488#issuecomment-1661174988
If $bLoadWait Then _WD_LoadWait($sSession, 50)
EndIf
Return SetError(__WD_Error($sFuncName, $iErr, $sParameters & $sMessage), 0, $sValue)
EndFunc ;==>_WD_FrameEnter if you think that this is good direction, please open new PR for |
I have one interesting notice/obervation: |
As we've found out recently with the changes to
|
I understand your point - I think it's right. So let's keep the current way of working by default, but let's add the possibility of extended operation. I mean that ultimately I want to add this action to Summary: So I suggest doing this change to my prev proposal, like this: Func _WD_FrameEnter($sSession, $vIdentifier, $bHoverBody = False, $bLoadWait = False)
.... Instead of the earlier concept: Func _WD_FrameEnter($sSession, $vIdentifier, $bHoverBody = True, $bLoadWait = True)
.... |
A few things that warrant further consideration / discussion --
|
Do not know, still in testing.
Must to think about.
We can only try to check it on several pages. |
modified version: ; #FUNCTION# ====================================================================================================================
; Name ..........: _WD_FrameEnter
; Description ...: Enter the specified frame.
; Syntax ........: _WD_FrameEnter($sSession, $vIdentifier[, $bForceLoad = False])
; Parameters ....: $sSession - Session ID from _WD_CreateSession
; $vIdentifier - Target frame identifier. Can be any of the following:
; |Null - Return to top-most browsing context
; |String - Element ID from _WD_FindElement or path like 'null/2/0'
; |Integer - 0-based index of frames
; $bForceLoad - [optional] Determine if Frame should be focused on and checked if is Fully loaded. Default is False.
; Return values .: Success - True.
; Failure - WD Response error message (E.g. "no such frame") and sets @error to one of the following values:
; - $_WD_ERROR_Exception
; Author ........: Decibel
; Modified ......: Danp2, mLipok, jchd
; Remarks .......: You can drill-down into nested frames by calling this function repeatedly or use identifier like 'null/2/0'
; Related .......: _WD_Window, _WD_LastHTTPResult
; Link ..........:
; Example .......: No
; ===============================================================================================================================
Func _WD_FrameEnter($sSession, $vIdentifier, $bForceLoad = False)
Local Const $sFuncName = "_WD_FrameEnter"
If String($vIdentifier) = 'null' Then $vIdentifier = Null ; String must be used because checking 0 = 'null' is True
Local Const $bIsIdentifierNull = (IsKeyword($vIdentifier) = $KEYWORD_NULL)
Local Const $sParameters = 'Parameters: Identifier=' & ($bIsIdentifierNull ? ("Null") : ($vIdentifier) & ' ForceLoad=' & $bForceLoad)
Local $sValue, $sMessage = '', $sOption, $sResponse, $oJSON
Local $iErr = $_WD_ERROR_Success
; must start with null or digit, must have at least one slash (may have many slashes but should not be followed one per other), must end with digit
Local Const $bIdentifierAsPath = StringRegExp($vIdentifier, "(?i)\A(?:Null|\d+)(?:\/\d+)+\Z", $STR_REGEXPMATCH)
If $bIdentifierAsPath Then
; will be processed below
ElseIf $bIsIdentifierNull Then
$sOption = '{"id":null}'
ElseIf IsInt($vIdentifier) Then
$sOption = '{"id":' & $vIdentifier & '}'
Else
$sOption = '{"id":' & __WD_JsonElement($vIdentifier) & '}'
EndIf
If Not $bIdentifierAsPath Then
$sResponse = _WD_Window($sSession, "frame", $sOption)
$iErr = @error
Else
Local $aIdentifiers = StringSplit($vIdentifier, '/')
For $i = 1 To $aIdentifiers[0]
If String($aIdentifiers[$i]) = 'null' Then
$aIdentifiers[$i] = '{"id":null}'
Else
$aIdentifiers[$i] = '{"id":' & $aIdentifiers[$i] & '}'
EndIf
$sResponse = _WD_Window($sSession, "frame", $aIdentifiers[$i])
If Not @error Then ContinueLoop
$iErr = @error
$sMessage = ' Error on ID#' & $i & ' > ' & $aIdentifiers[$i]
ExitLoop
Next
EndIf
If $iErr = $_WD_ERROR_Success Then
$oJSON = Json_Decode($sResponse)
$sValue = Json_Get($oJSON, $_WD_JSON_Value)
;*** Evaluate the response
If $sValue <> Null Then
$sValue = Json_Get($oJSON, $_WD_JSON_Error)
Else
$sValue = True
EndIf
ElseIf Not $_WD_DetailedErrors Then
$iErr = $_WD_ERROR_Exception
EndIf
If $iErr = $_WD_ERROR_Success And $bForceLoad Then
_WD_LoadWait($sSession, 50)
Local $sHead = _WD_FindElement($sSession, $_WD_LOCATOR_ByCSSSelector, 'html body')
_WD_ElementActionEx($sSession, $sHead, 'hover') ; https://github.com/Danp2/au3WebDriver/issues/488#issuecomment-1661174988
_WD_LoadWait($sSession, 50)
EndIf
Return SetError(__WD_Error($sFuncName, $iErr, $sParameters & $sMessage), 0, $sValue)
EndFunc ;==>_WD_FrameEnter |
maybe we can put this change to the upcomming new release ? |
Please submit a PR so that this can be properly reviewed / tested. |
Will open separate issue for handling frames.
Originally posted by @mlipok in #487 (comment)
The text was updated successfully, but these errors were encountered: