Skip to content

Commit 386bfea

Browse files
authored
Merge pull request #1009 from seleniumbase/specify-executable-path-as-needed
Specify the driver executable_path as needed (and more)
2 parents 14c45cb + 50ca733 commit 386bfea

File tree

11 files changed

+95
-17
lines changed

11 files changed

+95
-17
lines changed

docs/requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
regex>=2021.9.30
1+
regex>=2021.10.8
22
tqdm>=4.62.3
33
livereload==2.6.3;python_version>="3.6"
44
joblib==1.1.0;python_version>="3.6"
@@ -10,7 +10,7 @@ python-dateutil==2.8.2
1010
keyring==23.2.1;python_version>="3.6"
1111
pkginfo==1.7.1;python_version>="3.6"
1212
Jinja2==3.0.2;python_version>="3.6"
13-
click==8.0.1;python_version>="3.6"
13+
click==8.0.2;python_version>="3.6"
1414
zipp==3.6.0;python_version>="3.6"
1515
readme-renderer==30.0
1616
pymdown-extensions==9.0;python_version>="3.6"

examples/test_demo_site.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@ def test_demo_site(self):
2222
# Verify that a hover dropdown link changes page text
2323
self.assert_text("Automation Practice", "h3")
2424
try:
25-
self.hover_and_click("#myDropdown", "#dropOption2")
25+
self.hover_and_click(
26+
"#myDropdown", "#dropOption2", timeout=2)
2627
except Exception:
27-
# If the user moves the mouse while the test runs
28+
# If a human moves the mouse while the test runs
2829
self.js_click("#dropOption2")
2930
self.assert_text("Link Two Selected", "h3")
3031

@@ -107,6 +108,11 @@ def test_demo_site(self):
107108
# Highlight a page element (Also asserts visibility)
108109
self.highlight("h2")
109110

111+
# Actions with Demo Mode enabled
112+
self.demo_mode = True
113+
self.type("input", "Have a Nice Day!")
114+
self.assert_text("SeleniumBase", "h2")
115+
110116
# Assert no broken links (Can be slow if many links)
111117
# self.assert_no_404_errors()
112118

help_docs/install_python_pip_git.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,33 +24,40 @@ pip install -U setuptools
2424
If that didn't work, here are some more commands you can try:
2525

2626
On macOS / Windows / Linux, run the following command:
27+
2728
```bash
2829
python -m ensurepip --default-pip
2930
```
3031

3132
If your existing version of pip is old, upgrade to the latest version:
33+
3234
```bash
3335
python -m pip install --upgrade pip setuptools
3436
```
3537

3638
On CentOS 7 and some versions of Linux, you may need to install pip with ``yum``:
39+
3740
```bash
3841
yum -y update
3942
yum -y install python-pip
4043
```
4144

42-
If you're having any trouble getting pip, you can [GET PIP HERE](https://pip.pypa.io/en/latest/installing/).
45+
If you're having any trouble getting pip, you can [GET PIP HERE](https://pip.pypa.io/en/latest/installation/).
4346

