04-16-2015 02:20 PM
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
04-16-2015 02:36 PM - edited 04-16-2015 02:37 PM
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...
04-17-2015 09:06 PM
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
04-18-2015 12:32 PM - edited 04-18-2015 12:33 PM
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:
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.
04-22-2015 05:04 AM
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.