Could this package be used with other test-framework
SteveHarrison82 opened this issue · comments
Thank you for the package.
I would like to request please if we could have the package be used independent of robotframework. Currently I understood that se2lib instance is based on
BuiltIn().get_library_instance("Selenium2Library")
If the instance se2lib, could be created universally, (without using the method of BuiltIn that gets an existing-running instance of Selenium2Library ,) then the package could also be used with other test-framework also. I would like to request if we could have the enhancement and if its practical
p.s The other dependency on robot api wont be affecting if used with other test-framework. Only this specific dependency affects
This wouldn't be hard, and I've thought about doing it, but it would add
complexity to the code and part of the goal is to keep this package as
simple as possible. I doubt I'll do it, but I'll give it some thought.
Perhaps I could create a base class that doesn't use robot, and then
inherit from that to create one that uses robot.
On Fri, Jul 1, 2016 at 2:46 AM, Ramakrishnan notifications@github.com
wrote:
Thank you for the package.
I would like to request please if we could have the package be used
independent of robotframework. Currently I understood that se2lib instance
is based onBuiltIn().get_library_instance("Selenium2Library")
If the instance se2lib, could be created universally, without using the
method of BuiltIn that gets an existing instance, then the package could
also be used with other test-framework also. I would like to request if we
could have the enhancement and if its practical—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#4,
or mute the thread
https://github.com/notifications/unsubscribe/ABEmYla3z35ap5ea3-GeBIHKZUucqPpcks5qRMXWgaJpZM4JC5eS
.
Thank you, if its possible to simply control using an argument to existing PageObject on using other test framework, I will find it useful
pageobject.py
.
.
.
from robot.utils.connectioncache import ConnectionCache
import Selenium2Library
# These two lines needs to be executed only once
cache_sel2lib = ConnectionCache()
cache_sel2lib.register (Selenium2Library.Selenium2Library(), alias='page_instance')
.
.
.
Class PageObject(six.with_metaclass(ABCMeta, object)):
def __init__(self, robot_running=True):
self.logger = robot.api.logger
self.locator = LocatorMap(getattr(self, "_locators", {}))
self.robot_running = robot_running
# N.B. se2lib, browser use @property so that a
# subclass can be instantiated outside of the context of a running
# test (eg: by libdoc, robotframework-hub, etc)
@property
def se2lib(self):
if self.robot_running:
return BuiltIn().get_library_instance("Selenium2Library")
else:
global cache_sel2lib
return cache_sel2lib.get_connection('page_instance')
example:
If the argument robot_running is False, then Selenium2Library instance is returned else, the Selenium2Library instance using method of BuiltIn is returned
Why would you use Selenium2Library without robot framework? Is that even
possible? I think Selenium2Library requires robot. I was thinking you
wanted to use it without robot at all, meaning without Selenium2Library.
On Fri, Jul 1, 2016 at 12:14 PM, Ramakrishnan notifications@github.com
wrote:
Thank you, if its possible to simply control using an argument to existing
PageObject on using other test framework, I will find it usefulfrom robot.utils.connectioncache import ConnectionCache
import Selenium2LibraryThis three lines needs to be executed only once
cache_sel2lib = ConnectionCache()
cache_sel2lib.register (Selenium2Library.Selenium2Library(), alias='page_instance')Class PageObject(six.with_metaclass(ABCMeta, object)):
def __init__(self, robot_running=True): self.logger = robot.api.logger self.locator = LocatorMap(getattr(self, "_locators", {})) self.robot_running = robot_running # N.B. se2lib, browser use @property so that a # subclass can be instantiated outside of the context of a running # test (eg: by libdoc, robotframework-hub, etc) @property def se2lib(self): if robot_running: return BuiltIn().get_library_instance("Selenium2Library") else: global cache_sel2lib return cache_sel2lib.get_connection('page_instance')
example:
If the argument robot_running is False, then Selenium2Library instance is
returned else, the Selenium2Library instance using method of BuiltIn is
returned—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#4 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/ABEmYp5YyPMRLbON9IIfKMS5z51bsE8sks5qRUragaJpZM4JC5eS
.
yes, Selenium2Library requires robot package as a 'dependency'. However, I could always create script that would import Selenium2Library but could be executed using any python test-framework and not necessarily robot framework. It gives an alternative. It also asserts that the library is independent though it could be using the utilities or api of robot package
I'm not going to implement this. I don't see any value. This library is so small, if you need to use it with some other testing framework, it would be easy to fork and make the necessary changes.
You could do this now by simply creating a new subclass and overriding the se2lib
property.