Skip to content

Commit 91ca4a2

Browse files
authored
Merge pull request #908 from seleniumbase/invoke-with-python-dash-m
Invoke console scripts with: "python -m seleniumbase"
2 parents dd54fd3 + 4c3a10c commit 91ca4a2

File tree

11 files changed

+73
-6
lines changed

11 files changed

+73
-6
lines changed

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ ENV/
2727
VENV/
2828
env.bak/
2929
venv.bak/
30-
sbase
31-
sbase*
30+
.sbase
31+
.sbase*
3232
seleniumbase_env
3333
seleniumbase_venv
3434
sbase_env

docs/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ joblib==1.0.1;python_version>="3.6"
55
Markdown==3.3.4;python_version>="3.6"
66
MarkupSafe==2.0.1;python_version>="3.6"
77
docutils==0.17.1
8-
Jinja2==3.0.0;python_version>="3.6"
8+
Jinja2==3.0.1;python_version>="3.6"
99
click==8.0.0
1010
readme-renderer==29.0
1111
pymdown-extensions==8.2

help_docs/customizing_test_runs.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,12 @@ pytest my_first_test.py --server=USERNAME:[email protected] --port=80
211211

212212
Or you can create your own Selenium Grid for test distribution. ([See this ReadMe for details](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/utilities/selenium_grid/ReadMe.md))
213213

214+
To use a server on the ``https`` protocol, add ``--protocol=https``:
215+
216+
```bash
217+
pytest test_suite.py --protocol=https --server=IP_ADDRESS --port=PORT
218+
```
219+
214220
<h3><img src="https://seleniumbase.io/img/logo6.png" title="SeleniumBase" width="28" /> Example tests using Logging:</h3>
215221

216222
```bash

sbase/ReadMe.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
"SBase" is the short name of "SeleniumBase".
2+
Use with console scripts: "python -m sbase".

sbase/__init__.py

Whitespace-only changes.

sbase/__main__.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import os
2+
import sys
3+
4+
# Remove "" and current working directory from the first entry
5+
# of sys.path (if present) to avoid using the current directory
6+
# in SeleniumBase commands when invoked as "python -m sbase <command>"
7+
if sys.path[0] in ("", os.getcwd()):
8+
sys.path.pop(0)
9+
10+
if __package__ == "":
11+
path = os.path.dirname(os.path.dirname(__file__))
12+
sys.path.insert(0, path)
13+
14+
if __name__ == "__main__":
15+
import warnings
16+
from seleniumbase.console_scripts.run import main
17+
18+
warnings.filterwarnings(
19+
"ignore", category=DeprecationWarning, module=".*packaging\\.version"
20+
)
21+
main()
22+
sys.exit()

seleniumbase/__main__.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import os
2+
import sys
3+
4+
# Remove "" and current working directory from the first entry
5+
# of sys.path (if present) to avoid using the current directory
6+
# in SeleniumBase commands when invoked as "python -m seleniumbase <command>"
7+
if sys.path[0] in ("", os.getcwd()):
8+
sys.path.pop(0)
9+
10+
if __package__ == "":
11+
path = os.path.dirname(os.path.dirname(__file__))
12+
sys.path.insert(0, path)
13+
14+
if __name__ == "__main__":
15+
import warnings
16+
from seleniumbase.console_scripts.run import main
17+
18+
warnings.filterwarnings(
19+
"ignore", category=DeprecationWarning, module=".*packaging\\.version"
20+
)
21+
main()
22+
sys.exit()

seleniumbase/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# seleniumbase package
2-
__version__ = "1.63.6"
2+
__version__ = "1.63.7"

seleniumbase/console_scripts/sb_mkdir.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,8 @@ def main():
205205
data.append("VENV/")
206206
data.append("env.bak/")
207207
data.append("venv.bak/")
208-
data.append("sbase")
209-
data.append("sbase*")
208+
data.append(".sbase")
209+
data.append(".sbase*")
210210
data.append("seleniumbase_env")
211211
data.append("seleniumbase_venv")
212212
data.append("sbase_env")

seleniumbase/utilities/selenium_grid/ReadMe.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,15 @@ The following commands will work once you've installed seleniumbase.
1313
```bash
1414
seleniumbase download server
1515
```
16+
1617
* (Required for using your own Selenium Grid)
1718

1819
<h4><img src="https://seleniumbase.io/img/sb_icon.png" title="SeleniumBase" width="30" /> Grid Hub server controls:</h4>
1920

2021
```bash
2122
seleniumbase grid-hub {start|stop|restart} [OPTIONS]
2223
```
24+
2325
<b>Options:</b>
2426
<ul>
2527
<li> -v / --verbose (Increases verbosity of logging output.)</li>
@@ -31,6 +33,7 @@ seleniumbase grid-hub {start|stop|restart} [OPTIONS]
3133
```bash
3234
seleniumbase grid-node {start|stop|restart} --hub=[HUB_IP] [OPTIONS]
3335
```
36+
3437
<b>Options:</b>
3538
<ul>
3639
<li> -v / --verbose (Increases verbosity of logging output.)</li>
@@ -48,30 +51,41 @@ pytest test_suite.py --server=IP_ADDRESS --port=4444
4851
You can also run your tests on someone else's Selenium Grid to avoid managing your own. Here are some Selenium Grids that you can use (and the run command format):
4952

5053
* [BrowserStack](https://www.browserstack.com/automate#) Selenium Grid:
54+
5155
```bash
5256
pytest my_first_test.py --server=USERNAME:[email protected] --port=80
5357
```
5458

5559
* [Sauce Labs](https://saucelabs.com/products/open-source-frameworks/selenium) Selenium Grid:
60+
5661
```bash
5762
pytest my_first_test.py --server=USERNAME:[email protected] --port=80
5863
```
5964

6065
* [TestingBot](https://testingbot.com/features) Selenium Grid:
66+
6167
```bash
6268
pytest my_first_test.py --server=USERNAME:[email protected] --port=80
6369
```
6470

6571
* [CrossBrowserTesting](https://help.crossbrowsertesting.com/selenium-testing/getting-started/python/) Selenium Grid:
72+
6673
```bash
6774
pytest my_first_test.py --server=USERNAME:[email protected] --port=80
6875
```
6976

7077
* [LambdaTest](https://www.lambdatest.com/selenium-automation) Selenium Grid:
78+
7179
```bash
7280
pytest my_first_test.py --server=USERNAME:[email protected] --port=80
7381
```
7482

83+
To use a server on the ``https`` protocol, add ``--protocol=https``:
84+
85+
```bash
86+
pytest test_suite.py --protocol=https --server=IP_ADDRESS --port=PORT
87+
```
88+
7589
(For setting browser desired capabilities while running Selenium remotely, see the <a href="https://seleniumbase.io/help_docs/desired_capabilities/">desired capabilities documentation</a> and the sample files located in <a href="https://github.com/seleniumbase/SeleniumBase/tree/master/examples/capabilities">SeleniumBase/examples/capabilities</a>)
7690

7791
<h4><img src="https://seleniumbase.io/img/sb_icon.png" title="SeleniumBase" width="30" /> More info about the Selenium Grid Hub can be found here:</h4>

0 commit comments

Comments
 (0)