- PageObject
- ChildObject
- AnotherObject
If I create a PageFactory of AnotherObject, I get something like NoMatchingPageError: There's, no matching classes to this page.
But it works fine when the PageFactory is for ChildObject
Is there a workaround for this?
IAdminPage:
def method1:
pass
def method2:
pass
class FreeAdminPage(IAdmin):
...
class Premium(IAdmin):
...
I think a hackish workaround could be to create an interface and have all 3 implement it. But I wonder what the underlying issue really is. Maybe the reflection on the PageFactory isn't picking up subclasses.e.g
class AdminPage(PageObject):
...
class FirstPage(AdminPage):
...
class SecondPage(AdminPage):
...
This is what I originally had. So I was getting that NoMatchingPageError: There's, no matching classes to this page. error when I did this:
navigator = PageFactory.create_page(SecondPage, driver)
But I just found out it happens for classes that inherit from PageObject as well.
e.g
class AdminPage(PageObject):
...
class FirstPage(PageObject):
...
class SecondPage(PageObject):
...
Now, if I do:
navigator = PageFactory.create_page(AdminPage, driver)
It works fine. But if it's something like
navigator = PageFactory.create_page(FirstPage, driver) # or SecondPage
I get that same error
These classes are already imported.
In my Test file:
from tests.pages.admin_page import AdminPage
from tests.pages.first_page import FirstPage
...
class Test(WTFBaseTest):
...
navigator = PageFactory.create_page(SecondPage, driver)