Jump to content

WebDriver UDF (W3C compliant version) - 2024/09/21


Danp2
 Share

Recommended Posts

Hi,

i created a profile to use all the time the same.

But Gecko won´t really connect...

$sDesiredCapabilities = '{"capabilities":{"alwaysMatch": {"moz:firefoxOptions": {"args": ["-profile", "C:/Users/AppData/Roaming/Mozilla/Firefox/Profiles/gbjaumrnd.default"],"prefs": {"dom.ipc.processCount": 8},"log": {"level": "trace"}}}}}'
    _WD_Option('Driver', 'geckodriver.exe')
    _WD_Option('DriverParams', '--log trace')
    _WD_Option('Port', 4444)

1522261038778   geckodriver::marionette TRACE     connection attempt 0/600
1522261040934   geckodriver::marionette TRACE     connection attempt 1/600
1522261043059   geckodriver::marionette TRACE     connection attempt 2/600
1522261045215   geckodriver::marionette TRACE     connection attempt 3/600

...

 

Do you had this problem already?

 

BR

 

horphi

Link to comment
Share on other sites

@horphi Some additional details would help --

  • Does Firefox launch when you call _WD_CreateSession?
  • Show us the contents of the Scite output window

You can also test to see if Marionette is running in Firefox by issuing the command "telnet localhost 2828" from a command prompt. Details on this technique can be found here.

Could also be related to this issue --

https://github.com/mozilla/geckodriver/issues/1058

Link to comment
Share on other sites

HI,

sry for that.

Yes Firefoy starts up and also with the added profile.

1522270030978   geckodriver     INFO    geckodriver 0.19.1
1522270030978   webdriver::httpapi      DEBUG   Creating routes
1522270030978   geckodriver     INFO    Listening on 127.0.0.1:4444
1522270031431   webdriver::server       DEBUG   -> POST /session {"capabilities":{"alwaysMatch": {"moz:firefoxOptions": {"args": ["-profile", "C:/Users/AppData/Roaming/Mozilla/Firefox/Profiles/gbjaumrnd.default"],"prefs": {"dom.ipc.processCount": 8},"log": {"level": "trace"}}}}}
1522270031509   mozrunner::runner       INFO    Running command: "C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe" "-marionette" "-profile" "C:/Users/AppData/Roaming/Mozilla/Firefox/Profiles/gbjaumrnd.default"
1522270033541   geckodriver::marionette TRACE     connection attempt 0/600
1522270035697   geckodriver::marionette TRACE     connection attempt 1/600
_WDStartup: OS: WIN_10 WIN32_NT 16299 
_WDStartup: AutoIt: 3.3.14.2
_WDStartup: WD.au3: 0.1.0.9
_WDStartup: Driver: geckodriver.exe
_WDStartup: Params: --log trace
_WDStartup: Port:   4444
__WD_Post: URL=HTTP://127.0.0.1:4444/session; $sData={"capabilities":{"alwaysMatch": {"moz:firefoxOptions": {"args": ["-profile", "C:/Users/AppData/Roaming/Mozilla/Firefox/Profiles/gbjaumrnd.default"],"prefs": {"dom.ipc.processCount": 8},"log": {"level": "trace"}}}}}
__WD_Post: StatusCode=0; ResponseText=0
__WD_Post ==> Send / Recv error
_WD_CreateSession: 0
_WD_CreateSession ==> Webdriver Exception: HTTP status = 0
__WD_Post: URL=HTTP://127.0.0.1:4444/session//url; $sData={"url":"https://google.com/"}
__WD_Post: StatusCode=404; ResponseText={"value":{"error":"unknown command","message":"POST /session//url did not match a known command","stacktrace":"stack backtrace:\n   0:           0x47e934 - <no info>\n   1:           0x47f0a3 - <no info>\n   2:           0x442649 - <no info>\n   3:           0x43c3f0 - <no info>\n   4:           0x40530f - <no info>\n   5:           0x40d01a - <no info>\n   6:           0x6bef19 - <no info>\n   7:           0x420b85 - <no info>\n   8:           0x6b96e0 - <no info>\n   9:     0x7fff3adc1fe4 - BaseThreadInitThunk"}}
_WD_Navigate: {"value":{"error":"unknown command","message":"POST /session//url did not match a known command","stacktrace":"stack backtrace:\n   0:           0x47e934 - <no info>\n   1:           0x47f0a3 - <no info>\n   2:           0x442649 - <no info>\n   3:           0x43c3f0 - <no info>\n   4:           0x40530f - <no info>\n   5:           0x40d01a - <no info>\n   6:           0x6bef19 - <no info>\n   7:           0x420b85 - <no info>\n   8:           0x6b96e0 - <no info>\n   9:     0x7fff3adc1fe4 - BaseThreadInitThunk"}}

