-
Notifications
You must be signed in to change notification settings - Fork 1.4k
-
My ConfTest file:
image
Here's my test_login file:
image
When I run test_login.py, the inside self automatically creates a new browser window, instead of using the browser window generated by the confTest method
Conftest. py is executed before PyTest has another test item, so you can write some precursors.
What do I have to do to make conftest.py work properly? I have tried using methods like sb.click() that do not create new Windows without using BaseCase. But there is no code completion function in the writing process, which is very inconvenient
What should I do
Beta Was this translation helpful? Give feedback.
All reactions
Hi @HellShuro,
For the code auto-completion part, you'll need to use BaseCase
inheritance, as most code editors will not be able to parse the methods from the pytest sb
fixture.
For all standard SeleniumBase tests, the browser is spun up automatically at the start of every test, and then spun down automatically at the end of it. It replaces the need for having to use a conftest.py
file to do that. If you need more driver control, you can use the example from https://github.com/seleniumbase/SeleniumBase/blob/master/examples/test_override_driver.py for overriding the driver as needed. You can also override the setUp()
and tearDown()
methods from tests that inherit BaseCase
(see https://gith...
Replies: 1 comment 2 replies
-
Hi @HellShuro,
For the code auto-completion part, you'll need to use BaseCase
inheritance, as most code editors will not be able to parse the methods from the pytest sb
fixture.
For all standard SeleniumBase tests, the browser is spun up automatically at the start of every test, and then spun down automatically at the end of it. It replaces the need for having to use a conftest.py
file to do that. If you need more driver control, you can use the example from https://github.com/seleniumbase/SeleniumBase/blob/master/examples/test_override_driver.py for overriding the driver as needed. You can also override the setUp()
and tearDown()
methods from tests that inherit BaseCase
(see https://github.com/seleniumbase/SeleniumBase/blob/master/examples/boilerplates/base_test_case.py for more info).
Beta Was this translation helpful? Give feedback.
All reactions
-
But I need to configure different initial actions for different files to be run, for example, for a.py, b.py I need to open Google.com first, for c.py, d.py I need to open YouTube.com, if each one is written in the header of the file then I need to write a lot of duplicate code, well, it doesn't look concise enough. Especially because I want each function to run independently, which means I need to write a self.open(url) in each function, which looks dumb.
I've been thinking about modifying the driver, and setUP, tearDown for a long time, and I still don't have a clue. Can you please provide some more detailed ideas?
Translated with www.DeepL.com/Translator (free version)
Beta Was this translation helpful? Give feedback.
All reactions
-
I gave up and am going to use an override of the setUp method to achieve the effect.
Beta Was this translation helpful? Give feedback.
All reactions
-
👍 1