Automate web page

This topic contains 5 replies, has 4 voices, and was last updated by  Kirt Carson 4 years ago.

  • Author
    Posts
  • #10088

    shanu
    Participant

    Hi All,

    Today I am stuck up with a new task where I need to access a url.
    The url redirects me to a webpage where I have two input boxes and a submit button.
    After inputting values I need to click on submit then I get a text string on the webpage.I need to capture that for my task.
    Have gone through invoke-uri but got few errors in it.Any solution with simple example can help me out..

  • #10089

    Richard Siddaway
    Moderator

    have you looked at the help file for Invoke-WebRequest ?
    It has an example that might help you

  • #10090

    shanu
    Participant

    Hi Richard,
    Worked out few things with sample examples. Yet I thought we can share knowledge on real time exposure.
    Anyways Got my solution through magazine on microsoft site only.:)

  • #10092

    Dhandapani K
    Participant

    why don't you share you command or script which you used to solve the issue. so that I can improve my knowledge. thanks in advance....

  • #10103

    shanu
    Participant

    Am new to powershell automation. I was trying to use the following code for my task
    PS C:\> $ie = new-object -com "InternetExplorer.Application"
    PS C:\> $ie.navigate("http://servername/somelocation/Default.aspx")
    PS C:\> $ie.visible = $true
    PS C:\> $doc = $ie.document
    PS C:\> $tb1 = $doc.getElementByID("TextBox1") ##Here i got error as below
    Cannot find an overload for "getElementById" and the argument count: "1".
    At line:1 char:27
    + $tb1 = $doc.getElementByID <<<< ("Textbox1") + CategoryInfo : NotSpecified: (:) [], MethodException + FullyQualifiedErrorId : MethodCountCouldNotFindBest

  • #10891

    Kirt Carson
    Participant

    Look at this. There maybe more than one element named Textbox1

    $doc.documentelement.all|?{$_.src -match "Textbox1"}

    Keep in mind you may receive an array of elements with the same name Textbox1 so handle as array to start.. Single row array logic the same as many row array logic, but not the same at all as single string logic.

You must be logged in to reply to this topic.