BR

Link to comment
Share on other sites

  • 2 weeks later...

@vkris81 This thread is for development discussions related to the Webdriver UDF. There's a separate thread for the FF UDF. Please post your inquiry there if you need assistance with that UDF.

P.S. There's also a separate thread in the GH&S section for the Webdriver UDF.

P.P.S. MozRepl is a dead technology. So you may want to focus on learning IUIAutomation and/or Webdriver technology.

Link to comment
Share on other sites

  • 2 weeks later...

@Danp2

This seems like a great tool thanks for making it available. I'm pretty new to using AutoIt, but wanted to see if you could help answer a few questions as I progress through this project. First one is when using with the chrome driver I notice a message under the address bar of the browser "Chrome is being controlled by automated test software" notification at the top". I saw a post about this on google for other programming/scripting languages to disable this I need to pass the "disable-infobars" ChromeOption to the WebDriver. Could you help me with the syntax to make this work for wd_test.au3

I believe this is where it would be added:

Func SetupChrome()
_WD_Option('Driver', 'chromedriver.exe')
_WD_Option('Port', 9515)
_WD_Option('DriverParams', '--log-path=' & @ScriptDir & '\chrome.log')

$sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"chromeOptions": {"w3c": true}}}}'
EndFunc

 

Link to comment
Share on other sites

On 3/28/2018 at 10:55 PM, Danp2 said:

Please read my earlier response and try the telnet test to see if Marionette is running within Firefox. Also review the Github issue I linked for relevance.

Hi,

 

thank you. I got it. :-) I did not understand to pass the port to the webdriver.... " --marionette-port 2828 " needs to be adapted to the Webdriver and not to the Firefox Capabilites...

_WD_Option('Driver', 'D:\geckodriver-v0.20.1-win64\geckodriver.exe  "--marionette-port 2828"')

BR

Edited by horphi
Link to comment
Share on other sites

Hello again,

how i can select some Text within a iframe?

$sElementBtnPost = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//iframe[@allowfullscreen='true']//body[@value='text']")

Somebody means, you need to switch first inside the iframe...

Stackoverflow

Did somebody tried it already?

Best regards

Link to comment
Share on other sites

Func SetupChrome()
    _WDOption('Driver', 'chromedriver.exe')
    _WDOption('Port', 9515)
    ;_WDOption('DriverParams', '--log-path=' & @ScriptDir & '\chrome.log') ;<==Original line
    _WD_Option('DriverParams', '--log-path="' & @ScriptDir & '\chrome.log"') ;<==I changed it to this

    $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"chromeOptions": {"w3c": true }}}}'
EndFunc

