Protractor clear a dropdown - protractor

While executing protractor tests, I would like to clear a dropdown. I know how to select a particular option in dropdown. How can it be cleared?
The dropdown is part of a form. The values of the options for dropdown are loaded with an ajax call. So, the select looks something like this.
<select>
<option>First Value</option>
<option>Second Value</option>
<select>
Now, when the form is loaded, no value is selected. But, as soon as a value is selected it is not possible to clear it (even manually) as this is a mandatory field. It is only possible to select an alternate value from the dropdown.
However, I would like to do a second test, which checks if the value of this field is blank (no selection). For this I have to clear the dropdown. Does protractor provide a way?
Let's say I can't change the order of tests for some reason.
Currently, I reload the entire form in order to clear the dropdown.

If the dropdown cannot be typed into, the only way to clear a dropdown using Protractor is to have an option in your dropdown that acts as a default selection before a user has selected 'First Value' or 'Second Value. This can be a blank option as well, like you desire
Something like this:
<select>
<option></option>
<option>First Value</option>
<option>Second Value</option>
</select>
And then select the first option via
element.all(by.tagName('option')).get(0).click();
This should get you the desired effect. Let me know if this helps!

Related

How to separate option values and text in drop-down form control?

Editing a simple (so far) form in Kentico 11. I am creating a drop-down. All I want to do is to have the value of each rendered option and the visible text of each option be different, like this:
<option value="CatalogNumber">Product name</option>
so that when I refer to the Value property of the drop-down I get the (in this case) CatalogNumber, but the user sees the product name. This is surely something people do every day, but I can not find anything in the doc, or on DevNet, explaining how to do it. Am I missing something so obvious that no one finds it necessary to mention?

wicket dropdown choice getting reset to "choose one" on validation error

I have a dropdown list with few rows in a table. All the dropdown are required fields. if none of the dropdown list has been selected and a user select only one dropdown and tries to save. A validation error is thrown which is correct, the problem is the value for the selected dropdown choice gets reset to "Choose one". how can i correct that?
Wicket uses the IChoiceRenderer#getIdValue() to find the selected option. If you do not provide custom IChoiceRenderer then Wicket will use ChoiceRenderer and as an id it will use the index of the item in the List of options.
See the usages of #equals() at https://github.com/apache/wicket/blob/7bef3d67c8ccc269f02e8943bf9a22c3cd5438e9/wicket-core/src/main/java/org/apache/wicket/markup/html/form/AbstractSingleSelectChoice.java. Even better fire the debugger and see what happens!

Make uib-typeahead behave like a select or format a select like uib-typehead?

is it possible to make a uib-typeahead behave like a dropdown select ?
I like the style of uib-typeahead when you use typeahead-min-length="0", and when you just click the text input you get all the possible options, so this kind of does what I want...
However, once you selected a first option, and you want to try another one, to get back the full list of options, you need to remove all the text from the input field first... whereas I would like to get it just by clicking the field.
So I would like to always get the full options list whatever text is already input... I know this is a bit against the idea of 'typeahead' if the tool doesn't care what you 'type ahead' ;)...
Another option would be to try and style a select with ng-options to look the same as uib-typeahead but I've read that it was not possible because the select dropdown list was a browser buitlin component. (is that correct?)
Any idea? Many thanks!

Remove "empty" selection from dropdown list box

When creating a form in Orbeon Form Builder, you can define a list of values for a dropdown list box.
When running the form in form runner, is it possible to remove the "[Select...]" value from this dropdown list box?
I would like to restrict the possible values only to the given ones and restricting the user from selecting an "[Select...]" value when filling in the form. I hope you understand what I mean :)
Here is a screenshot
It's not possible without changes to Orbeon Forms to remove the empty option.
The best way to achieve what you want is to make the field required. When that's the case, the user will have to select a value or validation won't pass.
(The rationale for adding/keeping an empty option at the top is to force the user to make a selection. Otherwise it is possible that users might not even look at the option selected by default, and involuntarily select an incorrect option.)

Symfony2 DOMCrawler - How to select second option of a select tag

I'm trying to select the second option in a <select> tag with the DOMCcrawler. First of all, I select the second form in the page:
$form = $DOMCrawler->filter('form')->eq(1)->filter('input[type=submit]')->form();
Then I could change each value of the form by:
$form['value'] = "new value";
but I don't have a fixed key for each value. Instead, I have a variable number. E.g. I could have something like:
$form[1234];
but also could be
$form[4321];
depending on other variables. So I need to change the form values without knowing the key values, but its position in the node <form>. E.g. something like $form->firstKey();
Also, I want to select the second option inside <select> tag, not a fixed value. Any ideas on how to achieve it?