Storm00551
Storm00551

Reputation: 11

Powershell - How to select and click hyperlink in firefox

I am trying to find, select and click on a specific Hyperlink in Firefox using Powershell.

I have been able to find all the Hyperlinks available through .Links I am unsure of how to select the one that I want and how to click on it.

$azr = Invoke-WebRequest -uri "https://Website/" -SessionVariable sbv
$sbv
$azr.Links

This is for a typing test website. There is a link that says start typing test, and that's what I'm trying to click on. I'm just not sure of how to select that within all of the HTML that is produced with .Links and how to click on it.

Upvotes: 1

Views: 469

Answers (1)

postanote
postanote

Reputation: 16096

What you are calling though is not using a browser at all.

In a browser, this is a very common thing and well documented and asked about. So, your query could be viewed as a duplicate of this and it's accepted answer.

Click a hyperlink using powershell

$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()

Now, the above is for IE, so, you'd do the same thing for another browser.

With Invoke-WebRequest, then the discussion and sample here:

Teaching PowerShell to Click

Upvotes: 1

Related Questions