(I screwed up the original post and now I can't figure out how to quote from your example during an edit.)

Edited by Decibel
Link to comment
Share on other sites

I gave the frames problem a shot below.

Add these to _wd_helper.au3

#Region - WD Frame Functions
; #FUNCTION# ====================================================================================================================
; Name ..........: _WD_GetFrameCount
; Description ...: This will return how many frames/iframes are in your current window/frame. It will not traverse to nested frames.
; Syntax ........: _WD_GetFrameCount()
; Parameters ....:
; Return values .: Success      - Numeric count of frames, 0 or positive number
;                  Failure      - ""
; Author ........: Decibel
; Modified ......: 2018-04-27
; Remarks .......:
; Related .......:
; Link ..........: https://www.w3schools.com/jsref/prop_win_length.asp
; Example .......: No
; ===============================================================================================================================
Func _WD_GetFrameCount($sSession)
    Local $sResponse, $sJSON, $iValue

    $sResponse = _WD_ExecuteScript($sSession, "return window.frames.length")
    $sJSON = Json_Decode($sResponse)
    $iValue = Json_Get($sJSON, "[value]")

    Return Number($iValue)
EndFunc ;==>_WD_GetFrameCount

; #FUNCTION# ====================================================================================================================
; Name ..........: _WD_IsWindowTop
; Description ...: This will return a boolean of the session being at the top level, or in a frame(s).
; Syntax ........: _WD_IsWindowTop()
; Parameters ....:
; Return values .: Success      - Boolean response
;                  Failure      - ""
; Author ........: Decibel
; Modified ......: 2018-04-27
; Remarks .......:
; Related .......:
; Link ..........: https://www.w3schools.com/jsref/prop_win_top.asp
; Example .......: No
; ===============================================================================================================================
Func _WD_IsWindowTop($sSession)
    Local $sResponse, $sJSON
    Local $blnResult

    $sResponse = _WD_ExecuteScript($sSession, "return window.top == window.self")
    $sJSON = Json_Decode($sResponse)
    $blnResult = Json_Get($sJSON, "[value]")

    Return $blnResult
EndFunc ;==>_WD_IsWindowTop

; #FUNCTION# ====================================================================================================================
; Name ..........: _WD_FrameEnter
; Description ...: This will enter the specified frame for subsequent WebDriver operations.
; Syntax ........: _WD_FrameEnter($sIndexOrID)
; Parameters ....:
; Return values .: Success      - True
;                  Failure      - WD Response error message (E.g. "no such frame")
; Author ........: Decibel
; Modified ......: 2018-04-27
; Remarks .......:
; Related .......:
; Link ..........: OMG you have no idea how many I read.
; Example .......: No
; ===============================================================================================================================
Func _WD_FrameEnter($sSession, $sIndexOrID)
    #cs - $sOption value trials
        ;*** These $sOption values didn't work
        ;_WD_Window($sSession, "frame",'{"name":"name1"}')
        ;_WD_Window($sSession, "frame",'{"name":name1}')
        ;_WD_Window($sSession, "frame",'{"id":{"name": "name1"}}')
        ;_WD_Window($sSession, "frame",'{"id":{"ELEMENT": "name1"}}')
        ;_WD_Window($sSession, "frame",'{"id":' & $sElement & '}') ;where $sElement is the result of _WD_FindElement

        ;*** This works but the frames are indexed 0-based in this notation.
        ;    The "id" value can be the index, or the string value from an "id" attribute.
        ;_WD_Window($sSession, "frame",'{"id":0}')
        ;_WD_Window($sSession, "frame",'{"id":"nest1"}')

        ;Firefox will only work with a frame index number, not with an ID attribute value.
    #ce - $sOption value trials
    Local $sOption
    Local $sResponse, $sJSON
    Local $sValue

    ;*** Encapsulate the value if it's an integer, assuming that it's supposed to be an Index, not ID attrib value.
    If IsInt($sIndexOrID) = True Then
        $sOption = '{"id":' & $sIndexOrID & '}'
    Else
        $sOption = '{"id":"' & $sIndexOrID & '"}'
    EndIf

    $sResponse = _WD_Window($sSession, "frame", $sOption)
    ;Good: '{"value":null}'
    ;Bad: '{"value":{"error":"no such frame"....
    $sJSON = Json_Decode($sResponse)
    $sValue = Json_Get($sJSON, "[value]")

    ;*** Evaluate the response
    If $sValue <> Null Then
        $sValue = Json_Get($sJSON, "[value][error]")
    Else
        $sValue = True
    EndIf

    Return $sValue
EndFunc ;==>_WD_FrameEnter

; #FUNCTION# ====================================================================================================================
; Name ..........: _WD_FrameLeave
; Description ...: This will leave the current frame, to its parent, not necessarily the Top, for subsequent WebDriver operations.
; Syntax ........: _WD_FrameLeave()
; Parameters ....:
; Return values .: Success      True
;                  Failure      - WD Response error message (E.g. "chrome not reachable")
; Author ........: Decibel
; Modified ......: 2018-04-27
; Remarks .......: ChromeDriver and GeckoDriver respond differently for a successful operation
; Related .......:
; Link ..........: https://www.w3.org/TR/webdriver/#switch-to-parent-frame
; Example .......: No
; ===============================================================================================================================
Func _WD_FrameLeave($sSession)
    Local $sOption
    Local $sResponse, $sJSON, $asJSON
    Local $sValue

    ;*** For Firefox, you HAVE to have the $sOption present, but the value can be anything.
    ;    Chrome ignores it just fine.
    ;From Firefox: {"value":{"error":"invalid argument","message":"Failed to decode request as JSON: \"\"","stacktrace":"Syntax error at :1:1"}}
    $sOption = '{"id":"anything"}'

    $sResponse = _WD_Window($sSession, "parent", $sOption)
    ;Chrome--
    ;   Good: '{"value":null}'
    ;   Bad: '{"value":{"error":"chrome not reachable"....
    ;Firefox--
    ;   Good: '{"value": {}}'
    ;   Bad: '{"value":{"error":"unknown error","message":"Failed to decode response from marionette","stacktrace":""}}'

    $sJSON = Json_Decode($sResponse)
    $sValue = Json_Get($sJSON, "[value]")

    ;*** Is this something besides a Chrome PASS?
    If $sValue <> Null Then
        ;*** Check for a nested JSON object
        If Json_IsObject($sValue) = True Then
            $asJSON = Json_ObjGetKeys($sValue)

            ;*** Is this an empty nested object
            If UBound($asJSON) = 0 Then ;Firefox PASS
                $sValue = True
            Else ;Chrome and Firefox FAIL
                $sValue = $asJSON[0] & ":" & Json_Get($sJSON, "[value][" & $asJSON[0] & "]")
            EndIf
        EndIf
    Else ;Chrome PASS
        $sValue = True
    EndIf

    Return $sValue
EndFunc ;==>_WD_FrameLeave

 

Code to use the frame helper functions

#include "wd_core.au3"
#include "wd_helper.au3"

Opt("MustDeclareVars", 1);require variables to be declared

Local Enum $eFireFox = 0, _
            $eChrome

Local Const $_TestType = $eChrome
;~ Local Const $_TestType = $eFireFox

Local $sDesiredCapabilities
Local $iIndex
Local $sSession
Local $sElement

$_WD_DEBUG = False

Switch $_TestType
    Case $eFireFox
        SetupGecko()

    Case $eChrome
        SetupChrome()
EndSwitch

_WD_Startup()
$sSession = _WD_CreateSession($sDesiredCapabilities)

;*** Load a local file in the relative path
_WD_Navigate($sSession, StringReplace("file:///" & @ScriptDir & "/HTML_Examples/nested_frames.html", "\","/"))

#Region - Frames Examples

ConsoleWrite(@ScriptLineNumber & @TAB &  "WINDOW.FRAMES" & @TAB & "has '" & _WD_GetFrameCount($sSession) & "' iframes in the top window" & @CRLF)

;*** Syntax to recurse nested frames
ConsoleWrite(@ScriptLineNumber & @TAB &  "WINDOW.FRAMES[1]" &       @TAB & "has '" & _WD_ExecuteScript($sSession, "return window.frames[1].frames.length") & "' iframes" & @CRLF)
ConsoleWrite(@ScriptLineNumber & @TAB &  "WINDOW.FRAMES[1][0]" &    @TAB & "has '" & _WD_ExecuteScript($sSession, "return window.frames[1].frames[0].frames.length") & "' iframes" & @CRLF)
ConsoleWrite(@ScriptLineNumber & @TAB &  "WINDOW.FRAMES[1][1]" &    @TAB & "has '" & _WD_ExecuteScript($sSession, "return window.frames[1].frames[1].frames.length") & "' iframes" & @CRLF)
ConsoleWrite(@ScriptLineNumber & @TAB &  "WINDOW.FRAMES[1][2]" &    @TAB & "has '" & _WD_ExecuteScript($sSession, "return window.frames[1].frames[2].frames.length") & "' iframes" & @CRLF)
ConsoleWrite(@ScriptLineNumber & @TAB &  "WINDOW.FRAMES[1][2][0]" & @TAB & "has '" & _WD_ExecuteScript($sSession, "return window.frames[1].frames[2].frames[0].frames.length") & "' iframes" & @CRLF)
ConsoleWrite(@ScriptLineNumber & @TAB &  "WINDOW.FRAMES[1][2][1]" & @TAB & "has '" & _WD_ExecuteScript($sSession, "return window.frames[1].frames[2].frames[1].frames.length") & "' iframes" & @CRLF)
ConsoleWrite(@ScriptLineNumber & @TAB &  "WINDOW.FRAMES[1][2][2]" & @TAB & "has '" & _WD_ExecuteScript($sSession, "return window.frames[1].frames[2].frames[2].frames.length") & "' iframes" & @CRLF)
ConsoleWrite(@ScriptLineNumber & @TAB &  "WINDOW.FRAMES[1][2][3]" & @TAB & "has '" & _WD_ExecuteScript($sSession, "return window.frames[1].frames[2].frames[3].frames.length") & "' iframes" & @CRLF)

ConsoleWrite(@ScriptLineNumber & @TAB &  "WINDOW.FRAMES[2]" &       @TAB & "No iframes at this intentionally bad index = '" & _WD_ExecuteScript($sSession, "return window.frames[2].frames.length") & "'" & @CRLF)
;;{"value":{"error":"unknown error","message":"Cannot read property 'frames' of undefined(Session infochrome=66.0.3359.117)","stacktrace":"Backtrace:\n\t(No symbol) [0x0140E8F0]\n\t(No symbol) [0x013F7CCD]\n\t(No symbol) [0x013C6D73]\n\t(No symbol) [0x013C87EC]\n\t(No symbol) [0x013C86D6]\n\t(No symbol) [0x013AEC00]\n\t(No symbol) [0x013A6C8D]\n\t(No symbol) [0x013AE35B]\n\t(No symbol) [0x013A6CEB]\n\t(No symbol) [0x01390D9E]\n\t(No symbol) [0x01392314]\n\t(No symbol) [0x013922BA]\n\t(No symbol) [0x014338D6]\n\t(No symbol) [0x01412AB3]\n\t(No symbol) [0x013E08C6]\n\t(No symbol) [0x013E0BF3]\n\t(No symbol) [0x013E0D03]\n\t(No symbol) [0x01414B47]\n\t(No symbol) [0x013E060F]\n\t(No symbol) [0x013E177E]\n\t(No symbol) [0x013DD59B]\n\t(No symbol) [0x013DD6F5]\n\t(No symbol) [0x013F000B]\n\tBaseThreadInitThunk [0x7650336A+18]\n\tRtlInitializeExceptionChain [0x77379902+99]\n\tRtlInitializeExceptionChain [0x773798D5+54]\n"}}

;*** Go into frames

;*** Just some blank lines for console output readability
ConsoleWrite(@ScriptLineNumber & @TAB &  @CRLF)
ConsoleWrite(@ScriptLineNumber & @TAB &  @CRLF)

;*** Show that we're at the top level
$sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//h3")
ConsoleWrite(@ScriptLineNumber & @TAB &  "Top level text = '" & _WD_ElementAction($sSession, $sElement, 'text') & "'" & @CRLF)
ConsoleWrite(@ScriptLineNumber & @TAB &  "   Am I at the Top level? = '" & _WD_IsWindowTop($sSession) & "'" & @CRLF & @CRLF)

;*** Go into the first frame by index ({"id": 0}).
;~ ConsoleWrite(@ScriptLineNumber & @TAB &  "Go into frame 1 = '" &  _WD_Window($sSession, "frame",'{ "id": 0}') & "'" & @CRLF) ;aka id="nest1"
ConsoleWrite(@ScriptLineNumber & @TAB &  "Go into frame 1 = '" & _WD_FrameEnter($sSession, 0) & "'" & @CRLF) ;aka id="nest1"
$sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//h3")
ConsoleWrite(@ScriptLineNumber & @TAB &  "Nest1 text = '" & _WD_ElementAction($sSession, $sElement, 'text') & "'" & @CRLF)
ConsoleWrite(@ScriptLineNumber & @TAB &  "   Am I at the Top level? = '" & _WD_IsWindowTop($sSession) & "'" & @CRLF & @CRLF)

;*** You can't just jump from Frame 1 to Frame 2 without traversing back up to Parent first, then down Frame 2.
;~ ConsoleWrite(@ScriptLineNumber & @TAB &  "Failing to go into frame 2 = '" & _WD_FrameEnter($sSession, 1) & "'" & @CRLF)
ConsoleWrite(@ScriptLineNumber & @TAB &  "Failing to go into frame 2 = '" & _WD_FrameEnter($sSession, "nest2") & "'" & @CRLF)
$sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//h3")
;*** This will return a result just fine, but it's coming from the wrong frame (level 1 instead of level 2).
ConsoleWrite(@ScriptLineNumber & @TAB &  "Nest2 text = '" & _WD_ElementAction($sSession, $sElement, 'text') & "'" & @CRLF)
ConsoleWrite(@ScriptLineNumber & @TAB &  "   Am I at the Top level? = '" & _WD_IsWindowTop($sSession) & "'" & @CRLF & @CRLF)

;*** Go up one frame level
ConsoleWrite(@ScriptLineNumber & @TAB &  "Go up 1 parent frame = '" & _WD_FrameLeave($sSession) & "'" & @CRLF)
ConsoleWrite(@ScriptLineNumber & @TAB &  "Go up 1 parent frame too many times = '" & _WD_FrameLeave($sSession) & "'" & @CRLF)
$sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//h3")
ConsoleWrite(@ScriptLineNumber & @TAB &  "Top level text = '" & _WD_ElementAction($sSession, $sElement, 'text') & "'" & @CRLF)
ConsoleWrite(@ScriptLineNumber & @TAB &  "   Am I at the Top level? = '" & _WD_IsWindowTop($sSession) & "'" & @CRLF & @CRLF)

;*** Now you can jump into Frame 2
;~ ConsoleWrite(@ScriptLineNumber & @TAB &  "Go into frame 2 = '" & _WD_FrameEnter($sSession, 1) & "'" & @CRLF)
ConsoleWrite(@ScriptLineNumber & @TAB &  "Go into frame 2 = '" & _WD_FrameEnter($sSession, "nest2") & "'" & @CRLF)
$sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//h3")
ConsoleWrite(@ScriptLineNumber & @TAB &  "Nest2 text = '" & _WD_ElementAction($sSession, $sElement, 'text') & "'" & @CRLF)
ConsoleWrite(@ScriptLineNumber & @TAB &  "   Am I at the Top level? = '" & _WD_IsWindowTop($sSession) & "'" & @CRLF & @CRLF)

;*** Now you can jump into a nested frame inside Frame 2
;~ ConsoleWrite(@ScriptLineNumber & @TAB &  "Go into frame 2.3 = '" & _WD_FrameEnter($sSession, 2) & "'" & @CRLF)
ConsoleWrite(@ScriptLineNumber & @TAB &  "Go into frame 2.3 = '" & _WD_FrameEnter($sSession, "nest2.3") & "'" & @CRLF)
$sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//h3")
ConsoleWrite(@ScriptLineNumber & @TAB &  "Nest2.3 text = '" & _WD_ElementAction($sSession, $sElement, 'text') & "'" & @CRLF)
ConsoleWrite(@ScriptLineNumber & @TAB &  "   Am I at the Top level? = '" & _WD_IsWindowTop($sSession) & "'" & @CRLF & @CRLF)

;*** Now you can jump into a nested-nested frame inside Frame 2 (I.e. nested inside Frame 2.3)
;~ ConsoleWrite(@ScriptLineNumber & @TAB &  "Go into frame 2.3.4 = '" & _WD_FrameEnter($sSession, 3) & "'" & @CRLF)
ConsoleWrite(@ScriptLineNumber & @TAB &  "Go into frame 2.3.4 = '" & _WD_FrameEnter($sSession, "nest2.3.4") & "'" & @CRLF)
$sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//h3")
ConsoleWrite(@ScriptLineNumber & @TAB &  "Nest2.3.4 text = '" & _WD_ElementAction($sSession, $sElement, 'text') & "'" & @CRLF)
ConsoleWrite(@ScriptLineNumber & @TAB &  "   Am I at the Top level? = '" & _WD_IsWindowTop($sSession) & "'" & @CRLF & @CRLF)

ConsoleWrite(@ScriptLineNumber & @TAB &  "*** Loop to drill to the Top ***" & @CRLF)
ConsoleWrite(@ScriptLineNumber & @TAB &  "Am I at the Top level? = '" & _WD_IsWindowTop($sSession) & "'" & @CRLF)
While _WD_IsWindowTop($sSession) = False
    ConsoleWrite(@ScriptLineNumber & @TAB &  "Go up 1 parent frame = '" & _WD_FrameLeave($sSession) & "'" & @CRLF)
    $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//h3")
    ConsoleWrite(@ScriptLineNumber & @TAB &  "H3 text = '" & _WD_ElementAction($sSession, $sElement, 'text') & "'" & @CRLF)
    ConsoleWrite(@ScriptLineNumber & @TAB &  "   Am I at the Top level? = '" & _WD_IsWindowTop($sSession) & "'" & @CRLF)
WEnd


ConsoleWrite(@ScriptLineNumber & @TAB &  "Finished" & @CRLF)

#EndRegion - Frames Examples

_WD_DeleteSession($sSession)
_WD_Shutdown()

 

Supporting HTML test files are zipped and attached.

HTML_Examples.zip

Edited by Decibel
Included references to $sSession in the frame helper functions.
Link to comment
Share on other sites

  • 3 weeks later...
On 4/23/2018 at 9:19 PM, Danp2 said:

The webdriver spec supports the Switch To Frame command. This has been implemented in the _WD_Window of this UDF. I have not tested this functionality,  so you may have to play with the value of the $sOption parameter until you find the correct syntax.

Mhhh...i tried a lot combinations and @ the end he accept {"id":"element"} but still an error occurs....

 

"Frame ID has unexpected type"....i realy dont know what to do...

__WD_Post: URL=HTTP://127.0.0.1:4444/session/011663b8-b583-405b-8edc-bd8be0cb881f/element; $sData={"using":"xpath","value":"//iframe[@allowfullscreen='true']"}
__WD_Post: StatusCode=200; ResponseText={"value":{"element-6066-11e4-a52e-4f735466cecf":"7e089b80-0cdd-489b-ba1f-0213dac32f09"}}
_WD_FindElement: {"value":{"element-6066-11e4-a52e-4f735466cecf":"7e089b80-0cdd-489b-ba1f-0213dac32f09"}}
__WD_Post: URL=HTTP://127.0.0.1:4444/session/011663b8-b583-405b-8edc-bd8be0cb881f/frame; $sData={"id":"7e089b80-0cdd-489b-ba1f-0213dac32f09"}
__WD_Post: StatusCode=404; ResponseText={"value":{"error":"no such frame","message":"frame id has unexpected type","stacktrace":""}}

best regards

Link to comment
Share on other sites

51 minutes ago, Danp2 said:

I need to look into this further, but I don't believe this option is working currently --

;_WD_Window($sSession, "frame",'{"id":' & $sElement & '}') ;where $sElement is the result of _WD_FindElement

Right. I put the failed attempts in as comments to be comprehensive for others to see what I tried.

Link to comment
Share on other sites

  • Danp2 changed the title to WebDriver UDF (W3C compliant version) - 2024/09/21
  • Melba23 pinned this topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...