本文介绍了PowerShell的InternetExplorer.Application提示框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以下是代码:
<!DOCTYPE html>
< html>
< body>
< h2> PS提示测试< / h2>
< button onclick =Function()id =test>发送值< / button>
< p id =demo>< / p>
< script>
函数Function(){
var txt;
var text = prompt(请输入文字:,示例文字);
if(text == null || text ==){
txt =用户取消了提示。
} else {
txt =您的文字是:+ text;
}
document.getElementById(demo)。innerHTML = txt;
}
< / script>
< / body>
< / html>
以下是帮助我进入弹出窗口的命令:
$ ie = New-Object -ComObject InternetExplorer.Application;
$ loginpage =http://127.0.0.1/prompt.html
$ ie.Navigate2($ loginpage)
$ ie.Visible = $ true;
while($ ie.Busy){Start-Sleep -Milliseconds 100}
$ ie.document.IHTMLDocument3_getElementByID(test)。click()
执行这些脚本后,脚本将等待操作
请帮忙。如何输入任何值并单击弹出按钮?
Thanks!
解决方案
您是否可以在输入字段中输入任何文字? / p>
我测试过了,代码可以按预期工作 - 我可以通过追加以下内容来检索输入值。
$ result = $ ie.document.IHTMLDocument3_getElementByID(demo)。innerText
$ result
I can not add any value to the pop-up window.
Here is the code:
<!DOCTYPE html>
<html>
<body>
<h2>PS Prompt test</h2>
<button onclick="Function()" id="test">send value</button>
<p id="demo"></p>
<script>
function Function() {
var txt;
var text = prompt("Please enter text:", "example text");
if (text == null || text == "") {
txt = "User cancelled the prompt.";
} else {
txt = "Your text is: " + text;
}
document.getElementById("demo").innerHTML = txt;
}
</script>
</body>
</html>
Below are the commands that helped me get to the pop-up window:
$ie = New-Object -ComObject InternetExplorer.Application;
$loginpage = "http://127.0.0.1/prompt.html"
$ie.Navigate2($loginpage)
$ie.Visible = $true;
While ($ie.Busy) {Start-Sleep -Milliseconds 100}
$ie.document.IHTMLDocument3_getElementByID("test").click()
After they are executed, the script waits for actions
Please, help. How to enter any value and click the pop-up button?Thanks!
解决方案
Can you not enter any text into the input field where it states "example text"?
I've tested and the code works as expected - I am able to retrieve the input value by appending the following.
$result = $ie.document.IHTMLDocument3_getElementByID("demo").innerText
$result
这篇关于PowerShell的InternetExplorer.Application提示框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!