Automate web page

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…

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

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.:slight_smile:

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…

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: (:slight_smile: , MethodException
    • FullyQualifiedErrorId : MethodCountCouldNotFindBest

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.