none
Need help clicking on a hyperlink in powershell RRS feed

  • Question

  • Hi guys, I am new to powershell and trying to automate an application. For that I need to launch a URL and click on a hyperlink. I am able to launch the URL but unable to click on the hyperlink. I am using the below code. Please help me figure out what I am doing wrong.

    $IE=new-object -com internetexplorer.application
    $IE.navigate2("http://appview.csfb.net/appview/")
    $IE.visible=$true
    $link=$ie.Document.getElementsByTagName('A') | Where-Object {$_.href -eq "DLNSHCTM02"}
    $link.click()

    The hyperlink to be clicked is as below:

    <A class=cold title='Data Center' href='Apps.asp?ID=13'>DLNSHCTM02</A>

    Friday, December 9, 2016 10:04 AM

Answers

  • You should do something like this - 

    $IE=new-object -com internetexplorer.application
    $IE.navigate2("http://appview.csfb.net/appview/")
    $IE.visible=$true
    $link = $ie.Document.getElementsByTagName('a') | ?{$_.textcontent -eq 'DLNSHCTM02'} 
    $link.click()

    Friday, December 9, 2016 12:15 PM