Danp2 / au3WebDriver

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

wd_demo.au3 : $_VAR support in UserFile() #462

Closed mlipok closed 1 year ago

mlipok commented 1 year ago

Pull request

Proposed changes

user using UserTesting() with UserTesting.au3 should have ability to set values for variables, this is limited as Execute() have their specific usage, and given this particular need, one could even say that it is a limitation, which can be tested with this following snippet which shows that $b is not set to 1 as Execute() evaluates expression and return results from this evalutation.

Local $a = 1
Local $v = Execute("$a+1") ; $v is set to 2
ConsoleWrite("$v=" & $v & @CRLF)

Local $b
Execute("$b=1")
ConsoleWrite("$b=" & $b & @CRLF)

Local $c
ConsoleWrite(Execute("$c=1") & @CRLF)

Checklist

Types of changes

What is the current behavior?

description in: https://github.com/Danp2/au3WebDriver/issues/461

What is the new behavior?

It is possible to use such UserTesting.au3:

__UserAssign(0, 'Absolute Identifiers > _WD_FrameEnter|Relative Identifiers > _WD_FrameEnter|FRAME attributes|URL|Body ElementID|IsHidden|MatchedElements')

_Demo_NavigateCheckBanner($sSession, "https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_iframe", '//*[@id="snigel-cmp-framework" and @class="snigel-cmp-framework"]')
ConsoleWrite("! 1" & @CRLF)

__UserAssign(1, _WD_GetContext($sSession))
ConsoleWrite("! 2" & $_VAR[1] & @CRLF)

__UserAssign(2, _WD_FrameList($sSession))

ConsoleWrite("! 3" & @CRLF)

_ArrayDisplay($_VAR[2], 'Starting', 0, 0, Default, $_VAR[0])
ConsoleWrite("! 4 - _ArrayDisplay" & @CRLF)

_WD_FrameEnter($sSession, 'null/0')
ConsoleWrite("! 5" & @CRLF)

__UserAssign(3, _WD_FrameList($sSession))
ConsoleWrite("! 6" & @CRLF)

_ArrayDisplay($_VAR[3], 'null/0', 0, 0, Default, $_VAR[0])
ConsoleWrite("! 7 - _ArrayDisplay" & @CRLF)

_WD_FrameEnter($sSession, $CONTEXT)
ConsoleWrite("! 8" & @CRLF)

__UserAssign(4, _WD_FrameList($sSession))
ConsoleWrite("! 9" & @CRLF)

_ArrayDisplay($_VAR[4], '$CONTEXT', 0, 0, Default, $_VAR[0])
ConsoleWrite("! 10 - _ArrayDisplay" & @CRLF)

The main benefit of this modification is that you can test user code on the run without having to close wd_demo.au3 and more importantly without having to close the compiled version wd_demo.exe, so you can test a given script modification without having to install the test environment for AutoIt+SciTE.

Additional context

https://github.com/Danp2/au3WebDriver/issues/461

System under test

not related

Danp2 commented 1 year ago

__UserAssing

Perhaps you meant __UserAssign? 😆

mlipok commented 1 year ago

Typo...

mlipok commented 1 year ago

btw. I have already prepared additionall PR which will loop the selection and execution of the test file so that you can retry the tests without closing the active browser session

But it should be a separate PR as this is separate feature.