I have a select tag with some options under it . I select one value out of those along with other field values and move to next page. Once I return to previous page I want to check whether the dropdown value is same as that I selected. How can I get the already selected value using protractor. Can someone please help.
Following #Grasshopper's comment, I read this, and the following worked for me:
expect(element(by.xxxxxx('xxxxxxx')).$('option:checked').getText()).toEqual('xxxxxx')
var dropdownval=element(by.xpath/css("Xpathofdropdown/cssofdropdown")).element(by.css('option:checked')).getText();
console.log(dropdownval);
The following code helps me to resolve the issue,now the variable contains the value of the dropdown selected
var dropdownval=element(by.xpath("XpathOfDropdown")).element(by.css('option:checked')).getText();
console.log(dropdownval);
First select the input, then select the option using css, with the option:selected tag:
var selected = element(by.css('#ID_OF_THE_SELECT option:selected'))
Related
I'm banging my head against a wall trying to solve something I'm sure is simple. I'm using Access 2016 and trying to build a form which essentially has a filter combo box in the header.
Let's say the form is called myForm and the comboBox cboStatus. The query contains a field called status.
In my query, I basically have SELECT * FROM myQuery WHERE [myQuery].[status]=[Forms]![myForm]![cboStatus]. Eventually, I intend to add a VBA-based event on the COmboBox to update the query when it changes, but for now, I select a value and hit Refresh All on the form, just to test it.
No matter what value I have in the ComboBox, no records display in the form. What am I missing? Thanks in advance!
If status is a text field then you need
SELECT * FROM myQuery WHERE [myQuery].[status]= "'" & [Forms]![myForm]![cboStatus] & "'"
I think I have solved it! I didn't define the form element (comboBox) as a parameter in the SQL query. Adding:
PARAMETERS [Forms]![myForm]![cboStatus] Text ( 255 );
seems to have fixed it! Wanted to make sure I responded in case anyone else has the same issue!
Can anyone suggest a link or solution to add select All option within the multiselect dom element of the material design. I want all the options to be selected except for the select all option and want to display it in the text field and post it.
I couldn't find a solution for it. Can anyone suggest.
Pls Note: I dont want to add it as a button outside the dom.
$("#all_member").change(function(){
if($("#all_member option[value=-1]:selected").length > 0){
$('#all_member option').attr('selected', "selected");
$('#all_member').prev("ul").find("li").addClass('active');
$('#all_member').prev("ul").find("li span input").attr('checked', "true");
}else{
$('#all_member option').attr('selected', "false");
$('#all_member').prev("ul").find("li").removeClass('active');
$('#all_member').prev("ul").find("li span input").removeAttr('checked');
}
Thanks IN advance!
I can provide the logic. The rest is up to you.
Put an onChange event handler (function) for your select.
On that function, put an "if statement" to check if the value is equal to the value of "Select All" option.
If it returns true, then manually call the element and set its value to the value of all the other options (probably an array).
In a protractor test I have an <input type="text"/> that is pre-filled with a value, and I'd like to erase that value and type a new one. Ideally I'd be able to just say something like
// Some way to select all the text in the text box so `
// sendKeys` will type over it.
element(by.css("input.myInput")).selectAll();
element(by.css("input.myInput")).sendKeys("my new value");
But selectAll doesn't exist and I can't find anything helpful in the API docs.
Any ideas?
I use clear to do this in one of my tests, works like a charm ;)
element(by.css("input.myInput")).clear();
Found it:
var ctrlA = protractor.Key.chord(protractor.Key.CONTROL, "a");
element(by.css("input.myInput")).sendKeys(ctrlA);
Sends Ctrl+A, the keyboard shortcut for "select all".
Double click on input and click on BackSpace
browser.actions().doubleClick(input).sendKeys(Key.BACK_SPACE).perform();
Or double click on the input and set a new value, and it will replace previous value
browser.actions().doubleClick(input).sendKeys('9999').perform();
Similar to glepretre, my solution is given the input formcontrol is named 'Name' but this worked for me
newValue = getNewValue();
element(by.css('input[formControlName=Name]')).clear();
element(by.css('input[formControlName=Name]')).sendKeys(newValue)
.then(function () {....});
I have looked at the documentation at http://www.web2py.com/books/default/chapter/29/05/the-views?search=OPTION%28 and I have looked at the previous question How to preselect options in SELECT helper in web2py, but my selects have not been working properly.
I make the select:
select = SELECT(_name = attr)
I populate it by appending options in a loop
...
option = OPTION(the_string, _value=str(row.id))
select.append(option)
...
I set the selected value for the select
select.value = str(selected_value)
But the select does not have anything pre-selected. In the html, the correct option is not marked 'selected'. What am I missing?
value is an argument of SELECT.__init__ -- it is not an attribute that can simply be set after the object is created. If you want to change the selected attribute of an option after it has been created, you can do:
select.element('option[value=%s]' %
str(selected_value))['_selected'] = str(selected_value)
Or just specify the selected option when creating the OPTION object:
OPTION(the_string, _value=row.id, _selected=True)
I would like to display a default value (that I already set using setDefaultSuggestionsFromText()) when there is no suggestion displayed for the user entered value. Thanks for your help!
You need a SuggestOracle that always returns a suggestion. You could easily build one that wraps your current SuggestOracle and returns your canned suggestion when the wrapped oracle returns none.