I am trying to set a value in my test to the input below which has a default value
<input type="text" name="ntsSellAmount" maxlength="7" size="8" tabindex="130" value="0.0">
It seems when I set the value in my Geb page it is appended to the default value 0.00300:
grossExTax {
$("#content > form:nth-child(3) > fieldset:nth-child(8) > table:nth-child(3) > tbody:nth-child(1) > tr:nth-child(10) > td:nth-child(2) > input:nth-child(1)")
}
grossExTax.value("300")
Is there a way to clear the field and then set the value overriding the default value 0.00
According to section 4.13.5 of the manual, what you're doing is right.
value('foo') should overwrite, whilst << should append.
They have an example at section 4.12 Form Control Shortcuts
Interacting with form controls (input, select etc.) is such a common task in web functional testing that Geb provides convenient shortcuts for common functions.
Geb supports the following shortcuts for dealing with form controls.
Consider the following HTML…
<form>
<input type="text" name="geb" value="testing" />
</form>
The value can be read and written via property notation…
$("form").geb == "testing"
$("form").geb = "goodness"
$("form").geb == "goodness"
These are literally shortcuts for…
$("form").find("input", name: "geb").value() == "testing"
$("form").find("input", name: "geb").value("goodness")
$("form").find("input", name: "geb").value() == "goodness"
With that in mind, have you tried: grossExTax.value = 300?
You may need to explicitly mention the page you are in before trying to set the value on the locator. Try something like below
at GrossExTaxPage // This is the Geb page object where you have defined the element
grossExTax.value("300")
Related
I'm using TestCafe and would like to determine if the checkbox element is present or not. In the HTML element, if the checkbox is already checked then the attribute checked exists otherwise not. How do I determine using TestCafe?
I used the function available in TestCafe - .hasAttribute('checked') but the return is undefined.
Here is the HTML code when the checkbox is checked:
<input class="jss1523" tabindex="-1" type="checkbox" data-indeterminate="false" value checked>
Here is the HTML code when the checkbox is unchecked:
<input class="jss1523" tabindex="-1" type="checkbox" data-indeterminate="false" value>
How do I solve this using TestCafe?
For every Dom element which you get with Selector() you can check property checked - https://devexpress.github.io/testcafe/documentation/test-api/selecting-page-elements/dom-node-state.html#members-specific-to-element-nodes
For checkboxes and radio inputs it returns Boolean value (true - if checked, otherwise - false) and for other types of elements return undefined
I want to dynamically set the input datetime step granularity using aurelia binding.
In my time.js:
timeStep = "1";
In my time.html:
The following works correctly:
<input type=datetime-local value="2017-01-01T00:00:00" step="1" value.bind="formParameters.timeFrom" >
${timeStep}
However when I try to set the step using my variable - it doesn't seem to work:
<input type=datetime-local value="2017-01-01T00:00:00" step="timeStep" value.bind="formParameters.timeFrom" >
${timeStep}
You can see I have lost the seconds granularity. When I inspect the element, it comes out as:
<input type="datetime-local" value="2017-01-01T00:00:00" step="timeStep" value.bind="formParameters.timeFrom" class="au-target" au-target-id="37">
Where timeStep should be "1".
To bind any HTML attribute to a property in your viewModel - you need to use .bind.
<input type=datetime-local value="2017-01-01T00:00:00" step.bind="timeStep" value.bind="formParameters.timeFrom">
Aurelia will assume anything in a .bind attribute is a property of your viewModel class and bind them accordingly. You can use .bind on any (as far as I know) HTML attribute.
Using can 2.2 : I'm having trouble getting a radio input field to be checked by default when also using the can-value attribute.
The relevant part of the stache template looks like this:
<input type="radio" name="visibility" value="corporate" can-value="reportData.visibility" checked="checked"/>
The relevant part of my viewModel looks like this:
can.Map.extend({
reportData = {
visibility: 'corporate',
}
});
I want the input value to be live-bound to my view model. According to the can 2.2 docs, I can use the can-value attribute on an input to reference a property on my view model and keep it in sync with the value of the input's value. My problem is the checked="checked" doesn't result in the input being checked by default, though the value on the input item (corporate) is being correctly live-bound. If I remove the can-value attribute, the check appears by default. How can I get both live-binding and a checked input by default with the help of can-value?
I have 2 forms that I am testing using TestStack.Seleno. Both forms have a checkbox that is mandatory. The first form has (including the checkbox) 5 fields. I can use TestStack.Seleno to create a passing test with valid data. I set the checkbox like this:
Input.TickCheckbox(f=>f.Accept,form.Accept);
On my other form which has 10 or so fields, when I try to set the checkbox to be ticked (using the same code) nothing happens. However when I try
var acceptCheckBox = Find.Element(By.Name("Accept"),new TimeSpan(0,0,0,50));
if (form.Accept)
{
acceptCheckBox.Click();
}
I get error "Element is not currently visible and so may not be interacted with"
Element is clearly visible and is not injected in using javascript.
I am using latest version of TestStack.Seleno from github.
Any ideas?
So I have managed to figure out what the issue is and have a work around, however I cannot explain why it works on the other form. The mandatory Accept field has html generated by mvc that looks like
<div>
<input class="check-box" data-val="true" data-val-mustbetrue="The Accept our field is required" data-val-required="The Accept our field is required." id="Accept" name="Accept" type="checkbox" value="true"><input name="Accept" type="hidden" value="false">
<label for="Accept">
Accept our Please accept our Terms and Conditions
</label>
<span class="field-validation-valid" data-valmsg-for="Accept" data-valmsg-replace="true"></span>
</div>
So you have the checkbox and hidden field both with id Accept, I suspect in code seleno is picking up the hidden field and setting value, so I updated my code todo
var acceptCheckBox = Find.Element(By.CssSelector("#Accept.check-box"));
acceptCheckBox.Click();
Now everything works.
Ismail
I want to show a popup dialog containing a dijit.ComboBox with data populated using ajax request or data store.
The problem I am facing is that the combobox is always disabled.
My selected code is:
<div dojoType="dojo.data.ItemFileReadStore" id="osTypeStore" data-dojo-id="osTypeStore" url="/AjaxPopulateOS.json">
</div>
<select id="osType" data-dojo-type="dijit.form.ComboBox"
data-dojo-props="
id:'osType',
store: osTypeStore,
placeHolder: 'Select a schdule type'" >
</select>
Any ideas
I believe it is because there are no items in it? Is it grayed out totally - and have the Disabled class parameter set?
Check that dijit.byId('osTypeStore') returns a store and that it has items in it.
If this is the case, change your code to
store: 'osTypeStore'
Note the quotes. This forces parser to evaluate the string into a dijit - and the store might not have been initialized correctly as a true variable at the point it is read. In other words, in combobox constructor - the javascript variable is undefined.
If this does not help, try forcing to set store after onShow has run for your dialog.
dialog.onShow = function() {
dijit.byId('osType').set('store', dijit.byId('osTypeStore'));
}
Try forcing it to enabled using the property of the combo
enabled: true,
Other than that, check it using Firebug or debug bar or something similar :)