Greetings to all!

Faced the task of making a variable in the popup window of the prompt box.

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> 

I could only get to open it:

 $ie = New-Object -ComObject InternetExplorer.Application; $loginpage = "https://127.0.0.1/1/" $ie.Navigate2($loginpage) $ie.Visible = $true; While ($ie.Busy) {Start-Sleep -Milliseconds 100} $ie.document.IHTMLDocument3_getElementByID("test").click() 

Next you need to enter any text in the pop-up window and click on the button enter image description here

If you can help solve this problem. Thank.

  • Try $ie.document.IHTMLDocument3_getElementByID("ваш ID, куда нужно текст вставить").value = txt; - Senior Pomidor
  • Thanks for the advice, but as you can see in the code there is one id and when you insert $ ie.document.IHTMLDocument3_getElementByID ("demo"). innerHTML = "test test test" the value changes between the "P" tags and the button itself will not click ) - Anton Savichev
  • then I did not understand what the problem was - Senior Pomidor
  • you must enter a value in the window that opens (replace "example text" with any other value. and then click the ok button. - Anton Savichev
  • script execution stops at the moment: $ ie.document.IHTMLDocument3_getElementByID ("test"). click () and then waits for action from the user. So you need to automate it. - Anton Savichev

0