4447
When done, make sure the location of pip is on your path, which is ``$PATH`` for macOS/Linux. (On Windows, it's the System Variables ``Path`` within System Environment Variables.)
4548

4649
You can also get pip (or fix pip) by using:
50+
4751
```bash
4852
curl https://bootstrap.pypa.io/get-pip.py | python
4953
```
54+
5055
* (If you get SSL errors while trying to install packages with pip, see [this Stackoverflow post](https://stackoverflow.com/questions/49768770/not-able-to-install-python-packages-ssl-tlsv1-alert-protocol-version), which tells you to run the above command.)
5156

5257
**Keep Pip and Setuptools up-to-date:**
53-
```
58+
59+
```bash
5460
python -m pip install -U pip setuptools
5561
```
62+
5663
* (Depending on your user permissions, you may need to add ``--user`` to the command if you're not inside a [Python virtual environment](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/virtualenv_instructions.md), or use "[sudo](https://en.wikipedia.org/wiki/Sudo)" on a UNIX-based OS if you're getting errors during installation.)

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ wheel>=0.37.0
1313
attrs>=21.2.0
1414
PyYAML>=5.4.1;python_version>="3.6"
1515
sortedcontainers==2.4.0
16-
certifi>=2021.5.30
16+
certifi>=2021.10.8
1717
six==1.16.0
1818
nose==1.3.7
1919
ipdb==0.13.4;python_version<"3.5"

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.66.10"
2+
__version__ = "1.66.11"

seleniumbase/console_scripts/ReadMe.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ test frameworks.
8686

8787
```bash
8888
ui_tests/
89-
9089
├── __init__.py
9190
├── my_first_test.py
9291
├── parameterized_test.py
@@ -95,15 +94,13 @@ ui_tests/
9594
├── setup.cfg
9695
├── test_demo_site.py
9796
└── boilerplates/
98-
9997
├── __init__.py
10098
├── base_test_case.py
10199
├── boilerplate_test.py
102100
├── classic_obj_test.py
103101
├── page_objects.py
104102
├── sb_fixture_test.py
105103
└── samples/
106-
107104
├── __init__.py
108105
├── google_objects.py
109106
├── google_test.py
@@ -115,7 +112,6 @@ If running with the ``-b`` or ``--basic`` option:
115112

116113
```bash
117114
ui_tests/
118-
119115
├── __init__.py
120116
├── pytest.ini
121117
├── requirements.txt

seleniumbase/console_scripts/sb_mkchart.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ def main():
263263
file = codecs.open(file_path, "w+", "utf-8")
264264
file.writelines("\r\n".join(data))
265265
file.close()
266+
os.system("sbase print %s -n" % file_name)
266267
success = (
267268
"\n" + c1 + '* Chart Presentation: "' + file_name + '" was created! *'
268269
"" + cr + "\n"

seleniumbase/console_scripts/sb_mkdir.py

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,18 @@ def main():
291291
file.close()
292292

293293
if basic:
294+
data = []
295+
data.append(" %s/" % dir_name)
296+
data.append(" ├── __init__.py")
297+
data.append(" ├── pytest.ini")
298+
data.append(" ├── requirements.txt")
299+
data.append(" └── setup.cfg")
300+
file_path = "%s/%s" % (dir_name, "outline.txt")
301+
file = codecs.open(file_path, "w+", "utf-8")
302+
file.writelines("\r\n".join(data))
303+
file.close()
304+
os.system("sbase print %s -n" % file_path)
305+
os.remove(file_path)
294306
success = (
295307
"\n" + c1 + '* Directory "' + dir_name + '" was created '
296308
"with config files! *" + cr + "\n"
@@ -337,7 +349,12 @@ def main():
337349
data.append(' self.type("textarea.area1", "Testing Time!\\n")')
338350
data.append(' self.type(\'[name="preText2"]\', "Typing Text!")')
339351
data.append(' self.assert_text("Automation Practice", "h3")')
340-
data.append(' self.hover_and_click("#myDropdown", "#dropOption2")')
352+
data.append(" try:")
353+
data.append(" self.hover_and_click(")
354+
data.append(' "#myDropdown", "#dropOption2", timeout=2)')
355+
data.append(" except Exception:")
356+
data.append(" # If a human moves the mouse while the test runs")
357+
data.append(' self.js_click("#dropOption2")')
341358
data.append(' self.assert_text("Link Two Selected", "h3")')
342359
data.append(' self.assert_text("This Text is Green", "#pText")')
343360
data.append(' self.click("#myButton")')
@@ -393,6 +410,9 @@ def main():
393410
data.append(' self.click_link("SeleniumBase Demo Page")')
394411
data.append(' self.assert_exact_text("Demo Page", "h1")')
395412
data.append(' self.highlight("h2")')
413+
data.append(" self.demo_mode = True")
414+
data.append(' self.type("input", "Have a Nice Day!")')
415+
data.append(' self.assert_text("SeleniumBase", "h2")')
396416
data.append("")
397417
file_path = "%s/%s" % (dir_name, "test_demo_site.py")
398418
file = codecs.open(file_path, "w+", "utf-8")
@@ -649,6 +669,35 @@ def main():
649669
file.writelines("\r\n".join(data))
650670
file.close()
651671

672+
data = []
673+
data.append(" %s/" % dir_name)
674+
data.append(" ├── __init__.py")
675+
data.append(" ├── my_first_test.py")
676+
data.append(" ├── parameterized_test.py")
677+
data.append(" ├── pytest.ini")
678+
data.append(" ├── requirements.txt")
679+
data.append(" ├── setup.cfg")
680+
data.append(" ├── test_demo_site.py")
681+
data.append(" └── boilerplates/")
682+
data.append(" ├── __init__.py")
683+
data.append(" ├── base_test_case.py")
684+
data.append(" ├── boilerplate_test.py")
685+
data.append(" ├── classic_obj_test.py")
686+
data.append(" ├── page_objects.py")
687+
data.append(" ├── sb_fixture_test.py")
688+
data.append(" └── samples/")
689+
data.append(" ├── __init__.py")
690+
data.append(" ├── google_objects.py")
691+
data.append(" ├── google_test.py")
692+
data.append(" ├── sb_swag_test.py")
693+
data.append(" └── swag_labs_test.py")
694+
file_path = "%s/%s" % (dir_name, "outline.txt")
695+
file = codecs.open(file_path, "w+", "utf-8")
696+
file.writelines("\r\n".join(data))
697+
file.close()
698+
os.system("sbase print %s -n" % file_path)
699+
os.remove(file_path)
700+
652701
success = (
653702
"\n" + c1 + '* Directory "' + dir_name + '" was created '
654703
"with config files and sample tests! *" + cr + "\n"

seleniumbase/console_scripts/sb_mkpres.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ def main():
282282
file = codecs.open(file_path, "w+", "utf-8")
283283
file.writelines("\r\n".join(data))
284284
file.close()
285+
os.system("sbase print %s -n" % file_name)
285286
success = (
286287
"\n" + c1 + '* Presentation: "' + file_name + '" was created! *'
287288
"" + cr + "\n"

seleniumbase/core/browser_launcher.py

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,7 +1129,13 @@ def get_local_driver(
11291129
capabilities=firefox_capabilities, options=firefox_options
11301130
)
11311131
else:
1132-
return webdriver.Firefox(options=firefox_options)
1132+
if os.path.exists(LOCAL_GECKODRIVER):
1133+
return webdriver.Firefox(
1134+
executable_path=LOCAL_GECKODRIVER,
1135+
options=firefox_options,
1136+
)
1137+
else:
1138+
return webdriver.Firefox(options=firefox_options)
11331139
elif browser_name == constants.Browser.INTERNET_EXPLORER:
11341140
if not IS_WINDOWS:
11351141
raise Exception(
@@ -1534,7 +1540,13 @@ def get_local_driver(
15341540
sys.argv = sys_args # Put back original sys args
15351541
if not headless or "linux" not in PLATFORM:
15361542
try:
1537-
driver = webdriver.Chrome(options=chrome_options)
1543+
if os.path.exists(LOCAL_CHROMEDRIVER):
1544+
driver = webdriver.Chrome(
1545+
executable_path=LOCAL_CHROMEDRIVER,
1546+
options=chrome_options,
1547+
)
1548+
else:
1549+
driver = webdriver.Chrome(options=chrome_options)
15381550
except Exception as e:
15391551
auto_upgrade_chromedriver = False
15401552
if "This version of ChromeDriver only supports" in e.msg:
@@ -1599,7 +1611,13 @@ def get_local_driver(
15991611
chrome_options, headless_options
16001612
)
16011613
_mark_chromedriver_repaired()
1602-
driver = webdriver.Chrome(options=chrome_options)
1614+
if os.path.exists(LOCAL_CHROMEDRIVER):
1615+
driver = webdriver.Chrome(
1616+
executable_path=LOCAL_CHROMEDRIVER,
1617+
options=chrome_options,
1618+
)
1619+
else:
1620+
driver = webdriver.Chrome(options=chrome_options)
16031621
return driver
16041622
else: # Running headless on Linux
16051623
try:

0 commit comments

Comments
 (0)