PowerShell-IE11-Apex-自动下拉选择

我正在尝试通过PowerShell自动执行使用Oracle Apex编写的现有网站的一些任务。有一个州的下拉列表,当选择一个州时,数据需要相应地更改。我可以选择所需的状态并成功激发";OnChange";事件,但它不会像手动选择下拉选项那样更改数据。请谁帮助我如何使用PowerShell获得与手动选择相同的结果。

这里是下拉框的示例。

<select  id="All_STATE" name="All_STATE" class="selectlist apex-item-select" size="1" >
   <option value="" selected="selected" >- Please Select -</option>
   <option value="Texas">Texas</option>
   <option value="Kansas">Kansas</option>
   <option value="Michigan">Michigan</option>
</select>

以下是我尝试使用的Powershell代码

$statecontrol = $null
$statecontrol = $ie.document.IHTMLDocument3_getElementById("All_STATE")
($statecontrol | where {$_.value -eq "Texas"}).Selected = $true
$statecontrol.FireEvent("OnChange")

我在JavaScript下找到了这些函数,它们可能相关,但不能确定,我不知道APEX。我认为我不能在这里共享整个JavaScript,因为它是专有的。

function(){ apex.widget.selectList("#All_STATE",{`code here`});})();

function(){ apex.jQuery('#List').interactiveReport.interactiveReport({`code here`});})();

{"triggeringElementType":"ITEM","triggeringElement":"All_STATE","bindType":"bind","bindEventType":"change","anyActionsFireOnInit":false,actionList:`code here`

解决方案

根据您的描述,我创建了一个简单的示例来满足您的需求,我认为您的问题主要是自动化页面的加载情况,asimilar case。

这是我的测试,工作正常:

页面代码:

<select id="All_STATE" name="All_STATE" class="selectlist&#x20;apex-item-select" size="1" onchange="myFunction()">
        <option value="" selected="selected">- Please Select -</option>
        <option value="Texas">Texas</option>
        <option value="Kansas">Kansas</option>
        <option value="Michigan">Michigan</option>
    </select>
    <script>
        function myFunction() {
            alert('some script code here');
        }
    </script>

Powershell代码:

$ie = New-Object -ComObject internetexplorer.application
$ie.Visible = $true
$ie.Navigate("<your website url>")
While ($ie.Busy -eq $true) {Start-Sleep -Seconds 3;}
$statecontrol = $ie.document.IHTMLDocument3_getElementById("All_STATE")
($statecontrol | where {$_.value -eq "Texas"}).Selected = $true
$statecontrol.FireEvent("OnChange")

结果:

相关文章