LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to "enter" a text field on a website that doesn't have an enter button?

Hi All,

I wanted to know I can press "enter" in a text field on a website that doesn't have an enter button.

I have used the following to help me code (i.e. login, enter values into fields).

 

https://decibel.ni.com/content/docs/DOC-25396

 

The above link helps but there isn't a submit on the website I am trying to access or in the code.

 

What has worked for me, but isn't the best solution, is to simulate a mouse click on the desired field, after text entry, then simulate the keyboard "pressing enter".  The problem with this is the mouse click depends on the position of the labview front panel. The code runs in the background and is also a subvi.

 

thanks in advance,

Jose

0 Kudos
Message 1 of 5
(5,586 Views)

I would suggest using the .NET browser instead of the ActiveX one, as it's more modern and easier to work with. I don't have a direct answer to your question, but I expect it should be possible by setting the value of the element.

 

There's a basic example which shows using the browser here (not for setting the value, but it shows you the concept and you can search other sites for what the .NET control allows) - http://forums.ni.com/t5/LabVIEW/Mouse-event-in-embedded-internet-explorer/m-p/2853440/highlight/true...


___________________
Try to take over the world!
0 Kudos
Message 2 of 5
(5,578 Views)

Hello tst,

 

I have used your example of .net.  I did also look online for sample login code, http://www.codingtiger.com/questions/c/trying-to-login-to-web-form-in-code..html

 

This one has a "setattribute"? I can't seem to find this in the .net for LabVIEW?

 

thanks,

J

0 Kudos
Message 3 of 5
(5,529 Views)

Well, if you look at the code, it drills into the document to call the method on a specific element inside the document:

 

webBrowser1.Document.All.GetElementsByName("j_username")[0].SetAttribute("Value", "************");

 

 

Similar LV code would look like this:

 

Example_VI_BD.png

 

You might also wish to use the GetElementByID method which is probably less affected by changes and allows you to skip the get_Item method.


___________________
Try to take over the world!
0 Kudos
Message 4 of 5
(5,503 Views)

Just a question/idea - but can you not just POST the data to the web server directly? Take a look at the HTML of the page and see if you can find the <form action="<THE URL TO POST TO>"> and then find all of the names of the form fields and send them along with the values via the HTTP Client POST VI.

 

It sounded to me like you are trying to push data into a web server so it shouldn't be necessary to render the page and fill out the fields on the rendered page if you can bypass all that and just submit the data and get the response.

 

If the form data is sent asynchronously (using AJAX), then you might need to delve a little into the site's javascript to find the POST URL and field names.

 

 


LabVIEW Champion, CLA, CLED, CTD
(blog)
Message 5 of 5
(5,464 Views)