нужна помощь программно войти на веб-страницу и выполнить JavaScript - PullRequest
0 голосов
/ 03 ноября 2018

Используя powershell и HTML DOM и javascript, я пытаюсь программно создавать учетные записи на веб-странице, и я застрял в следующем пункте кода:

$ie = New-Object -ComObject 'internetExplorer.Application'
$ie.Visible= $true # Make it visible

$password="password"

$ie.Navigate("http://printerAccounts:8001/login")

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

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

$Link = $ie.document.getElementByID('key_anchor')
$Link.click()
While ($ie.Busy -eq $true) {Start-Sleep -Seconds 1;}
$ie.Navigate("http://printerAccounts:8001/fields/listValues.do")
$Link = $ie.document.getElementByID('theRows'). // <--- doesnt work
$Link.click()

Исходный код веб-страницы приведен ниже. Мне кажется, я пытаюсь запустить эту строку tr class = 'tablerowunselected' index = '0' objectId = '3' onclick = 'toggleRow (this);' Уровень = '0'

<html>
<head>
<link rel="stylesheet" type="text/css"
     href='/resources/stylesheets/basestyle.css'/>
<script src="/jquery-1.7.2.min.js"></script>
<script src="/util.js"></script>
<script>

var currentRow = null;
function toggleRow(row) {...}
function disableRow(row){...}
function enableRow(row){...}
function enableRows()  {...}
function enableChildren(enable)  {...}
function enableTreeRow(index,level,enable) {...}
function initialisation() {...}

</script>
</head>
<body bgcolor='white' topmargin='0' leftmargin='0' bottommargin='0' 
     rightmargin='0'
       onload='javascript:initialisation();'>
<table width='100%' height='100%' cellspacing='0' cellpadding='0' '>
<tr><td height='100%' valign='top' align='left'>
   <table id='theRows' width='100%' cellpadding='0' cellspacing='0'>
 <tr class='tablerowunselected' index='0' objectId='3' 
 onclick='toggleRow(this);' level='0'>
 <td width='33' height='18'><img src='/resources/images/tree/t1110.gif'/ 
 </td>
    <td width='100%' class='font' colspan='2' nowrap>User Name</td>
 </tr>
 <tr class='tablerowunselected' index='1' objectId='7' 
 onclick='toggleRow(this);' level='1'>
   <td width='33' height='18'><img src='/resources/images/tree/t1010.gif'/> 
   </td>
   <td width='33' height='18'><img src='/resources/images/tree/t1100.gif'/> 
   </td>
   <td width='100%' class='font' colspan='1' nowrap>Password</td>
 </tr>
 <tr class='tablerowunselected' index='2' objectId='5' 
 onclick='toggleRow(this);' level='0'>
  <td width='33' height='18'><img src='/resources/images/tree/t1110.gif'/> 
</td>
  <td width='100%' class='font' colspan='2' nowrap>Project</td>
 </tr>
 <tr class='tablerowunselected' index='3' objectId='6' 
onclick='toggleRow(this);' level='0'>
  <td width='33' height='18'><img src='/resources/images/tree/t1100.gif'/> 
</td>
  <td width='100%' class='font' colspan='2' nowrap>Reason For Plot</td>
 </tr>
</table>
</td></tr>....
</html>

Любая помощь приветствуется.

...