New issue 200 by ovuaia...@gmail.com: Add a public member of the selenium
instance to SeleniumLibrary
http://code.google.com/p/robotframework-seleniumlibrary/issues/detail?id=200
When there is complex logic involved in the implementation of keywords
for selenium driven in-browser testing, (and perhaps you need to
access selenium api functions not implemented as SeleniumLibrary
keywords) a good practice is to implement those keywords directly in
python.
In such a case it makes a whole lot of sense (i.e. it is more
convenient and in most cases more elegant) to interact directly with
the underlying selenium object instance.
So instead of the following code :-
from robot.libraries.BuiltIn import BuiltIn
def title_should_start_with(expected):
seleniumlib = BuiltIn().get_library_instance('SeleniumLibrary')
xml_data =
seleniumlib.call_selenium_api('captureNetworkTraffic','xml')
# do something useful with xml_data
title = seleniumlib.get_title()
if not title.startswith(expected):
raise AssertionError("Title '%s' did not start with '%s'"
% (title, expected))
you could have the following code snippet which uses the private
selenium member object ('_selenium') of the SeleniumLibrary instance
directly:-
from robot.libraries.BuiltIn import BuiltIn
def title_should_start_with(expected):
seleniumlib = BuiltIn().get_library_instance('SeleniumLibrary')
seleniumobj = seleniumlib._selenium
xml_data = seleniumobj.captureNetworkTraffic('xml')
# do something useful with xml_data
title = seleniumobj.get_title() #calling get_title directly on
the _selenium instance
if not title.startswith(expected):
raise AssertionError("Title '%s' did not start with '%s'"
% (title, expected))
This alternate approach would require that the ._selenium member
object of the robotframework SeleniumLibrary instance be always
available through subsequent releases.
But it may be more pythonic for the SeleniumLibrary API to explicitly
provide a public reference to the _selenium private member.
Please see the following URL where this was earlier discussed :-
http://groups.google.com/group/robotframework-users/browse_thread/thread/de2231f3aebb3268
Comment #1 on issue 200 by pekka.klarck: Add a public member of the
selenium instance to SeleniumLibrary
http://code.google.com/p/robotframework-seleniumlibrary/issues/detail?id=200
It's a good idea we expose the active Selenium instance either as `se` or
`selenium` attribute. We can change the library itself to use that too, but
we need to keep the old `_selenium` around for backwards compatibility.
Comment #2 on issue 200 by janne.t.harkonen: Add a public member of the
selenium instance to SeleniumLibrary
http://code.google.com/p/robotframework-seleniumlibrary/issues/detail?id=200
I think I'll go with `selenium` as the property name since it is not too
long to be cumbersome.
Comment #3 on issue 200 by janne.t.harkonen: Add a public member of the
selenium instance to SeleniumLibrary
http://code.google.com/p/robotframework-seleniumlibrary/issues/detail?id=200
This issue was updated by revision 13fc61e3a3d2.
Comment #4 on issue 200 by janne.t.harkonen: Add a public member of the
selenium instance to SeleniumLibrary
http://code.google.com/p/robotframework-seleniumlibrary/issues/detail?id=200
(No comment was entered for this change.)