Name Arrtibute's functionality - input

How does the "name" attribute works within an input tag (radio type)?
I need to know how does it specify an option from the radio type, in other words how it works.

Related

Using Selenium keywords to find if any text is in the Element

I know that there is the following keyword to find if particular text is in the Element:
Element Should Contain <xpath> <text>
But I just want to find if the Element contains any text.
Do I have to use a different keyword or can I use some kind of wildcard for any text?
i.e. Will this be possible?
Element Should Contain <xpath> *
Define what should satisfy "any text" - will an empty string also qualify? If so, you can do Page Should Contain Element - it will pass if it's in the page, regardless what its text is.
You could also get the text, and validate it any way you like:
${txt} Get Text <xpath>
Should Not Be Empty ${txt} # etc

Contains CSS Selector to fill a form with nightwatch / selenium

My Problem:
The Page I try to test with NightwatchJS Contains Some Input Fields that have the Same beginning, but a random number is added. I want to Fill the Textfield on the page. Only one with this name is present on the same time.
<input id="groupNamec7aed06a-67a1-4780-9cc3-5b985666adb9" class="d-styled-input" data-value-update="keyup" data-bind="value: name" title="">
Is the definition of the Field. groupName is every Time the same, but the number changes.
Is there a possibility to use CSS Selector in nightwatch instead of XPATH?
You can try this way :
input[id^="groupName"]
From MDN > Attribute selectors :
[attr^=value] : Represents an element with an attribute name of attr and whose first value is prefixed by "value".
Unfortunately CSS Selector does not provide such a way. You could use a different CSS Selector to match inputs with an id and get those as a list. Afterwards using getAttribute('id') you could do it manually, but this seems like unnecessary effort to me and I'd recommend just using Xpath.
Ofcourse you could try and get a different unique CSS Selector. If it's in a form you could locate the form and use :nth-child but if I remember correctly this has limited/no support in IE.
Edit Apparently IE9 and later does support :nth-child

selenium can't test text color

Hello I am trying to check if the color of an input is red.(Selenium IDE 1.9 Firefox Plugin)
If i select it with
<td>verifyAttribute</td>
<td>id=focus_me</td>
<td>*color=red*</td>
the "Find" button works, but there is no attribute selected to check.
if i change it to
<td>verifyAttribute</td>
<td>id=focus_me#color</td>
<td>*color=red*</td>
the element is not found, so how do i use it ?
Assuming we are talking about color as a style, your HTML probably looks something like:
<span id="custom1" style="color:red;">Custom Attribute 1</span>
As you can see 'color' is not an attribute. It is part of the value of the 'style' attribute.
So what you want do is verify that the 'style' attribute contains the 'color:red':
<td>verifyAttribute</td>
<td>id=focus_me#style</td>
<td>*color:*red*</td>
Note that the asterisk (*) are wildcards. They have been added in case there is another style property before or after the one of interest. One was also added between the color and red since sometimes people puts spaces and sometimes not.

how to combine html:text and bean:write

I am using <bean:write/> tag in my struts program to catch my data into text field but I want to update/edit those data which is coming by this tag so I want to use <html:text/> tag with <bean:write/>, is it possible?
is there any other option to update <bean:write/> tag's data.
I am using this tag like -
<bean:write name="Customer" property="lastname"/>
It's not entirely clear to me what you want to update, and under what circumstances.
If you're saying to want to have the customer's last name be an editable text field, then initialize the ActionForm with the appropriate values before displaying it to the user; you don't need the <bean:write> tag at all if you're just trying to initialize/show a form field.

Refining my Dojo/Dijit NumberTextBox numeric validation

I have the following code:
<input type="text" dojoType="dijit.form.NumberTextBox" size=8
constraints="{min:0,max:100000,places:0}"
id="orgNumberOfStudents" name="orgNumberOfStudents"
required="true" invalidMessage="Integer between 0 and 100,000"
value="">
Questions:
1) How do I set the width of the box? Do I have to do it in a style tag or a CSS? Is the traditional "input size" tag ignored?
2) The above sample shows the error when I type in a non-numeric value. But if I tab over the field and don't fill in anything, it's still blank. Is there a quick way to enforce the validation when I click the submit button? Do I need a Dijit submitt button? Do I need to write more JavaScript to make this happen? How does the required="true" actually occur?
(One get-around is to set the value to 0, but I'd rather force the user enter a value rather than just defaulting it).
Thanks,
Neal Walters
You should be able to use both CSS and traditional INPUT attributes like "maxLength" on your NumberTextBox by passing them in to the Widget's constructor. maxLength is available on all dijit.form.TextBox subclasses, but is probably less useful here since you have control over things like min/max and the actual number format.
Yes, you can always write your own JS to test "isValid()" on your widget instance before submission, e.g. in an HTML FORM onSubmit handler, or you could use dijit.form.Form which will check validity for you. The widget itself is only responsible for visual representation of its own validity, according to the options chosen.
HTH