@@ -47,6 +47,11 @@ Global Enum _
47
47
$_WD_OPTION_Visible = 1 , _
48
48
$_WD_OPTION_Enabled = 2 , _
49
49
$_WD_OPTION_Element = 4
50
+
51
+ Global Enum _
52
+ $_WD_OPTION_Standard , _
53
+ $_WD_OPTION_Advanced
54
+
50
55
#EndRegion
51
56
; #FUNCTION# ====================================================================================================================
52
57
; Name ..........: _WD_NewTab
@@ -1578,10 +1583,15 @@ EndFunc
1578
1583
; #FUNCTION# ====================================================================================================================
1579
1584
; Name ..........: _WD_SetElementValue
1580
1585
; Description ...: Set value of designated element
1581
- ; Syntax ........: _WD_SetElementValue($sSession, $sElement, $sValue)
1586
+ ; Syntax ........: _WD_SetElementValue($sSession, $sElement, $sValue[, $iStyle = Default] )
1582
1587
; Parameters ....: $sSession - Session ID from _WD_CreateSession
1583
1588
; $sElement - Element ID from _WD_FindElement
1584
1589
; $sValue - New value for element
1590
+ ; $iStyle - [optional] Update style. Default is $_WD_OPTION_Standard.
1591
+ ;
1592
+ ; $_WD_OPTION_Standard (0) = Set value using _WD_ElementAction
1593
+ ; $_WD_OPTION_Advanced (1) = set value using _WD_ExecuteScript
1594
+ ;
1585
1595
; Return values .: Success - Requested data returned by web driver
1586
1596
; Failure - ""
1587
1597
; @ERROR - $_WD_ERROR_Success
@@ -1592,17 +1602,31 @@ EndFunc
1592
1602
; @EXTENDED - WinHTTP status code
1593
1603
;
1594
1604
; Author ........: Dan Pollak
1595
- ; Modified ......:
1605
+ ; Modified ......: 03/31/2021
1596
1606
; Remarks .......:
1597
1607
; Related .......:
1598
1608
; Link ..........:
1599
1609
; Example .......: No
1600
1610
; ===============================================================================================================================
1601
- Func _WD_SetElementValue($sSession , $sElement , $sValue )
1611
+ Func _WD_SetElementValue($sSession , $sElement , $sValue , $iStyle = Default )
1602
1612
Local Const $sFuncName = " _WD_SetElementValue"
1613
+ Local $sResult , $iErr , $sScript , $sJsonElement
1603
1614
1604
- Local $sResult = _WD_ElementAction($sSession , $sElement , ' value' , $sValue )
1605
- Local $iErr = @error
1615
+ If $iStyle = Default Then $iStyle = $_WD_OPTION_Standard
1616
+ If $iStyle < $_WD_OPTION_Standard Or $iStyle > $_WD_OPTION_Advanced Then $iMethod = $_WD_OPTION_Standard
1617
+
1618
+ Switch $iStyle
1619
+ Case $_WD_OPTION_Standard
1620
+ $sResult = _WD_ElementAction($sSession , $sElement , ' value' , $sValue )
1621
+ $iErr = @error
1622
+
1623
+ Case $_WD_OPTION_Advanced
1624
+ $sScript = " Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, 'value').set.call(arguments[0], arguments[1]);arguments[0].dispatchEvent(new Event('input', { bubbles: true }));"
1625
+ $sJsonElement = ' {"' & $_WD_ELEMENT_ID & ' ":"' & $sElement & ' "}'
1626
+ $sResult = _WD_ExecuteScript($sSession , $sScript , $sJsonElement & ' ,"' & $sValue & ' "' )
1627
+ $iErr = @error
1628
+
1629
+ EndSwitch
1606
1630
1607
1631
Return SetError (__WD_Error($sFuncName , $iErr ), 0 , $sResult )
1608
1632
EndFunc
0 commit comments