0

I am trying to extend the RobotFramework SeleniumLibray to override open_browser method. The problem is, I am not even sure which class I should override.

Library

https://github.com/robotframework/SeleniumLibrary/blob/master/src/SeleniumLibrary/init.py

following code gives the error.

if I extend the BrowserManagementKeywords class, I am not sure what should I pass as ctx in constructor argument.

from SeleniumLibrary import SeleniumLibrary
import env


class DriverManager(SeleniumLibrary):

    def open_browser(self, url, alias=None, ff_profile_dir=None):

        browser = env.capabilities.get("browserName")
        remote_url = env.host
        desired_capabilities = env.capabilities

        return super(DriverManager, self).open_browser(url, browser, alias, remote_url, desired_capabilities, ff_profile_dir)


DriverManager().open_browser("https://google.com") 

Error

AttributeError: 'super' object has no attribute 'open_browser'

Laurent Bristiel
  • 6,819
  • 34
  • 52
Gaurang Shah
  • 11,764
  • 9
  • 74
  • 137
  • Can you explain what it is that you're trying to achieve functionally? I.e. the motivation to choose to override the class as opposed to creating a new library and passing the SeleniumLibrary object to it? – A. Kootstra Dec 06 '17 at 19:17
  • I am trying to run tests on mobile(using appium) as well as on browser (using selenium). I was thinking to write a class which over rides AppiumLibary or SeleniumLibaray based on my config. and then over ride open_browser and open_application to read from config. – Gaurang Shah Dec 06 '17 at 19:19
  • That does not motivate the design choice to extend the class. When using Robot Framework most of us use Robot Script to automate the browser. So, what it that requires a python solution? – A. Kootstra Dec 06 '17 at 19:23
  • it's hide the underlying complexity. I am trying to create a new library in Python which will handle driver creation. – Gaurang Shah Dec 06 '17 at 19:27
  • Have you had a look at this post which describes creating a [custom library](https://stackoverflow.com/questions/23703870/pass-existing-webdriver-object-to-custom-python-library-for-robot-framework) that uses an existing Selenium?Library instance. – A. Kootstra Dec 06 '17 at 19:36
  • 1
    Is this really your code, or is that first `def` supposed to be `def open_browser(...)`? – Bryan Oakley Dec 06 '17 at 19:39
  • @BryanOakley thanks. I might have made mistake while copying code – Gaurang Shah Dec 07 '17 at 16:36
  • Is this the solution to your problem, or just a copy-and-past to [so] error? – A. Kootstra Dec 07 '17 at 21:44
  • It's not the solution, i made error in pasting code – Gaurang Shah Dec 08 '17 at 23:48

0 Answers0