value for select in Selenium IDE - selenium-ide

Is there a way to select an item based on the label containing a set of characters? I can't select by index as that will change, and the items being generated in the select have some random numbers appended at the end. I'd like the basically say if the label contains "this."
is that possible?
Thanks!

Sure, example in XPath:
//*[contains(text(), 'this')]
Or CSS:
select:contains('This')

Another example
<label for="blah">
<input name="blah" id="blah" type="checkbox" />
Store Locator Plus
</label>
My target to get the checkbox:
//label[contains(text(),'Store Locator Plus')]//input[#type="checkbox"]
To check it I use the command "check", the target noted above, and a value of "On", which forces the checkbox to be marked (versus using click which will toggle it on/off).

Related

How to render a Mask checkbox with Typo3 Fluid?

I've created a content element with Mask for Typo3 where the editor can select the payment options provided. In the fluid template however, an integer with a bitmask is returned and not each individual option.
The default rendering suggested by mask is:
{f:if(condition: data.tx_mask_ue_payment_accepted, then: 'On', else: 'Off')}
The result of data.tx_mask_ue_payment_accepted can vary from 0 (nothing selected) to 511 (all 9 options selected). Has anyone managed to smoothly implement the checkbox with a for-loop or anything proper and if so how?
Many thanks in advance!
I use bitmask in a couple of areas for my current FE plugin and haven't found a better way than to map the field-value-pairs in your controller action prior to displaying the form.
For this I implemented two methods which will convert the current bitmask value to individual boolean values (and vice versa). I bind those values to an array and display it in a fluid for loop as checkboxes (not using extbase direct property mapping).
Maybe this gets somebody in the right direction, even if its no copy&paste ready solution.
Fluid:
<input type="checkbox" name="tx_myext[checkbox][0]" value="1" id="checkbox0" class="checkbox" {f:if(condition:'{return.checkbox.0} == "1"',then:'checked="checked"',else:'')}>
<input type="checkbox" name="tx_myext[checkbox][1]" value="1" id="checkbox1" class="checkbox" {f:if(condition:'{return.checkbox.1} == "1"',then:'checked="checked"',else:'')}>
As you can see we get an array "return" back that contains the values from the transmitted form. If the values exists we set the checkbox to "checked".

HTML5 multi="true" tag doesn't work

i use Eclipse kepler
in dynamic web project
i create html(HTML5) file and use code for Multi select file upload system
<input type="file" multiple="true" />
but can't select multiple with ctrl+click
and my eclipse has warning
Multiple annotations found at this line :
-Undefined attribute value(true)
-Undefined attribute value(true)
any suggestion?
You need to use the attribute's name as its value:
If the attribute is present, its value must either be the empty string
or a value that is an ASCII case-insensitive match for the attribute's
canonical name, with no leading or trailing whitespace.
(http://www.w3.org/TR/html5/infrastructure.html#boolean-attributes)
In other words, just use:
<input type="file" multiple>
or
<input type="file" multiple="multiple">
If it does not work, then the reason is that you are using a browser that does not support the multiple attribute, such as IE 9. To deal with such browsers, you can add some JavaScript that tests whether the input element has the multiple property and if it does not, creates some additional file input elements (possibly in a loop that lets the user specify any number of files).
The warning should really be an error message, since true is not a valid value for the multiple attribute. As #IlmoEuro explains, the value should be empty or multiple. However, the value has in practice no impact; browsers recognize just the attribute name and ignore the value (even if you write multiple="false" for example).

Autofill input type="text" field from an external link

I have a link on one page which looks like this:
http://www.domain.com/sample-link#product_id
and on the other page (sample-link), I have this input field:
<input type="text" name="name" value="name" />
So, when I click the link from the first page, I want to open the "sample-link" page, and autofill the name field with the "product_id" text. Any ideas how can I make this?
Thanks in advance.
You'll just have to add a tiny Javascript snippet:
if (document.location.hash)
document.getElementById('testbox').value = decodeURIComponent(document.location.hash.substr(1));
For obvious reasons you'll have to adjust the id of the text box.
It gets a bit more complicated in case you'd like to pass more than one value.
The call to decodeURIComponent() is optional, but required in case you're passing characters like spaces or non-alphanumerical stuff (just to be sure).

How do I use Selenium in Perl to click a checkbox with a dynamic value next to a known string?

Here's some hastily-scrubbed sample source from my page:
<tr><td nowrap><input type="checkbox" name="enrollments" value="1478">meta</td></tr>
<tr><td nowrap><input type="checkbox" name="enrollments" value="565">admin</td></tr>
<tr><td nowrap><input type="checkbox" name="enrollments" value="566">system</td></tr>
Going into this I won't know what number is populated in the value slot for any of these as that changes each time, and the location of the element will not always be the same index within the list (e.g., 'admin' and 'system' might be in a different order), but I will know the string of text wrapped in the table element. Is there a trick to checking that box based on the string located right next to it using Selenium?
I'm thinking I need to find the text and have it return the index within the table so I can use that index to send a click. So far I have tried every way I could think of to verify and store the text but have not been able to see where it is sitting on that table.
You can search for td tag that contains the label that you need (admin, system, meta, ...) by xPath and take input tag.
for admin
//td[text()='admin']/input
for system
//td[text()='system']/input
for meta
//td[text()='meta']/input

can't select the YES option

How do i make Watir select a specific radio button? I have 4 radio buttons, and i want it to select the second one:
//this will select the first option
ie.radio(:name, "radio1").set()
I can even set the second option for another radio button doing the following (for a different radio button):
ie.radio(:value => '1').set
however, i have the following radio button:
<input type=radio name='myRadio' id='myRadio-0' value='0' tabindex=8 ><span class=smalll>0. No</span>
<input type=radio name='myRadio' id='myRadio-1' value='1' tabindex=8 ><span
class=smalll>1. Yes</span>
I want to select the the "YES" option here, but no matter what i try, i can't. How do i get around this? I've tried the following:
ie.radio(:value => '1').set
ie.radio(:name, "myRadio-1").set
ie.radio(:name, "myRadio").set
any ideas?
In your example you've used name twice, even though "myRadio-1" is the id of the element, not the name. If that was a typo just in this post and not in your actual code, I would assume that one of the two radio buttons not provided (of the four total) has a conflicting name/id, etc.
For HTML:
<input type=radio name='myRadio' id='myRadio-1' value='1' tabindex=8 >
I would use:
#browser.radio(:id => "myRadio-1").set
Typically radio buttons are in a group. In the examples I've seen, people set the one radio out of the group rather than focus on a radio button.