3

I need to click on a hyperlink in a aspx webform using powershell. How can I achieve this? Also that link shows a drop down menu and I have to select the right option from that link.

DIF
  • 2,470
  • 6
  • 35
  • 49
user423487
  • 53
  • 1
  • 3
  • 7

2 Answers2

8
$ie = new-object -com internetexplorer.application
$ie.visible=$true
$ie.navigate('http://www.somewhere.com')
while($ie.busy) {sleep 1}
$link = $ie.Document.getElementsByTagName('A') | where-object {$_.innerText -eq 'Click here'}
$link.click()
Shay Levy
  • 121,444
  • 32
  • 184
  • 206
  • Thanks your help i had to use following lines to access frame's content. $dmeContExpFrame = $ie.Document.getElementById("ContentFrame") $dmecontexpframedoc = $dmeContExpFrame.contentWindow $dmeContExpFramedoc2 = $dmecontexpframedoc.Document $links = $dmeContExpFramedoc2.getElementsByTagName('A') $links | select innerText – user423487 Sep 06 '10 at 01:29
  • what does the 'A' in getElementsbyTagName indicate? – Clint Eastwood Jan 23 '15 at 21:16
  • 1
    I'd guess the `A` is from the HTML ` – user4317867 Feb 03 '15 at 23:31
  • if the innerText is variable you can use Regex as following: `{$_.innerText -Match '^a.*'}` – bnu Jun 26 '15 at 07:31
0

Its works

while($ie.busy) {sleep 5} 
$dmeContExpFrame = $ie.Document.getElementById("portfolio_frameset") 
$dmecontexpframedoc = $dmeContExpFrame.contentWindow 
$dmeContExpFramedoc2 = $dmecontexpframedoc.Document 
$click = $dmeContExpFramedoc2.getElementsByTagName("b") | ?{$_.innerText -Match "Monitor Library"}
$click.click()
Jean Paul
  • 1
  • 2