Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

do i need to download the whole project-or just import seleniumbase #1052

Answered by mdmintz
tallevy22 asked this question in Q&A
Discussion options

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

You must be logged in to vote

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

Comment options

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.

You must be logged in to vote
2 replies
Comment options

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.

Comment options

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.

Answer selected by mdmintz
Comment options

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

You must be logged in to vote
2 replies
Comment options

@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.

Comment options

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

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /