Use selenium wait function the way selenium code suggests

Bug #1404416 reported by Imran Hayder
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Dashboard (Horizon)
Fix Released
Undecided
Imran Hayder

Bug Description

BACKGROUND:
its known that horizon openstack dashboard integration tests uses selenium extensively to perform tests.
 Selenium official code is great in way each class and function has a docstring explaining the Usage and how params should be passed.
INFO:
Regarding this bug, In the helper file for integration tests i.e. 'horizon/openstack_dashboard/test/integration_tests/helpers.py`,
we call a selenium function named 'until()' passing a lambda function that returns title of webdriver.
Source: https://git.openstack.org/cgit/openstack/horizon/tree/openstack_dashboard/test/integration_tests/helpers.py#n52

We dont have to pass like 'until(lambda d: return self.driver.title)',
instead we can do it (as suggested by selenium docstrings for this function) like this 'until(lambda d: return d.title) and it would perfectly fine.
Why? because see the usage of this selenium function until():
https://code.google.com/p/selenium/source/browse/py/selenium/webdriver/support/wait.py#39
this docstring suggests how a lambda function be passed.
also, looking at function definition of until() , it takes care of passing self.driver.. so when we say lambda d: , until will pass self.driver to this lambda function, and our return statement will eventually be self.driver.title if we define this lambda function as
lambda d: return d.title
This is where until() is passing self.driver to method passed to it, ( here the method passed is labmda d )
https://code.google.com/p/selenium/source/browse/py/selenium/webdriver/support/wait.py#66

FIX: simple fix to rework 'lambda d: return self.driver.title' to 'lambda d: return d.title'

tags: added: integration-tests
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to horizon (master)

Fix proposed to branch: master
Review: https://review.openstack.org/143224

Changed in horizon:
assignee: nobody → Imran Hayder (hayderimran7)
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to horizon (master)

Reviewed: https://review.openstack.org/143224
Committed: https://git.openstack.org/cgit/openstack/horizon/commit/?id=8edb9f1bc3906f1157d7e7a5fc4912b10e68d69f
Submitter: Jenkins
Branch: master

commit 8edb9f1bc3906f1157d7e7a5fc4912b10e68d69f
Author: imran <email address hidden>
Date: Fri Dec 19 16:09:47 2014 -0800

    Fix method passed to selenium way it suggests

    A lambda function is passed to selenium wait call until() but the docstrings
    of that call suggest a better way of passing the lambda function.
    Its redundant to return a specific driver instance when until() function
    already takes care of that.

    Change-Id: Ie0916587bf6a7488b3828d91ad553a3944619dfc
    Partially implements blueprint: selenium-integration-testing
    Closes-Bug: #1404416

Changed in horizon:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in horizon:
milestone: none → kilo-2
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in horizon:
milestone: kilo-2 → 2015.1.0
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.