I've just found a proxy somewhere and applied to my code, seem to be successful. But when it comes down to submit("btnG"), I got an syntax error SyntaxError:
syntax error (httpunit; line 155)
at org.mozilla.javascript.NativeGlobal.constructError(NativeGlobal.java:597)
at org.mozilla.javascript.TokenStream.reportSyntaxError(TokenStream.java:1324)...
Submit from net.sourceforge.jwebunit.junit.WebTestCase is deprecated, so if this is what you are trying to use then you will have some issues
public void submit()
Deprecated.
Submit form - default submit button will be used (unnamed submit button, or named button if there is only one on the form.
submit
public void submit(String buttonName)
Deprecated.
Submit form by pressing named button.
Parameters:
buttonName - Submit button name attribut value.
submit
public void submit(String buttonName, String buttonValue)
Deprecated.
Submit the form by pressing the named button with the given value (label). Useful if you have more than one submit button with same name.
Parameters:
buttonName - Submit button name attribut value.
buttonValue - Submit button value attribut value.
Related
Some context:
AngularJS 1.4
Bootstrap 3.3.7
I'm using Bootstrap tabs navigation and panels inside a form.
Inside each panel I have an input that is required.
The default validation is not able to focus (change the active tab) and show the error message after the validation.
(console.log):
An invalid form control with name='' is not focusable.
A lot of "solutions" mention to remove the required attribute (from the hidden inputs) but that is not what I want because I need to have all inputs validated.
I tried to use ngModel validators but I'm not sure if it's a valid path for what I need.
What I'm trying to achieve is to be able to check the input's value and if invalid show it's tab, upon form submit.
Thank you.
[Solution found!]
Controller:
$scope.tabsValidation = form => {
let first = jQuery(`form[name="${form.$name}"] input.ng-invalid`).closest('.tab-pane');
let firstID = first.attr('id');
jQuery('.nav a[data-target="#' + firstID + '"]').tab('show');
};
View (form):
<button class="btn" type="submit" ng-click="tabsValidation(formName)">
Submit
</button>
From what I understand, the ng-click its executed before the actual form submit/validation.
How to make the html input field allow to be blank, when i click the submit button on the form view?
the idea is when I click the submit button, the input is a must to key in something else the behind code is unable to run, I am using the asp.net and the button is the asp button not html button
http://s15.postimg.org/wtl7xtuyx/myinputpic.png
I want to allow the new password can be blank
If clearing fields is what you want, use .reset() method.
document.getElementById("YourFormName").reset();
A working fiddle here:
https://jsfiddle.net/4fpk2z9o/
I may comprehend it wrongly as I do not really understand what do you want.
Update (To disable html 5 form validation) :
Add novalidate='' or <form action="yourform.asp" novalidate> to your form.
I have a question about making input fields required before being able to click a input button (not submit button). My code below only will send out the requirement notice after a submit button is click.
I have my form split into 3 div's with 'next' buttons in between which conditionally displays the next div. How do I make the input field to be required before the 'next' button brings up the next div portion of my form?
You should post the html for your question. It is missing. That being said, look into the blur event that gets trigger everytime an input loses focus. You could add the logic to display an error to the user and disable the next button.
http://www.w3schools.com/jquery/event_blur.asp
You have two main options:
FIRST OPTION
You could disable your button like so: <input id="but" type="button" disabled>, and then, you could set your field onchange method to enable the button i. e. <input type="text" onchange="changed();"> and in your script,
function changed(){
if(1 == 1){ // custom test
document.getElementById("but").disabled = false;
}
}
SECOND OPTION
In your button handler, verify your textfield is filled i. e.
function butHandler(){
if(document.getElementById("textfield").value !== "") {
// do your actions
}
}
yes, it does.
Is this any where documented?
Background: with my RoR Helper I made an error and created Links with data-method='GET'. Everthing still worked, only that I got a "Resend Data Warning" when refreshing the page ...
Now I found this strange behavior: data-method='GET'
Works with FF, IE, Chrome
Is this a standard? if yes it makes the Rails button_to (with all the form around) obsolette ...
edit: I forgott to say: _method is made out of data-method and this is as data posted, if i change the 'GET' to a - lets say 'PUT' I get RoR routing errors
an other edit: OK, I try too explain with a better example:
the following line
"<a data-method='PUT' href='?'>post</a>"
creates a POST request with _method='PUT' as data
no it is not a standard, as long as you say that RAILS Jquery_ujs.js is not a standard.
Rails/Jquery is doing this Magic:
if you take a look here all the magic is gone ...:
$.rails = rails = {
// Link elements bound by jquery-ujs
linkClickSelector: 'a[data-confirm], a[data-method], a[data-remote], a[data-disable-with], a[data-disable]',
// Button elements bound by jquery-ujs
buttonClickSelector: 'button[data-remote], button[data-confirm]',
// Select elements bound by jquery-ujs
inputChangeSelector: 'select[data-remote], input[data-remote], textarea[data-remote]',
// Form elements bound by jquery-ujs
formSubmitSelector: 'form',
// Form input elements bound by jquery-ujs
formInputClickSelector: 'form input[type=submit], form input[type=image], form button[type=submit], form button:not([type])',
// Form input elements disabled during form submission
disableSelector: 'input[data-disable-with]:enabled, button[data-disable-with]:enabled, textarea[data-disable-with]:enabled, input[data-disable]:enabled, button[data-disable]:enabled, textarea[data-disable]:enabled',
// Form input elements re-enabled after form submission
enableSelector: 'input[data-disable-with]:disabled, button[data-disable-with]:disabled, textarea[data-disable-with]:disabled, input[data-disable]:disabled, button[data-disable]:disabled, textarea[data-disable]:disabled',
// Form required input elements
requiredInputSelector: 'input[name][required]:not([disabled]),textarea[name][required]:not([disabled])',
// Form file input elements
fileInputSelector: 'input[type=file]',
// Link onClick disable selector with possible reenable after remote submission
linkDisableSelector: 'a[data-disable-with], a[data-disable]',
// Button onClick disable selector with possible reenable after remote submission
buttonDisableSelector: 'button[data-remote][data-disable-with], button[data-remote][data-disable]',
ENV
chrome 32 webdriver2.8
I am using selenium(java) to click a submit input. But I need to click twice to active the submit operation.
The input code:
<input type="submit" disabled="disabled" id="id_submit" name="submit" class="btn-txt" value="OK">
NOT WORK selenium code:
if(submitButton.isEnabled()) {
new Actions(driver).moveToElement(submitButton).perform();
submitButton.click(); // this sentence is executed.
}
WORKS
submitButton.click();
submitButton.click();
Well, the first click function seems to make the button get focus, and the second click function active submit operation. When I use moveToElement to focus the button first, the click not work either. I can ensure that the button is enabled. I want to use selenium to click button and I dont want to do click twice. What should I do? Any ideas? Thanks.
EDIT
WORKS EITHER
JavascriptExecutor jse = (JavascriptExecutor) driver;
jse.executeScript("document.getElementById('id_submit').focus();");
jse.executeScript("document.getElementById('id_submit').click();");
UPDATE
Imagine that I want to input a string, say "abcdef123456". Then send_keys is executed. It looks like
and submit button is enabled. After click the submit button at the first time. It looks like and submit button get focus. After click the submit button at the second time, the form is submited and page is redirected. I am confusing about the first click.
have you tried with Expected Conditions class,
new WebDriverWait(driver,30).until(ExpectedConditions.elementToBeClickable(By.id("id_submit"))).click();
It can solved like:
driver.sendkeys("abc1234"); (input in text box)
//explicit wait
WebDriverWait w = new WebDriverWait(driver, 10);
w.until(ExpectedConditions.elementToBeClickable(By.id("Button")));
or
w.until(ExpectedConditions.visibilityOf((WebElement) By.id("Button")));
driver.findElement(By.id("Button")).click();