Skip to content

Commit 43ae2b8

Browse files
authored
Merge pull request #453 from seleniumbase/improve-firefox-compatibility
Update Firefox settings, dependencies, examples, and docs
2 parents 6154426 + 423ec8e commit 43ae2b8

File tree

8 files changed

+87
-98
lines changed

8 files changed

+87
-98
lines changed

.github/Workflows.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
### <img src="https://cdn2.hubspot.net/hubfs/100006/images/super_square_logo_3a.png" title="SeleniumBase" height="32"> SeleniumBase Workflows
22

33
> **Table of Contents / Navigation:**
4-
> - [**CI Tests**](workflows/python-package.yml)
4+
> - [**CI build**](workflows/python-package.yml)

README.md

Lines changed: 40 additions & 84 deletions
Large diffs are not rendered by default.

examples/test_hack_search.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
""" Testing the "self.set_attribute()" and "self.set_attributes()" methods
2+
to modify a Google search into becoming a Bing search.
3+
set_attribute() -> Modifies the attribute of the first matching element.
4+
set_attributes() -> Modifies the attribute of all matching elements. """
5+
6+
from seleniumbase import BaseCase
7+
8+
9+
class HackingTest(BaseCase):
10+
11+
def test_hack_search(self):
12+
self.open("https://google.com/ncr")
13+
self.assert_element('input[title="Search"]')
14+
self.set_attribute('[action="/search"]', "action", "//bing.com/search")
15+
self.set_attributes('[value="Google Search"]', "value", "Bing Search")
16+
self.update_text('input[title="Search"]', "SeleniumBase GitHub")
17+
self.click('[value="Bing Search"]')
18+
self.assert_element("h1.b_logo")
19+
self.click('[href*="github.com/seleniumbase/SeleniumBase"]')
20+
self.assert_element('[href="/seleniumbase/SeleniumBase"]')
21+
self.assert_true("seleniumbase/SeleniumBase" in self.get_current_url())
22+
self.click('[title="examples"]')
23+
self.assert_text('examples', 'strong.final-path')

help_docs/method_summary.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,7 @@ self.get_attribute(selector, attribute, by=By.CSS_SELECTOR, timeout=None)
7171
self.set_attribute(selector, attribute, value, by=By.CSS_SELECTOR, timeout=None)
7272

7373
self.set_attributes(selector, attribute, value, by=By.CSS_SELECTOR)
74-
75-
self.set_attribute_all(selector, attribute, value, by=By.CSS_SELECTOR)
74+
# Duplicates: self.set_attribute_all(selector, attribute, value, by=By.CSS_SELECTOR)
7675

7776
self.remove_attribute(selector, attribute, by=By.CSS_SELECTOR, timeout=None)
7877

requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,15 @@ pytest-timeout>=1.3.3
2525
pytest-xdist>=1.31.0
2626
parameterized>=0.7.1
2727
soupsieve==1.9.5
28-
beautifulsoup4==4.8.1
28+
beautifulsoup4==4.8.2
2929
atomicwrites==1.3.0
3030
portalocker==1.5.2
3131
cryptography==2.8
3232
asn1crypto==1.2.0
3333
pyopenssl==19.1.0
3434
pygments==2.5.2
3535
colorama==0.4.3
36+
coverage>=5.0.1
3637
pymysql==0.9.3
3738
pyotp==2.3.0
3839
boto==2.49.0

seleniumbase/config/proxy_list.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020

