Skip to content

Conversation

adwu73
Copy link
Contributor

@adwu73 adwu73 commented Aug 16, 2012

when nothing match

@adwu73
Copy link
Contributor Author

adwu73 commented Aug 16, 2012

the issue is that when you "select from list" with an non-existing item name, no error will be returned

@emanlove
Copy link
Member

Looks good to me. Any objections to me merging?

@emanlove
Copy link
Member

With the performance changes to "Select Element From List ..." code this patch will not merge in. I've written a quick test and this issue is still present with the generic keyword 'Select From List'. (The more specific and speedier 'Select From List By Value', '...By Label', and '...By Index' all catch this error and throw a exception).

I have a new patch which resolves this issue but I have a question on expected functionality. Since 'Select From List'...

  • handles both multi-selection lists and single-selection lists and...
  • if it is multi-selection and the user provides and empty list* then it selects all and ...
  • if more than one value is given for a single-selection list, the last value will be selected

should we

  1. Throw a generic "Item not within list" exception if any item is not present (by value or label) ...or...
  2. Throw a specific "${THIS} item does not exist within ${THAT} list" exception if any multi-selection item is not present ...or...
  3. Throw a specific "${THIS} item does not exist within ${THAT} list" exception if the last value/label on single-selection item is not present ...or...
  4. if more than one value is given for a single-selection list and any of those items excluding the last item log that those items are not present ...or...
  5. Throw a specific "${THESE} items does not exist within ${THAT} list" exception for any and all items not present
  6. ... some combination of the above...

Anyone with suggestions as to the best behaviour should be?

* only empty list? what if it is None? Note to self to check this

@adwu73
Copy link
Contributor Author

adwu73 commented Aug 27, 2013

I would suggest to go with the first simple option, thanks!

Adam

From: Ed Manlove
Sent: Tuesday, August 27, 2013 9:00 PM
To: rtomac/robotframework-selenium2library
Cc: adwu73
Subject: Re: [robotframework-selenium2library] raise exception in (un)select from list... (#92)

With the performance changes to "Select Element From List ..." code this patch will not merge in. I've written a quick test and this issue is still present with the generic keyword 'Select From List'. (The more specific and speedier 'Select From List By Value', '...By Label', and '...By Index' all catch this error and throw a exception).

I have a new patch which resolves this issue but I have a question on expected functionality. Since 'Select From List'...

a.. handles both multi-selection lists and single-selection lists and...
b.. if it is multi-selection and the user provides and empty list* then it selects all and ...
c.. if more than one value is given for a single-selection list, the last value will be selected
should we

1.. Throw a generic "Item not within list" exception if any item is not present (by value or label) ...or...
2.. Throw a specific "${THIS} item does not exist within ${THAT} list" exception if any multi-selection item is not present ...or...
3.. Throw a specific "${THIS} item does not exist within ${THAT} list" exception if the last value/label on single-selection item is not present ...or...
4.. if more than one value is given for a single-selection list and any of those items excluding the last item log that those items are not present ...or...
5.. Throw a specific "${THESE} items does not exist within ${THAT} list" exception for any and all items not present
6.. ... some combination of the above...
Anyone with suggestions as to the best behaviour should be?

  • only empty list? what if it is None? Note to self to check this


Reply to this email directly or view it on GitHub.

emanlove added a commit to emanlove/robotframework-seleniumlibrary that referenced this pull request Aug 27, 2013
@adwu73 submitted a pull request, robotframework#92, with changes to perform this check but
we had delayed pulling it and in the meantime other chnages were made. I am
resubmitting similar changes working out the best way to catch and report the
error.
@emanlove
Copy link
Member

@adwu73 I've added some code and a test to give some sandbox room to try the methods.

Here is some sample code to test it my changes above

$ mkdir s2l-select-non-exist
$ cd s2l-select-non-exist/
~/s2l-select-non-exist $ virtualenv -p /usr/bin/python2.6 --no-site-packages clean-python26-env
~/s2l-select-non-exist $ source clean-python26-env/bin/activate
(clean-python26-env) ~/s2l-select-non-exist $ easy_install selenium decorator docutils robotframework
(clean-python26-env) ~/s2l-select-non-exist $ git clone [email protected]:emanlove/robotframework-selenium2library.git rf-s2l
(clean-python26-env) ~/s2l-select-non-exist $ cd rf-s2l/
(clean-python26-env) ~/s2l-select-non-exist $ git checkout select-nonexisting-item
(clean-python26-env) ~/s2l-select-non-exist $ python test/run_tests.py python ff --suite acceptance.keywords.lists --include OnyThisOne

@emanlove
Copy link
Member

I'm getting the feeling that Selenium does not throw an exception when one tries to unselect an non-existing item. Need to verify this when I find some more time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants