Powershell нажмите на кнопку javascript в проводнике inte rnet - PullRequest
0 голосов
/ 14 января 2020

Я бы хотел нажать на эту кнопку без использования селена. Есть предложения?


HTML КОД

image

->


мой код и тесты, которые я сделал

$ ie = new-object -com "InternetExplorer.Application" $ ie .visible = $ true max IE $ ie

$ username = "xxxxxxx"

$ password = Get-Content -Path D: \ pass \ PasswordPo snet .txt

$ ie .Navigate ("siteweb" ) $ HomePage = $ ie .document

While ($ ie .Busy -eq $ true) {Start-Sleep -Seconds 2;}

$ usernamefield = $ ie .document.getElementByID ('userid') $ usernamefield.value = "$ username"

$ passwordfield = $ ie .document.getElementByID ('password') $ passwordfield.value = "$ password"

$ Link = $ ie .document.getElementByID ('button') $ Link.click ()

Start-Sleep -секунд 2

Test 1

$ link = @ ($ ie .Document.getElementsByTagName ('a')) | Where-Object {$ _. InnerText -eq 'Examinar'} $ link.click ()

Тест 2

$ ie .document.IHTMLDocument3_getElementsByTagName ("button") | ForEach-Object {$ _. Click ()}

Тест 3

$ link = $ ie .Document.getElementsByTagName ("button") | where-object {$ _. type -eq "submit"} $ link.click ()

Тест 4

$ link = $ ie .Document.getElementsByTagName ("input") | Where-Object {$ .type -eq 'button' -and $ .value -eq 'FileBrowseApplet0'} $ link.Click ()


Способ дифференциации этой кнопки это: "FileBrowseApplet0"

1 Ответ

0 голосов
/ 14 января 2020

Это должно привести вас к правильному пути (PowerShell):

$oIE         = new-object -com internetexplorer.application
$oIE.visible = $true

[void]$oIE.navigate2("https://<yourUrl>")
Do {
    sleep -seconds 1
} while ($oIE.busy)


$control = $oIE.document.IHTMLDocument3_getElementsByTagName('BUTTON') | ? { $_.IHTMLElement_innerHTML -like <patternToFind> }

[void]$control.click()

while ($oIE.busy) {
    sleep -seconds 1
}
...