2121
PROXY_LIST = {
2222
"example1": "104.236.248.219:3128", # (Example) - set your own proxy here
23-
"example2": "165.227.102.37:3128", # (Example) - set your own proxy here
24-
"example3": "23.244.28.27:3128", # (Example) - set your own proxy here
23+
"example2": "81.4.255.25:3128", # (Example) - set your own proxy here
24+
"example3": "52.187.121.7:3128", # (Example) - set your own proxy here
2525
"proxy1": None,
2626
"proxy2": None,
2727
"proxy3": None,

seleniumbase/core/browser_launcher.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -223,13 +223,15 @@ def _create_firefox_profile(
223223
profile.set_preference("pdfjs.disabled", True)
224224
profile.set_preference("app.update.auto", False)
225225
profile.set_preference("app.update.enabled", False)
226+
profile.set_preference("app.update.silent", True)
226227
profile.set_preference("browser.privatebrowsing.autostart", True)
227228
profile.set_preference("devtools.errorconsole.enabled", True)
228229
profile.set_preference("extensions.allowPrivateBrowsingByDefault", True)
229230
profile.set_preference("extensions.PrivateBrowsing.notification", False)
230231
profile.set_preference("extensions.systemAddon.update.enabled", False)
231232
profile.set_preference("extensions.update.autoUpdateDefault", False)
232233
profile.set_preference("extensions.update.enabled", False)
234+
profile.set_preference("extensions.update.silent", True)
233235
profile.set_preference(
234236
"datareporting.healthreport.logging.consoleEnabled", False)
235237
profile.set_preference("datareporting.healthreport.service.enabled", False)
@@ -514,27 +516,34 @@ def get_local_driver(
514516
if headless:
515517
options.add_argument('-headless')
516518
if LOCAL_GECKODRIVER and os.path.exists(LOCAL_GECKODRIVER):
517-
make_driver_executable_if_not(LOCAL_GECKODRIVER)
519+
try:
520+
make_driver_executable_if_not(LOCAL_GECKODRIVER)
521+
except Exception as e:
522+
print("\nWarning: Could not make geckodriver"
523+
" executable: %s" % e)
518524
elif not is_geckodriver_on_path():
519525
if not "".join(sys.argv) == "-c": # Skip if multithreaded
520526
from seleniumbase.console_scripts import sb_install
521527
sys_args = sys.argv # Save a copy of current sys args
522-
print("\nWarning: geckodriver not found."
528+
print("\nWarning: geckodriver not found!"
523529
" Installing now:")
524-
sb_install.main(override="geckodriver")
530+
try:
531+
sb_install.main(override="geckodriver")
532+
except Exception:
533+
print("\nWarning: Could not install geckodriver!")
525534
sys.argv = sys_args # Put back the original sys args
526535
firefox_driver = webdriver.Firefox(
527536
firefox_profile=profile,
528537
capabilities=firefox_capabilities,
529538
options=options)
530539
except WebDriverException:
531-
# Don't use Geckodriver: Only works for old versions of Firefox
540+
# Skip Firefox options and try again
532541
profile = _create_firefox_profile(
533542
downloads_path, proxy_string, user_agent, disable_csp)
534543
firefox_capabilities = DesiredCapabilities.FIREFOX.copy()
535-
firefox_capabilities['marionette'] = False
536544
firefox_driver = webdriver.Firefox(
537-
firefox_profile=profile, capabilities=firefox_capabilities)
545+
firefox_profile=profile,
546+
capabilities=firefox_capabilities)
538547
return firefox_driver
539548
except Exception as e:
540549
if headless:

setup.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545

4646
setup(
4747
name='seleniumbase',
48-
version='1.34.6',
48+
version='1.34.7',
4949
description='Fast, Easy, and Reliable Browser Automation & Testing.',
5050
long_description=long_description,
5151
long_description_content_type='text/markdown',
@@ -108,14 +108,15 @@
108108
'pytest-xdist>=1.31.0',
109109
'parameterized>=0.7.1',
110110
'soupsieve==1.9.5',
111-
'beautifulsoup4==4.8.1',
111+
'beautifulsoup4==4.8.2',
112112
'atomicwrites==1.3.0',
113113
'portalocker==1.5.2',
114114
'cryptography==2.8',
115115
'asn1crypto==1.2.0',
116116
'pyopenssl==19.1.0',
117117
'pygments>=2.5.2',
118118
'colorama==0.4.3',
119+
'coverage>=5.0.1',
119120
'pymysql==0.9.3',
120121
'pyotp==2.3.0',
121122
'boto==2.49.0',

0 commit comments

Comments
 (0)