Using Robot Framework, I have a dropdown with multiple options. When I use the select from list option I can see the selection become highlighted, but when the dropdown closes, the value is not changed.
Here is a sample of my code:
click element id=month
select from list xpath=//select/#name="month" September
click button css=button.submit
I have tried variants of this with the select from list by label and select from list by value, and they fail with error stating the selected list or value does not exist.
Select from list by value example:
click element id=month
select from list by value xpath=//select/#name="month" September
click button css=button.submit
Select from list by label example 1:
click element id=month
select from list by label xpath=//select/#name="month" September
click button css=button.submit
Select from list by label example 2:
click element id=month
select from list by label xpath=//select/#name="month" label=September
click button css=button.submit
Anyone experienced this before where an item gets "selected" but the value does not get changed?
Use following keyword.
Pass locator as 1st argument and value as another argument
Select from list by label and validate
[Arguments] ${locator} ${select value}
Focus ${locator}
# Select from list by label
Select From List By Label ${locator} ${select value}
# Get selected value and validate it against passed value as argument
${value} = Get Selected List Label ${locator}
Should be equal ${select value} ${value}
Related
I have a dynamic table displayed based on a value selected from a radio button in my project. The radio button field "Doctor Name" field has different choices like "Frank", "Michael", "Josh", "Jessica". When I select the "Frank" value, it displays a dynamic table with the list of appointments for "Frank", The first column in the table is "Doctor Name". When I select "Frank" from the radio button, I have to validate if all the appointments listed are for "Frank". So I have to write coding in cypress to check if all the first column cell values are "Frank".
How can I achieve this?
retrieve all the first columns using cy.get() with the proper selector, then use the each command to validate the content of each cell, something like this
cy.get("selector for first colums").each(($el, index, $list) => {
cy.wrap($el).contains('Frank')
})
I need an automatic way to have new fiscal weeks (a string that looks like yyyyww) added to my dropdown filter. It's necessary that it's a dropdown unfortunately. Can I just filter out all values that don't start with "2021*" in this particular table? I use those other values in other parts of my dashboard, so I can't filter them out of my data completely.
Create a calculation called DateDisplay as follows:
IF STARTSWITH((STR([Period])),'2021') = TRUE then 'Display'
END
Add the new DateDisplay field to the Filters Shelf and uncheck NULL
Select 'Show Filter' for the string date field
On the drop down menu (down arrow on the right) for the filter which is now showing, select the options 'Only Relevant Values'
#Html.DropDownListFor(m => m.field, Model.fieldList, "Select")
I have the code above to get the values of a drop down list from a database. Because the database does not have the select value, I am add it to the list. However, I want to set the selected value to a certain value(variable). How can I do this?
Say I want the selected value to be "WI" and "WI" is in the list. How do i do this? Or how do I specify the #value property?
The DropDownListFor function will first look if there is a selected value in the provided select list. If there are no selected values in the selected list items, it will look at the value of the field that the drop down list is for and attempt to match that to the value of each select list item until it finds the correct one. If any select list item does not have value, it will compare it to the text instead.
Once you have the full list generated, loop through it and find the value you want selected, then set the selected property to true and it should choose that one.
I want to clear the toolbar of my grid, but not to the default value of the column. I want to empty all fields.
When I use the
$("#Jqgrid")[0].clearToolbar();
method the toolbar gets the initial default values..
You can choose one from the following two ways.
1) You can temporary change the defaultValue of the searchoptions to "" before call of clearToolbar. You can use setColProp method for example to change column properties (see en example here).
2) Set the value of the the toolbar element manually to "" or to any other value which you want. There are simple way how the ids of the input or select elements of the toolbar are constructed. Let us you have column with the name 'col1' (the corresponding column of colModel has name: 'col1'). Then the id of the element in the filter toolbar will be gs_col1. So you can use
$("#gs_col1").val("");
to clear the field. In more general case if the colname is the variable which hold the value from colModel[i].name you can use
$("#gs_" + $.jgrid.jqID(colname)).val("");
I'm trying to find a simple Selenium call to grab the current option from a select drop-down list. I'm aware there are calls which grab all the values in a list but I wish to know which option is currently selected. Apologies if this is trivial but google and Selenium IDE didn't help me. Thanks.
You should be able to use the getSelected* commands to return the ID, index, or label of the selected item. Below is quoted from the Selenium Reference:
storeSelectedId ( selectLocator, variableName )
Gets option element ID for selected option in the specified select element.
Arguments:
selectLocator - an element locator identifying a drop-down menu
variableName - the name of a variable in which the result is to be stored.
Returns: the selected option ID in the specified select drop-down
storeSelectedIndex ( selectLocator, variableName )
Gets option index (option number, starting at 0) for selected option in the specified select element.
Arguments:
selectLocator - an element locator identifying a drop-down menu
variableName - the name of a variable in which the result is to be stored.
Returns: the selected option index in the specified select drop-down
storeSelectedLabel ( selectLocator, variableName )
Gets option label (visible text) for selected option in the specified select element.
Arguments:
selectLocator - an element locator identifying a drop-down menu
variableName - the name of a variable in which the result is to be stored.
Returns: the selected option label in the specified select drop-down
I would use storeSelectedValue or getSelectedValue
JUNIT
String value = selenium.getSelectedValue(selectLocator)
Selenium Action
storeSelectedValue ( selectLocator, variableName )
there is a link to practice such things:
"https://letskodeit.teachable.com/p/practice"
there's a "Select Class Example"
1.in this test first it clicks on "Honda" in the dropdown menu
2. then extracts the select-tag as parent of the option-tag "Honda"
3. then converts it to Select object
4. then i uses the getFirstSelectedOption() to compare it with the expected value "Honda.
#Test
public void selectTagDemo() {
WebElement hondaElement = webDriver.findElement(By.xpath("//option[#value=\"honda\"]"));
hondaElement.click();
WebElement selectCarWebElement = hondaElement.findElement(By.xpath("//parent::select"));
Select selectCar = new Select(selectCarWebElement);
Assert.assertEquals(selectCar.getFirstSelectedOption().getText(), "Honda");
}
if you need the whole Test class comment below