-
Notifications
You must be signed in to change notification settings - Fork 1.4k
-
Hi there,
first i want to thank you for this cool framework, it makes life easy even for those who are not developers.
i wanted to ask if there is an easier, slimmer way to work with seleniumbase, can I just import the package?
thank you
Tal Levy
Beta Was this translation helpful? Give feedback.
All reactions
Hello @tallevy22, thank you,
You can just import the package to use it. Cloning it gives you the advantage of having all the example tests from the examples/
folder for learning SeleniumBase better. If you just import it, you may want to copy the pytest.ini
file from https://github.com/seleniumbase/SeleniumBase/blob/master/pytest.ini into the root folder. Or you can create a test directory with that and sample tests by running:
sbase mkdir FOLDER_NAME
Eg: sbase mkdir ui_tests
:
sbase mkdir ui_tests
1 ui_tests/
2 ├── __init__.py
3 ├── my_first_test.py
4 ├── parameterized_test.py
5 ├── pytest.ini
6 ├── requirements.txt
7 ├── setup.cfg...
Replies: 3 comments 4 replies
-
Hello @tallevy22, thank you,
You can just import the package to use it. Cloning it gives you the advantage of having all the example tests from the examples/
folder for learning SeleniumBase better. If you just import it, you may want to copy the pytest.ini
file from https://github.com/seleniumbase/SeleniumBase/blob/master/pytest.ini into the root folder. Or you can create a test directory with that and sample tests by running:
sbase mkdir FOLDER_NAME
Eg: sbase mkdir ui_tests
:
sbase mkdir ui_tests
1 ui_tests/
2 ├── __init__.py
3 ├── my_first_test.py
4 ├── parameterized_test.py
5 ├── pytest.ini
6 ├── requirements.txt
7 ├── setup.cfg
8 ├── test_demo_site.py
9 └── boilerplates/
10 ├── __init__.py
11 ├── base_test_case.py
12 ├── boilerplate_test.py
13 ├── classic_obj_test.py
14 ├── page_objects.py
15 ├── sb_fixture_test.py
16 └── samples/
17 ├── __init__.py
18 ├── google_objects.py
19 ├── google_test.py
20 ├── sb_swag_test.py
21 └── swag_labs_test.py
Or if you just want the folder setup without the sample tests, add -b
to that command:
sbase mkdir ui_tests -b
1 ui_tests/
2 ├── __init__.py
3 ├── pytest.ini
4 ├── requirements.txt
5 └── setup.cfg
(If the directory name already exists in that folder, it'll throw an error message so that it doesn't overwrite any folders.)
To see other console scripts such as sbase mkdir
, type sbase
on the command line.
Beta Was this translation helpful? Give feedback.
All reactions
-
thank you for your answer. i'm a beginner in python and in developing, is it possible to combine page locators and methods in the same class? (FYI I'm using Pycharm)
do I need to use sb? when I use sb. i don't see the completion of the method I'm trying to use, eg. sb.click---doesn't complete the click and doesn't show me the parameters I'm supposed to pass.
Beta Was this translation helpful? Give feedback.
All reactions
-
Hi @tallevy22 You could combine all that into one class. Eg: https://github.com/seleniumbase/SeleniumBase/blob/master/examples/boilerplates/samples/test_page_objects.py
The pytest sb
fixture for SeleniumBase won't do autocompletion in IDEs because most IDEs don't get the available methods from pytest fixtures.
Beta Was this translation helpful? Give feedback.
All reactions
-
the thing is that i want to create different tests using the methods and objects so I'm looking to separate them In different classes. eg---
Project
----pages
------methods
------locators
----tests
Beta Was this translation helpful? Give feedback.
All reactions
-
@tallevy22 See https://github.com/seleniumbase/SeleniumBase/blob/master/examples/boilerplates/boilerplate_test.py
That test has the structure you just described, where tests call methods and get locators from an external file located in that folder.
Beta Was this translation helpful? Give feedback.
All reactions
-
the example includes page methods in test class.
i was looking for an option to have the locators and page methods in a single class so in the test class under test folder I can call methods from different pages . by this I can create several tests flows through the pages.
(this is how i used Quantum if you are familiar with this framework)
thanks Tal
Beta Was this translation helpful? Give feedback.
All reactions
-
@tallevy22 Then maybe this has the examples you're looking for:
Subclass: https://github.com/seleniumbase/SeleniumBase/blob/master/examples/boilerplates/base_test_case.py
The test using it: https://github.com/seleniumbase/SeleniumBase/blob/master/examples/boilerplates/boilerplate_test.py
Beta Was this translation helpful? Give feedback.