Code review comment for lp:~kenneth-koontz/selenium-simple-test/bug-828050

Revision history for this message
Kenneth Koontz (kenneth-koontz) wrote :

Corey, great point! I actually thought about extracting functionality and putting it into another action; however, I was left with the same thing. If we give the user the ability to add partial_id's, then the user can input any substring, like the aforementioned 'foobar' example. Which means that if we want to have partial locators with id's, the user must give some thought into the locator otherwise they will be left with an assertion error.

Take for instance a dynamic website that appends a unique key every time a new post is created. Suppose the string to append the key to is postlink. We would likely see postlink1, postlink2, ... postlink{n}. Furthermore, suppose there was another link element with the id, postlink-summary. In this case, link_click('postlink') won't work; but my question is-should it? Partial matching or not, if the user provides an ambiguous selector, they should be notified and there should be no action associated with it. So in link_click's case, if there is ambiguity in 'element_locator', the following line:

"""
if not get_element_by_xpath(element_locator).get_attribute('href')
"""

should catch this ambiguity in 'get_element_by_xpath'.

"""
if len(elements) != 1:
    msg = 'Could not identify element: %s elements found' % len(elements)
    _raise(msg)
"""

Thanks!

-K

« Back to merge proposal