I am trying to choose a option by Robot Framework native Keyword "Select From List" command, however it is failed with error message :
html page source:
<select id="reason" placeholder="Please select" style="width: 100%; display: none;" class="m-b-xs" data-role="combobox" aria-disabled="false" aria-readonly="false">
<option value="a">Assume</option>
<option value="b">New</option>
<option value="c">Renew</option>
<option value="d">Purchase</option>
<option value="e">Refinance</option>
<option value="f">Reschedul</option>
<option selected="selected" value="New">New</option>
</select>
I used value "Assume" or "a":
Choose Application Reason
Select From List xpath=//select[#id="reason"] Assume
Test was failed with error message:
INFO : Selecting option(s) 'Assume' from list
'xpath=//select[#id="reason"]'.
.....
FAIL :ValueError: Option 'Assume' not in list 'xpath=//select[#id="reason"]'.
INFO : Selecting option(s) 'a' from list 'xpath=//select[#id="reason"]'.
.....
FAIL : ValueError: Option 'a' not in list 'xpath=//select[#id="reason"]'.
But if I replace value "Assume" with default vale "New":
Choose Application Reason
Select From List xpath=//select[#id="reason"] New
test was passed.
Can anyone do the help? Thanks ahead.
I had similar issues with select drop downs and i tried this and worked for me.
click element xpath=//select[#id="reason"]
wait until element is visible xpath=//option[contains(text(),'${label}')]
click element xpath=//option[contains(text(),'${label}')]
If you want to select any static value form the list.
click element xpath=//select[#id="reason"]
click element xpath=//select/option[0]
You can also use text equal,
click element xpath=//option[text()='${label}')]
To ignore blank,
click element xpath=//option[normalize-space(text())='Assume']
I guess it worked as New is a default option.
For me keyword "Select from List by Value" works better.
Try:
Select From List by Value xpath=//select[#id="reason"] a
If it doesn't work - I used to have an error with an element state - add Click Element before selecting from list:
Click Element xpath=//select[#id="reason"]
Select From List by Value xpath=//select[#id="reason"] a
Other alternative by using Index
Select From List By Index xpath=//select[#id="reason"] 1
when you want to value a,
I solved the problem this way.
***Keywords***
Select By Value
[Arguments] ${locator} ${value}
Page Should Contain Element ${locator} 10
Select From List By Value ${locator} ${value}
List Selection Should Be ${locator} ${value}
Active time,
***Test Case ***
Choose Application Reason
Select By Value reason a
should use Label, which means text
e.g.
Select From List By Label xpath=//select[#id="reason"] Assume
I think you should select by value :
select from list by value xpath=//select[#id="reason"] a
Related
I have a multiple option select and everytime i submit the page i get:
ERR-1002 Unable to find item ID for item "clients1" in application
for day in {something}
htp.p('<select class="custom-select" name="clients'||to_char(day+1)||'" id="clients'||to_char(day+1)||'" multiple>
<option selected>Open this select menu</option>');
for client in (SELECT id, name FROM client) loop
htp.p('<option value="'|| client.id ||'">'|| client.name ||'</option>');
end loop;
htp.p('</select></div></div></div>');
Looks like this :
<select class="custom-select" name="clients1" id="clients1" multiple=""><option selected="">Open this select menu</option>
<option value="1">Test</option>
...
</select>
I really can't find the problem. Tried to search for an answer but could not find anything.
Thanks in advance
APEX assumes that a form element such as a select list is an APEX page item if its name and id are the same, which yours are. So you can avoid this problem by making the names different from the IDs in some way.
The usual way to create bespoke form elements on an APEX page is to use the APEX_ITEM package, which has functions like SELECT_LIST_FROM_QUERY to generate form elements whose values can be accessed from PL/SQL after page submit via APEX_APPLICATION arrays.
In the Expedia.com, on flights section, there're two inputs (departing and returning) for handle dates.
I'm not being able to get the right element so that I can click and sendKeys to it. I've tried many types and only using the place holder it works for returning input, but not for departing.
I'm using this: #FindBy (xpath = "//input[#placeholder='City or airport']") but it's clicking on the returning instead of departing.
So, what can I put in this locator so that I can get the right one? I've tried also with index [1] or [2] but didn't worked as well.
In case you want to insert the Departing date the input can be selected by #flight-departing-flp
Flight returning input element can be selected by #flight-returning-flp
Flying from airport field can be selected //input[#data-airport_code_element="flight-origin-flp-airport_code"] etc.
I have this code
<select ng-model='item.data.choice' >
<option ng-if='item.data.simple_allow_blank == false' ng-show='choice.name' ng-repeat='choice in item.data.simple_choices' value="{{choice.name}}" ng-disabled="$parent.controllerAction == 'show'">{{choice.name}}</option>
</select>
It shows the 3 choices entered by the Admin of the system in a dropdown box. It shows it without the blank choice.
The problem is if I want to put a default value (for example, choice[0]), it adds a blank value.
Also when converting from ng-repeat to ng-options from this question.
I have 4 choices 1,2,3 and blank i wanted to remove the blank i followed the guide/answers found on the link i have posted with my question, the difference in my part is that i have a dynamic list and when the list is newly created. it never fails to include the blank when using ng-option but it solves my problem to have an initial default value from the dynamic list, if i use ng-repeat i dont have the initial value but the blank from the choices where remove. i wanted to have the blank choice remove and the same time to have an initial value from the dynamic list.
I can set the default value but it cannot remove the blank option.
Can anyone help? Thanks.
You have to filter data in js file and create a new array that you will render it in html.let say you are getting data in variable **item.data.simple_choices**(as you have written it in ng-repeat)then your function would be.
var data = item.data.simple_choices;
var filteredArray = [];
data.filter(function(item){
if(item.name!=''){
filteredArray.push(item)
}
})
After hours of leeching the web and lots of trial and error I finally got the correct answer.
<select ng-model='model'>
<!-- correct binding -->
<option ng-show='choice.name' ng-repeat='choice in object' value="{{choice.name}}" ng-selected='model = object[0].name'>{{choice.name}}</option>
</select>
The code is simple but this format is helpful because object is an object the has the value of the list. as you can see i did assign it to the model because model is the variable that is being used in the view. The [0] is the index number of the list. You can use value or name depending on what parameters are present on the object.
I'm having a problem selecting certain value in a dynamic dropdown list. The scenario is when there is a newly added value on the DDL then my scripts will fail since the xpath position changes once there is new values.[this is the script in selecting the xpath][2]
Thanks in advance!
This is the html source html source of the DDL
Have a look at the documentation: http://robotframework.org/Selenium2Library/Selenium2Library.html
You could try to select an item from the dropdown list by value or label with the keywords:
'Select From List By Label'
'Select From List By Value'
I hope someone is able to help me. I am trying to determine whether or not Selenium IDE can verify that only specific values are present in a drop down list, and should anything else appear within the drop down list it is an error.
For example, using a basic html Single Select drop down list :
<select id="drop_down_list">
<option value="Test">Please select...</option>
<option value="Saab">Saab</option>
<option value="Mercedes">Mercedes</option>
<option value="Audi">Audi</option>
</select>
I know I can verify the 'Label' of each selectable value using (for example) :
verifySelectedLabel : //select[#id='drop_down_list'] : Please select...
I know I can verify the 'Value' of each selectable value using (for example):
verifySelectedValue : //select[#id='drop_down_list'] : Test
And I know I can do this for each other selectable value displayed.
But what if for whatever crazy scenario, a Dev decided to add 'Ford' to the drop down list, and he/she did not make anyone aware of this ? My tests would pass as those selectable values which I am expecting are still present.
Is there is a way of verifying that no other values other than those I am expecting are also contained within the drop down list ?
I know there is 'verifyNotSelectedLabel' and 'verifyNotSelectedValue' available for use, and these work perfectly when I can specify the 'Labels' and 'Values' accordingly, but they dont help in this particular scenario.
Fingers crossed someone can help, many thanks in advance to all,
How about using "verifySelectOptions", this will check all the options in the dropdown exactly how it should appear.
So in case if there is a New value added or some changes in the existing values (like spelling mistake etc) Step will fail.
If you right click on the dropdown list while in Selenium-IDE, try choosing verifyTextPresent from the command list. The value will be a text list of all the options in the list strung together(usually with spaces between).
Then if a developer adds a selection(or misspells an existing selection, the step will fail(you could use assertTextPresent if you want the test to stop at that point).
Klendathu