Hey.
I'm writing powershell script that simulates actions performed by user on the page.
I have a problem with performing click on a button. Page has form and inside button that saves changes to database:
input type="button" onClick="__doPostBack('someIdentifier','SAVE')" value="Save changes"
I need to invoke that from the client side. Problem is that button it self has id="" and tag="" so the following doesn't work:
$ie = new-object -com "InternetExplorer.Application";
$ie.visible = $true;
$ie.navigate("http://myTestedPage.com");
$doc = $ie.Document;
#doesn't work
$save = $doc.getElementByID("")
#doesn't work neither
$save = $doc.getElementsByTagName("");
#so how to call
$save.click();
both getElementbyID and getElementsByTagName just perform some operations but only effect they have is my CPU usage jumping to max.
I was thinking about getting elements[]
of the form and finding button there but it doesn't neither (effects like in previous case).
Is there some other (brilliant) way to do that (that obviously I'm not aware of)? I would need something like InvokeScript
webBrowser = new System.Windows.Forms.WebBrowser()
webBrowser.Document.InvokeScript(@"__doPostBack", new object[] {@"someIdentifier", @"SAVE"});
but I need to use instance of IE manipulated by powershell (or other scripting/programming language, maybe VBScript?), not .NET standalone app.