Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

click link with no ID + echo without popup

Status
Not open for further replies.

morphed

Technical User
Nov 8, 2012
7
0
0
GB
Hi all - I would really appreciate any advice you may have.
I don't know VBS atall - Everything I have done has been from googling and logic.

I have 2 things I want to achieve.

A) Click a link without an ID - this is what I have to work with:

Code:
</a></div>]

My script navigates to this page, fills in the information, submits, it now needs to click the dynamically assigned link to confirm the submission.

B) I'm calling my hostname using
Code:

Script navigates to the page and should write the hostname to a text field and then submit, im using Wscript.echo as above - I have a blank popupbox with a blank button, I click the button manually then the hostname writes to the field automatically and submits automatically.


Any idea on how to go about these two?

Many many thanks!
 
Code from above


The link:

<div class="error">TEXT<br /><br /><a href="?dynamic=link">[ submission ]</a></div>


The hostname

Set wshShell = WScript.CreateObject( "WScript.Shell" )
strComputerName = wshShell.ExpandEnvironmentStrings( "%COMPUTERNAME%" )



ie.Document.all("ELEMENTID").value = WScript.Echo & strComputerName
ie.document.forms(0).submit
 
This looks like a job more suited for javascript and jquery. VBS can do it but only if it is being run in a Windows Environment using IE (VBS is not supported in other browsers)

perhaps something like this:

Code:
set objIE = CreateObject( "InternetExplorer.Application" )
objIE.Navigate "[URL unfurl="true"]http://insert.url/here.html"[/URL]

do while objIE.Busy
	WScript.sleep 200
loop
    
set objAnchors = objIE.document.getElementsByTagName("a")

for each objLink in objAnchors
	if (objLink.innerHTML = "[ submission ]") then
		msgbox objLink.href
      end if
next


set objNetwork = CreateObject("WScript.Network")
strComputerName = objNetwork.ComputerName
objIE.document.getElementById("elementID").innerHTML = strComputerName

-Geates

 
I'm not 100% sure but I don't think you can "submit" a single field via the href of an anchor. I would think the webpage would need a form element with the action set to the appropriate link. Do you have control over these components?

Can you explain what your end goal is? Perhaps, there is an easier way.

-Geates

 
Thank you so much for your reply.

My Goal: Open up IE - got to a few pages, set some configuration options (2x forms) submit them and done.


Running on Windows, IE9 - script works perfectly apart from the above 2 issues - I can get an element added to the [submission] link if there isn't a work around that's not the end of the world, the problem is the random blank popup from echoing the computername.

Are we thinking a rewrite in JS is required?

many thanks
 
the problem is the random blank popup
get rid of WScript.Echo &

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
PHV is right. WScript.Echo is function to write to the screen (actually, .echo is the function, WScript is the library containing the .echo() function)

A rewrite in JS is not necessary as long as the script is run on a windows machine with IE.

Can you post the vbs and the html forms so we can put the peices together?

-Geates

 
Thanks - well don't I feel stupid - The echo issue is now sorted :)

My only issue now is clicking the [submission] link with no element id ect.

What I was thinking is this

Set wshShell = WScript.CreateObject( "WScript.Shell" )
strComputerName = wshShell.ExpandEnvironmentStrings( "%COMPUTERNAME%" )

Set stationid = Item.UserProperties.Find("input")

ie.Document.all("input").value = strComputerName
ie.document.forms(0).submit


'Wait for dispatch to load
Do While ie.Busy Or ie.ReadyState = 1
Loop

ie.Navigate2 submission

submission, being the link i need to click to re confirm the submissions.

I've declared it at the top like

override = "StrComputerName"&override=1"

That's not working (I imagine I can't just echo the StrComputerName that easily in the url?

Is there something stupid I am missing here? If so, and I can write the computername into the dynamic link - then we are away.

It's a bit messy but will do me perfectly :)

Again - thank you all so much.
 
Sorry, it's declared as submission and im using ie.navigate2 submission -
 
Thanks - I've just been looking at string concatenation and literally just tried that

submission = "mylink?action=save&input=" & StrComputerName & "&override=1"


Called by :


Set wshShell = WScript.CreateObject( "WScript.Shell" )
strComputerName = wshShell.ExpandEnvironmentStrings( "%COMPUTERNAME%" )

Set aninput = Item.UserProperties.Find("inputbox")

ie.Document.all("inputbox").value = strComputerName
ie.document.forms(0).submit


'Wait forload
Do While ie.Busy Or ie.ReadyState = 1
Loop

ie.Navigate2 submission


It navs to

mylink?action=save&input=&override=1

Where as I should see
mylink?action=save&input=myhostname&override=1

Any ideas?

Thanks
 
I've declared it at the top
You should set the value of submission AFTER strComputerName get its value !

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Working perfectly!!

Thank you so much guys - Appreciate it very much

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top