1

Powershell noob here, it seems like this should be easy but I can't figure it out. I'm trying to have my script click on a login button on the home page of a brokerage:

$login = Invoke-Webrequest -uri http://www.foliofn.com -sessionvariable fol
$login.links

The third link is the login button, which when clicked brings up the login form:

innerHTML : <I class=icon-lock></I>Login 
innerText : Login 
outerHTML : <A class="btn btn-small headerloginlink" href="/servlets/ProcessAction?identifier=loginFormEntry&amp;click1=Login"><I class=icon-lock></I>Login </A>
outerText : Login 
tagName   : A
class     : btn btn-small headerloginlink
href      : /servlets/ProcessAction?identifier=loginFormEntry&amp;click1=Login

How do I "click" this using the invoke-webrequest method? Do I need to post somehow (although this is not a form, just a link).

I know I can do it using ie.document.getelementsbyTagName to select this element and then use click(), but I can't figure out how to do it in V3 without using DOM (if that's the right way to say it).

2
  • You could call invoke-request with the uri foliofn.com and append the href of the link/button. Commented Sep 26, 2013 at 1:40
  • That's it! Works great and is nice and simple, thanks. Commented Sep 26, 2013 at 14:00

1 Answer 1

1

You can try the module AutoBrowse. It contains commands to make this sort of interaction with IE more scriptable. Here's a sample of it logging into xbox live.

# Autobrowse can make automatically logging into a site simple and easy.  
# This simple pipeline logs someone into xbox (assuming $liveId and $password are set)
$ie = Open-Browser -Url http://xbox.com -Visible|
    Invoke-BrowserControl -Name RpsSignInLink -Click |
    Set-BrowserControl -Name login -Value $liveId | 
    Set-BrowserControl -Name passwd -Value $password | 
    Invoke-BrowserControl -Name SI -Click 

# Once we're in, let's check out recent activity    
$ie | Set-BrowserLocation -Url http://live.xbox.com/en-US/Activity
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.