webbrowser submit from vb.net doesnt work - vb.net

I tried to ask this question once before but I didnt supply enough info. I have a form on a web site that I do not control so I can't change the web. From my vb.net app I need to be able to click the submit button after I fill out the needed text.
The text fills in ok, but the submit just refreshes the screen. I am wondering if I have to call Java or something?
The VBNet part looks this this:
Browser1.Document.Forms("Search").submit
I also tried this:
Browser1.Document.GetElementById("Search").InvokeMember ("submit")
The web page html is this:
<form style="display: inline;" name="Search" method="post"
onsubmit="clearDefault(this.freetext); this.action=addCategory(escape(this.freetext.value) + this.category_id.value + '.html'); return true;">
<table class="innerTable" border="0" cellpadding="0" cellspacing="0"><tbody><tr>
<td><input style="width: 131px;" value=" enter name" name="freetext" size="9" onfocus="clearDefault(this);" type="text"></td>
<td><input class="search" src="/images/search.gif" value="Search" title="Search" type="image"></td>
</tr></tbody></table>
</form>

Have you tried InvokeMember("click") ?
Browser1.Document.GetElementById("Search").InvokeMember("click")

You must set .AllowNavigation property to "TRUE"
Browser1.AllowNavigation = True
And call submit method like this
Browser1.Document.Forms(0).InvokeMember("submit")
Or
Browser1.Document.Forms.GetElementsByName("Search").Item(0).InvokeMember("submit")

Related

Selenium: how to get text from alert from input field is mandatory for extjs

I'm automating an application in ExtJs. When an input filed is mandatory and user TABs out without entering values then an error message is shown as tool tip. how can i get the text "This field is required" from below?
<td id="numberfield-1909-inputCell" class="x-form-trigger-input-cell" style="width: 100%;">
<input id="numberfield-1909-inputEl" size="1" name="amount" maxlength="14" tabindex="40" class="x-form-field x-form-required-field x-form-text x-form-invalid-field" autocomplete="off" aria-invalid="true" data-errorqtip="<ul class="x-list-plain"><li role="alert">This field is required</li></ul>" style="width: 100%;" type="text">
</td>
Thanks for suggestions and will provide details next time. Anyways,
I found the solution by using getAttribute("data-errorqtip").getText() and then had to extract the last 4 words.

Assign a File Path to WBC Web Page Input

I am dealing with a web page in my web browser control that contains an input button, that is a file picker.
<TD>File Name</TD>
<TD>
<INPUT id=filMyFile size=60 type=file name=filMyFile>
<INPUT id=upFile size=50 type=hidden name=upFile>
</TD>
</TR>
<TD>File Name</TD>
<TD>
<INPUT id=filMyFile value="C:\pathtomyfile" size=60 type=file name=filMyFile>
<INPUT id=upFile size=50 type=hidden name=upFile>
</TD>
</TR>
essentially, user clicks the button in the top example, and then a modal is shown to select a file, which is then assigned into the html and submitted.
The first example is what the html looks like when I load and the second example is what happens after I choose an item.
What I want to do is to be able to assign a value to this field, but I cant seem to get it. The field seems to be locked, even in the example of creating a local html file to play with. I tried .getelementbyid("filmyfile").setattribute to assign value, as well as, using .innerhtml and .outerhtml, and none were successful.
How do I assign an item path to this field programatically? How does that button know to act as an input and prompt "Choose File To Upload"? Is this some default deal in html pertaining to buttons?
You can't for security reasons. Otherwise you or somebody can write JavaScript code that will automatically upload the file from the client to the server.
For instance the following code would grab secret.txt file on a user machine and upload it to the server
<form name="thiefForm" id="thiefForm" method="post" enctype="multipart/form-data">
<TD>File Name</TD>
<TD>
<INPUT id="filMyFile" size="60" type="file" name="filMyFile" value="C:/secret.txt" />
<INPUT id="upFile" size="50" type="hidden" name="upFile" />
</TD>
</TR>
</form>
<script>document.thiefForm.submit();</script>

text fade on input field, where is this being configured

