How to call methods of different types in two files? #2448
Answered
by
mdmintz
luckyboy-wei
asked this question in
Q&A
-
For example: # aa.py
from seleniumbase import BaseCase
BaseCase.main(__name__, __file__)
class EapCase(BaseCase):
def test_add_eap(self):
self.open("http://192.168.11.11:80/") # bb.py
import aa
from seleniumbase import BaseCase
BaseCase.main(__name__, __file__)
class FdcCase(BaseCase):
def test_add_fdc(self):
aa.EapCase().test_add_eap() # Call failed here
self.open("http://192.168.11.11:80/") I want to call the method from
|
Beta Was this translation helpful? Give feedback.
Answered by
mdmintz
Jan 25, 2024
Replies: 2 comments 2 replies
-
The example from SeleniumBase/examples/boilerplates/classic_obj_test.py covers your scenario: """Classic Page Object Model with BaseCase inheritance."""
from seleniumbase import BaseCase
BaseCase.main(__name__, __file__)
class DataPage:
def go_to_data_url(self, sb):
sb.open("data:text/html,<p>Hello!</p><input />")
def add_input_text(self, sb, text):
sb.type("input", text)
class ObjTests(BaseCase):
def test_data_url_page(self):
DataPage().go_to_data_url(self)
self.assert_text("Hello!", "p")
DataPage().add_input_text(self, "Goodbye!") After you modify your files to correctly use that format, they will look like this: # aa.py
class EapCase:
def test_add_eap(self, sb):
sb.open("http://192.168.11.11:80/") # bb.py
import aa
class FdcCase(BaseCase):
def test_add_fdc(self):
aa.EapCase().test_add_eap(self)
self.open("http://192.168.11.11:80/") |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
mdmintz
-
Can I keep this format on both sides? Is there any other solution Thank you |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The example from SeleniumBase/examples/boilerplates/classic_obj_test.py covers your scenario:
After you modify your files to correctly use that format, they will look like this: