Skip to content

Commit 1b65b6f

Browse files
authored
Prep release (#415)
* Tidy code * Update changelog * Update readme * Update version * Update help file
1 parent 77a2aa1 commit 1b65b6f

File tree

7 files changed

+73
-58
lines changed

7 files changed

+73
-58
lines changed

CHANGELOG.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
Go to [legend](#legend---types-of-changes) for further information about the types of changes.
1111

12+
## [ 0.12.0]
13+
14+
### Added
15+
16+
- _WD_DebugSwitch (@mLipok)
17+
- _WD_GetFreePort
18+
19+
### Changed
20+
21+
- _WD_CreateSession: Revise default capabilities
22+
- _WD_ElementActionEx: Scroll element into view by default
23+
1224
## [ 0.11.0]
1325

1426
### Added
@@ -1007,7 +1019,8 @@ _WD_CapabilitiesDisplay
10071019
- Initial release
10081020

10091021

1010-
[Unreleased]: https://github.com/Danp2/au3WebDriver/compare/0.11.0...HEAD
1022+
[Unreleased]: https://github.com/Danp2/au3WebDriver/compare/0.12.0...HEAD
1023+
[0.12.0]: https://github.com/Danp2/au3WebDriver/compare/0.11.0...0.12.0
10111024
[0.11.0]: https://github.com/Danp2/au3WebDriver/compare/0.10.1...0.11.0
10121025
[0.10.1]: https://github.com/Danp2/au3WebDriver/compare/0.10.0...0.10.1
10131026
[0.10.0]: https://github.com/Danp2/au3WebDriver/compare/0.9.1...0.10.0

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ This au3WebDriver UDF (project) allows to interact with any browser that support
7373
| _WD_Attach | Attach to existing browser tab. |
7474
| _WD_CheckContext | Check if browser context is still valid. |
7575
| _WD_ConsoleVisible | Control visibility of the webdriver console app. |
76+
| _WD_DebugSwitch | Switch to new debug level or switch back to saved debug level. |
7677
| _WD_DispatchEvent | Create and dispatch events. |
7778
| _WD_DownloadFile | Download file and save to disk. |
7879
| _WD_ElementActionEx | Perform advanced action on designated element. |
@@ -90,6 +91,7 @@ This au3WebDriver UDF (project) allows to interact with any browser that support
9091
| _WD_GetElementByRegEx | Find element by matching attributes values using Javascript regular expression. |
9192
| _WD_GetElementFromPoint | Retrieves reference to element at specified point. |
9293
| _WD_GetFrameCount | Returns the number of frames/iframes in the current document context. |
94+
| _WD_GetFreePort | Locate and return an available TCP port within a defined range. |
9395
| _WD_GetMouseElement | Retrieves reference to element below mouse pointer. |
9496
| _WD_GetShadowRoot | Retrieves the shadow root of an element. |
9597
| _WD_GetTable | Return all elements of a table. |

Webdriver.chm

3.54 KB
Binary file not shown.

wd_cdp.au3

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ Func _WD_CDPExecuteCommand($sSession, $sCommand, $oParams, $sWebSocketURL = Defa
234234
$sMessage &= " ResponseText=" & $sRecv
235235
EndIf
236236
EndIf
237-
Return SetError(__WD_Error($sFuncName, $_WD_ERROR_Success, $sMessage), 0, $sRecv)
237+
Return SetError(__WD_Error($sFuncName, $_WD_ERROR_Success, $sMessage), 0, $sRecv)
238238
EndFunc ;==>_WD_CDPExecuteCommand
239239

240240
; #FUNCTION# ====================================================================================================================
@@ -339,5 +339,5 @@ Func _WD_CDPGetSettings($sSession, $sOption)
339339
If $iErr Then
340340
Return SetError(__WD_Error($sFuncName, $iErr), 0, "")
341341
EndIf
342-
Return SetError(__WD_Error($sFuncName, $_WD_ERROR_Success), 0, $vResult)
342+
Return SetError(__WD_Error($sFuncName, $_WD_ERROR_Success), 0, $vResult)
343343
EndFunc ;==>_WD_CDPGetSettings

wd_core.au3

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
#EndRegion Many thanks to:
7070

7171
#Region Global Constants
72-
Global Const $__WDVERSION = "0.11.0"
72+
Global Const $__WDVERSION = "0.12.0"
7373

7474
Global Const $_WD_ELEMENT_ID = "element-6066-11e4-a52e-4f735466cecf"
7575
Global Const $_WD_SHADOW_ID = "shadow-6066-11e4-a52e-4f735466cecf"
@@ -239,7 +239,7 @@ Func _WD_CreateSession($sCapabilities = Default)
239239
$sMessage = $sSession
240240

241241
; Save response details for future use
242-
$_WD_SESSION_DETAILS = $sResponse
242+
$_WD_SESSION_DETAILS = $sResponse
243243
EndIf
244244
Else
245245
$iErr = $_WD_ERROR_Exception
@@ -1208,13 +1208,13 @@ Func _WD_Startup()
12081208

12091209
$sFunction = "_WD_GetFreePort"
12101210
Call($sFunction, $_WD_PORT)
1211-
1211+
12121212
Select
1213-
Case @error = 0xDEAD And @extended = 0xBEEF
1214-
; function not available
1213+
Case @error = 0xDEAD And @extended = 0xBEEF
1214+
; function not available
12151215

1216-
Case @error
1217-
$sPortAvailable = " (Unavailable)"
1216+
Case @error
1217+
$sPortAvailable = " (Unavailable)"
12181218
EndSelect
12191219

12201220
Local $sCommand = StringFormat('"%s" %s ', $_WD_DRIVER, $_WD_DRIVER_PARAMS)
@@ -1223,7 +1223,7 @@ Func _WD_Startup()
12231223
$iPID = ProcessExists($sFile)
12241224

12251225
If $_WD_DRIVER_DETECT And $iPID Then
1226-
$sExistingDriver = "Existing instance of " & $sFile & " detected! (PID=" & $iPID & ")"
1226+
$sExistingDriver = "Existing instance of " & $sFile & " detected! (PID=" & $iPID & ")"
12271227
Else
12281228
$iPID = Run($sCommand, "", ($_WD_DEBUG >= $_WD_DEBUG_Info) ? @SW_SHOW : @SW_HIDE)
12291229
If @error Or ProcessWaitClose($iPID, 1) Then $iErr = $_WD_ERROR_GeneralError

wd_demo.au3

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ Func RunDemo($idDebugging, $idBrowsers, $idUpdate, $idHeadless, $idOutput)
206206
_WD_CheckContext($sSession, False)
207207
$iError = @error
208208
If @error Then ExitLoop ; return if session is NOT OK
209-
209+
210210
ConsoleWrite("+ wd_demo.au3: Running: " & $sDemoName & @CRLF)
211211
If $aDemoSuite[$iIndex][2] Then
212212
Call($sDemoName, $sBrowserName)

wd_helper.au3

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ Global Enum _
5353
$_WD_OPTION_Enabled = 2, _
5454
$_WD_OPTION_Element = 4, _
5555
$_WD_OPTION_NoMatch = 8, _
56-
$_WD_OPTION_Hidden = 16
56+
$_WD_OPTION_Hidden = 16
5757

5858
Global Enum _
5959
$_WD_OPTION_Standard, _
@@ -76,7 +76,7 @@ Global Enum _
7676
Global Enum _
7777
$_WD_STORAGE_Local = 0, _
7878
$_WD_STORAGE_Session = 1
79-
79+
8080
Global Enum _
8181
$_WD_FRAMELIST_Absolute = 0, _
8282
$_WD_FRAMELIST_Relative = 1, _
@@ -180,7 +180,7 @@ Func _WD_NewTab($sSession, $bSwitch = Default, $iTimeout = Default, $sURL = Defa
180180
EndIf
181181

182182
_WD_ExecuteScript($sSession, "window.open(arguments[0], '', arguments[1])", '"' & $sURL & '","' & $sFeatures & '"')
183-
183+
184184
If @error <> $_WD_ERROR_Success Then
185185
Return SetError(__WD_Error($sFuncName, $_WD_ERROR_Exception, $sParameters), 0, $sTabHandle)
186186
EndIf
@@ -235,7 +235,7 @@ EndFunc ;==>_WD_NewTab
235235
; ===============================================================================================================================
236236
Func _WD_Attach($sSession, $sSearch, $sMode = Default)
237237
Local Const $sFuncName = "_WD_Attach"
238-
Local Const $sParameters = 'Parameters: Search=' & $sSearch & ' Mode=' & $sMode
238+
Local Const $sParameters = 'Parameters: Search=' & $sSearch & ' Mode=' & $sMode
239239
Local $sTabHandle = '', $bFound = False, $sCurrentTab = '', $aHandles
240240
Local $iErr = $_WD_ERROR_Success
241241

@@ -374,7 +374,7 @@ Func _WD_WaitElement($sSession, $sStrategy, $sSelector, $iDelay = Default, $iTim
374374

375375
; Other options aren't valid if No Match or Hidden option is supplied
376376
If ($bNoMatch And $iOptions <> $_WD_OPTION_NoMatch) Or _
377-
($bHidden And $iOptions <> $_WD_OPTION_Hidden) Then
377+
($bHidden And $iOptions <> $_WD_OPTION_Hidden) Then
378378
$iErr = $_WD_ERROR_InvalidArgue
379379
Else
380380
__WD_Sleep($iDelay)
@@ -424,14 +424,14 @@ Func _WD_WaitElement($sSession, $sStrategy, $sSelector, $iDelay = Default, $iTim
424424
EndIf
425425

426426
Select
427-
Case $bHidden
428-
If Not $bIsVisible Then ExitLoop
427+
Case $bHidden
428+
If Not $bIsVisible Then ExitLoop
429429

430-
Case $bIsVisible And $bIsEnabled
431-
ExitLoop
430+
Case $bIsVisible And $bIsEnabled
431+
ExitLoop
432432

433-
Case Else
434-
$sElement = ''
433+
Case Else
434+
$sElement = ''
435435
EndSelect
436436
EndIf
437437

@@ -634,8 +634,8 @@ Func _WD_FrameEnter($sSession, $vIdentifier)
634634
Local $sValue, $sMessage = '', $sOption, $sResponse, $oJSON
635635
Local $iErr = $_WD_ERROR_Success
636636

637-
; 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
638-
Local Const $bIdentifierAsPath = StringRegExp($vIdentifier, "(?i)\A(?:Null|\d+)(?:\/\d+)+\Z", $STR_REGEXPMATCH)
637+
; 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
638+
Local Const $bIdentifierAsPath = StringRegExp($vIdentifier, "(?i)\A(?:Null|\d+)(?:\/\d+)+\Z", $STR_REGEXPMATCH)
639639

640640
If $bIdentifierAsPath Then
641641
; will be processed below
@@ -701,7 +701,7 @@ EndFunc ;==>_WD_FrameEnter
701701
; - $_WD_ERROR_Exception
702702
; Author ........: Decibel
703703
; Modified ......: Danp2
704-
; Remarks .......:
704+
; Remarks .......:
705705
; Related .......: _WD_Window, _WD_LastHTTPResult
706706
; Link ..........: https://www.w3.org/TR/webdriver/#switch-to-parent-frame
707707
; Example .......: No
@@ -2437,7 +2437,7 @@ EndFunc ;==>_WD_SetElementValue
24372437
Func _WD_ElementActionEx($sSession, $sElement, $sCommand, $iXOffset = Default, $iYOffset = Default, $iButton = Default, $iHoldDelay = Default, $sModifier = Default, $bScrollView = Default)
24382438
Local Const $sFuncName = "_WD_ElementActionEx"
24392439
Local Const $sParameters = 'Parameters: Element=' & $sElement & ' Command=' & $sCommand & ' XOffset=' & $iXOffset & ' YOffset=' & $iYOffset & ' Button=' & $iButton & ' HoldDelay=' & $iHoldDelay & ' Modifier=' & $sModifier & ' ScrollView=' & $bScrollView
2440-
Local $sAction, $sJavascript, $iErr, $sResult, $iActionType = 1
2440+
Local $sAction, $sJavaScript, $iErr, $sResult, $iActionType = 1
24412441
$_WD_HTTPRESULT = 0
24422442
$_WD_HTTPRESPONSE = ''
24432443

@@ -2516,19 +2516,19 @@ Func _WD_ElementActionEx($sSession, $sElement, $sCommand, $iXOffset = Default, $
25162516

25172517
Case 'hide'
25182518
$iActionType = 2
2519-
$sJavascript = "arguments[0].style='display: none'; return true;"
2519+
$sJavaScript = "arguments[0].style='display: none'; return true;"
25202520

25212521
Case 'show'
25222522
$iActionType = 2
2523-
$sJavascript = "arguments[0].style='display: normal'; return true;"
2523+
$sJavaScript = "arguments[0].style='display: normal'; return true;"
25242524

25252525
Case 'childcount'
25262526
$iActionType = 2
2527-
$sJavascript = "return arguments[0].children.length;"
2527+
$sJavaScript = "return arguments[0].children.length;"
25282528

25292529
Case 'check', 'uncheck'
25302530
$iActionType = 2
2531-
$sJavascript = "Object.getOwnPropertyDescriptor(arguments[0].__proto__, 'checked').set.call(arguments[0], " & ($sCommand = "check" ? 'true' : 'false') & ");arguments[0].dispatchEvent(new Event('change', { bubbles: true }));"
2531+
$sJavaScript = "Object.getOwnPropertyDescriptor(arguments[0].__proto__, 'checked').set.call(arguments[0], " & ($sCommand = "check" ? 'true' : 'false') & ");arguments[0].dispatchEvent(new Event('change', { bubbles: true }));"
25322532

25332533
Case Else
25342534
Return SetError(__WD_Error($sFuncName, $_WD_ERROR_InvalidDataType, "(Hover|RightClick|DoubleClick|Click|ClickAndHold|Hide|Show|ChildCount|ModifierClick|Check|Uncheck) $sCommand=>" & $sCommand), 0, "")
@@ -2579,7 +2579,7 @@ Func _WD_ElementActionEx($sSession, $sElement, $sCommand, $iXOffset = Default, $
25792579
$iErr = @error
25802580

25812581
Case 2
2582-
$sResult = _WD_ExecuteScript($sSession, $sJavascript, __WD_JsonElement($sElement), Default, $_WD_JSON_Value)
2582+
$sResult = _WD_ExecuteScript($sSession, $sJavaScript, __WD_JsonElement($sElement), Default, $_WD_JSON_Value)
25832583
$iErr = @error
25842584
EndSwitch
25852585

@@ -2878,37 +2878,37 @@ Func _WD_Storage($sSession, $vKey, $vValue = Default, $nType = Default)
28782878
Local $sParams, $vResult = '', $iErr = $_WD_ERROR_Success
28792879
Local Const $bIsKeyNull = (IsKeyword($vKey) = $KEYWORD_NULL), $bIsValueNull = (IsKeyword($vValue) = $KEYWORD_NULL)
28802880
Local Const $sParameters = 'Parameters: Key=' & ($bIsKeyNull ? "Null" : $vKey) & ' Value=' & ($bIsValueNull ? "Null" : $vValue) & ' Type=' & $nType
2881-
2881+
28822882
If $nType = Default Or $nType < $_WD_STORAGE_Local Or $nType > $_WD_STORAGE_Session Then $nType = $_WD_STORAGE_Local
28832883

28842884
Local $sTarget = ($nType = $_WD_STORAGE_Local) ? "window.localStorage" : "window.sessionStorage"
2885-
Local $sJavaScript = 'return ' & $sTarget
2885+
Local $sJavaScript = 'return ' & $sTarget
28862886

28872887
Select
2888-
Case $bIsKeyNull ; Empty storage
2889-
If $vValue = Default Then
2890-
$sJavaScript &= '.clear()'
2891-
$sParams = $_WD_EmptyDict
2892-
Else
2893-
$iErr = $_WD_ERROR_InvalidArgue
2894-
EndIf
2888+
Case $bIsKeyNull ; Empty storage
2889+
If $vValue = Default Then
2890+
$sJavaScript &= '.clear()'
2891+
$sParams = $_WD_EmptyDict
2892+
Else
2893+
$iErr = $_WD_ERROR_InvalidArgue
2894+
EndIf
28952895

2896-
Case $vValue = Default ; Retrieve key
2897-
If IsNumber($vKey) Then
2898-
$sJavaScript &= '.key(arguments[0])'
2899-
$sParams = String($vKey)
2900-
Else
2901-
$sJavaScript &= '.getItem(arguments[0])'
2902-
$sParams = '"' & $vKey & '"'
2903-
EndIf
2896+
Case $vValue = Default ; Retrieve key
2897+
If IsNumber($vKey) Then
2898+
$sJavaScript &= '.key(arguments[0])'
2899+
$sParams = String($vKey)
2900+
Else
2901+
$sJavaScript &= '.getItem(arguments[0])'
2902+
$sParams = '"' & $vKey & '"'
2903+
EndIf
29042904

2905-
Case $bIsValueNull ; Remove key
2906-
$sJavaScript &= '.removeItem(arguments[0])'
2907-
$sParams = '"' & $vKey & '"'
2905+
Case $bIsValueNull ; Remove key
2906+
$sJavaScript &= '.removeItem(arguments[0])'
2907+
$sParams = '"' & $vKey & '"'
29082908

2909-
Case $vKey And $vValue ; Set key
2910-
$sJavaScript &= '.setItem(arguments[0], arguments[1])'
2911-
$sParams = '"' & $vKey & '","' & $vValue & '"'
2909+
Case $vKey And $vValue ; Set key
2910+
$sJavaScript &= '.setItem(arguments[0], arguments[1])'
2911+
$sParams = '"' & $vKey & '","' & $vValue & '"'
29122912
EndSelect
29132913

29142914
If $iErr = $_WD_ERROR_Success Then
@@ -2917,7 +2917,7 @@ Func _WD_Storage($sSession, $vKey, $vValue = Default, $nType = Default)
29172917
EndIf
29182918

29192919
Return SetError(__WD_Error($sFuncName, $iErr, $sParameters), 0, $vResult)
2920-
EndFunc
2920+
EndFunc ;==>_WD_Storage
29212921

29222922
; #FUNCTION# ====================================================================================================================
29232923
; Name ..........: _WD_JsonActionKey
@@ -2956,7 +2956,7 @@ EndFunc ;==>_WD_JsonActionKey
29562956
; Parameters ....: $iMinPort - [optional] Starting port number. Default is 64000
29572957
; $iMaxPort - [optional] Ending port number. Default is $iMinPort or 65000
29582958
; Return values .: Success - Available TCP port number
2959-
; Failure - 0 and @error set to $_WD_ERROR_NotFound
2959+
; Failure - 0 and @error set to $_WD_ERROR_NotFound
29602960
; Author ........: Danp2
29612961
; Modified ......:
29622962
; Remarks .......:
@@ -2975,7 +2975,7 @@ Func _WD_GetFreePort($iMinPort = Default, $iMaxPort = Default)
29752975
If Not @error Then
29762976
For $iPort = $iMinPort To $iMaxPort
29772977
_ArraySearch($aPorts, $iPort, Default, Default, Default, Default, Default, 3)
2978-
If @error = 6 Then
2978+
If @error = 6 Then
29792979
$iResult = $iPort
29802980
$iErr = $_WD_ERROR_Success
29812981
ExitLoop

0 commit comments

Comments
 (0)