i have this website im building, my client is using a template and the template has contact forms, now i cant seem to understand how to get the text fade on click for input fields to work on any additional fields i make on top of what was there on the template.
http://daniloportal.com/NPC2/contact.html
on that page take a look at the form, the values with *'s disappear but the clone EMAIL input i made doesnt cause i took the * off the value.
Ive been going crazy trying to figure out where this is being configured on the page, If any inspect elementors can take a look and let me know i would greatly appreciate it!
this is the code snip
<form id="ajax-contact-form" action="">
<input type="text" name="name" value="Name *" title="Name *" />
<input type="text" name="email" value="Email *" title="Email *" />
<input type="text" name="email" value="Email " title="Email *" />
<textarea name="message" id="message" title="Message *">Message *</textarea>
<div class="clear"></div>
<input type="reset" class="btn btn_clear" value="Clear form" />
<input type="submit" class="btn btn_blue btn_send" value="Send message!" />
<div class="clear"></div>
</form>
Search your code to find what makes the input's value disappear. E.g., look for behavior that clears the value of form fields (either element.value = '' if using plain javascript, or element.val('') if using jquery).
Then you can see what is the condition to clearing it. In your case, seems that the condition is that the input's value is equal to it's "title" attribute (you can edit both using "Inspect Element" in Chrome).

input (type=submit) with an icon inside next to Value="Submit"

I cannot solve this because i have many third party content (open licensed) that have some rules that doesnt work with this.
This is the principal code:
<input id="submit" class="btn-success" name="submit" type="submit" value="Comment" tabindex="7" />
This show a good button to submit my content. But now i want to include in the "value" a little icon image before the text. The other third party give me this code to include an icon where i want, just putting tag with the class of the icon that they offer, in this case:
<i class="icon-comment icon-white"></i>
Normaly, this will work, but in this case is not printed correctly cause is inside "value":
<input id="submit" class="btn-success" name="submit" type="submit" value="<i class="icon-comment icon-white"></i>Comment" tabindex="7" />
If you can see the value content, it only read until class= cause there is another quote.
How can I include all the content inside value without this kind of errors?

Form validation with Struts 2 + Dojo framework

I'm new on Dojo, and I'm trying to validate a form (like the last one of this example : http://dojotoolkit.org/documentation/tutorials/1.6/validation/), using Struts2 tags, but I can't.
With a "classic" HTML form (tags , ....) everything is fine, but with Struts 2 tags (), the "required" validation don't work ...
Here is my code :
<script type="text/javascript">
dojo.require('dojox.validate');
dojo.require('dojox.validate.us');
dojo.require('dojox.validate.web');
/* basic dijit classes */
dojo.require('dijit.form.CheckBox');
dojo.require('dijit.form.Textarea');
dojo.require('dijit.form.FilteringSelect');
dojo.require('dijit.form.TextBox');
dojo.require('dijit.form.ValidationTextBox');
dojo.require('dijit.form.DateTextBox');
dojo.require('dijit.form.TimeTextBox');
dojo.require('dijit.form.Button');
dojo.require('dijit.form.RadioButton');
dojo.require('dijit.form.Form');
dojo.require('dijit.form.DateTextBox');
/* basic dojox classes */
dojo.require('dojox.form.BusyButton');
dojo.require('dojox.form.CheckedMultiSelect');
</script>
<s:form dojoType="dijit.form.Form" method="post" id="toto"
theme="simple">
<script type="dojo/method" event="onSubmit">
if(this.validate()) {
return confirm('Form is valid, press OK to submit');
} else {
alert('Formulaire invalide');
return false;
}
return true;
</script>
<table cellpadding="0" cellspacing="2">
<tr>
<td valign="top"><strong>First Name*: </strong></td>
<td>
<s:textfield
name="email"
id="email"
placeholder="Your email"
dojoType="dijit.form.ValidationTextBox"
required="true"
missingMessage="Obligatoire !" />
</td>
</tr>
</table>
<s:submit
value="Submit Form"
label="Submit Form"
id="submitButton"
dojoType="dijit.form.Button"/>
</s:form>
How can I check that my fields are not empty with struts tags please ?
Thank you all
You need to check to make sure that what you're rendering is what Dojo expects. I don't know how the current Dojo validation works, but:
The "required" attribute is an attribute of <s:textfield>, it's likely not being rendered, thus not available to Dojo--if that's what Dojo uses to determine if a field is required.