robotframework-pageobjectlibrary icon indicating copy to clipboard operation
robotframework-pageobjectlibrary copied to clipboard

Page objects with extended Selenium2Library

Open gaurav517 opened this issue 8 years ago • 3 comments

You use following to share instance of selenium2library: BuiltIn().get_library_instance("Selenium2Library")

Now in my case, I extend Selenium2Library to MySelenium2Library class in python.. with some additional functions in MySelenium2Library class. Is it possible to share the instance of MySelenium2Library?

Any clue how we can achieve page objects with custom: MySelenium2Library. Thanks a lot.

gaurav517 avatar May 10 '17 12:05 gaurav517

Sure, I could consider adding a configuration option to let you define which selenium library to choose from, though I'm not convinced it's necessary. You can just create your own base class that inherits from PageObject, but redefines the se2lib property to be whatever you want.

On Wed, May 10, 2017 at 7:42 AM, gaurav517 [email protected] wrote:

You use following to share instance of selenium2library: BuiltIn().get_library_instance("Selenium2Library")

Now in my case, I extend Selenium2Library to MySelenium2Library class in python.. with some additional functions in MySelenium2Library class. Is it possible to share the instance of MySelenium2Library?

Any clue how we can achieve page objects with custom: MySelenium2Library. Thanks a lot.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/boakley/robotframework-pageobjectlibrary/issues/7, or mute the thread https://github.com/notifications/unsubscribe-auth/ABEmYsMML_WPBaqQIjgsoPOCntInZoANks5r4bDJgaJpZM4NWm1a .

boakley avatar May 10 '17 14:05 boakley

@boakley - I'd like to use ExtendedSelenium2Library instead of Selenium2Library. I tried your suggestion to create my own base class that redefines se2lib, but I just cannot get that to work. I'm new to python, and I'm not sure what I'm doing wrong. Could you provide a concrete example of how to do this?

stevof avatar Nov 20 '17 20:11 stevof

It should be something as simple as this, though I haven't tested it and likely won't have time for several days:

class CustomPageObject(PageObject): @property def se2lib(self): return BuiltIn().get_library_instance("ExtendedSelenium2Library")

Then, just have your page objects inherit from CustomPageObject rather than PageObject

On Mon, Nov 20, 2017 at 2:40 PM, Steve Fisher [email protected] wrote:

@boakley https://github.com/boakley - I'd like to use ExtendedSelenium2Library instead of Selenium2Library. I tried your suggestion to create my own base class that redefines se2lib, but I just cannot get that to work. I'm new to python, and I'm not sure what I'm doing wrong. Could you provide a concrete example of how to do this?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/boakley/robotframework-pageobjectlibrary/issues/7#issuecomment-345824589, or mute the thread https://github.com/notifications/unsubscribe-auth/ABEmYky1You3fM4w8NenBCd4DORQSJpUks5s4ePOgaJpZM4NWm1a .

boakley avatar Nov 20 '17 23:11 boakley