Skip to content

Commit 7fcfa76

Browse files
authored
Merge pull request #340 from seleniumbase/add-command-line-features
Add command line features for Chrome control
2 parents 460c684 + 9ec56db commit 7fcfa76

20 files changed

+313
-42
lines changed

examples/boilerplates/samples/google_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
class GoogleTests(BaseCase):
1010

1111
def test_google_dot_com(self):
12-
self.open('https://google.com')
12+
self.open('https://google.com/ncr')
1313
self.update_text(HomePage.search_box, 'github')
1414
self.assert_element(HomePage.list_box)
1515
self.assert_element(HomePage.search_button)

examples/github_test.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,20 @@
33

44
class GitHubTests(BaseCase):
55

6-
# Selenium can trigger GitHub's abuse detection mechanism:
7-
# "You have triggered an abuse detection mechanism."
8-
# "Please wait a few minutes before you try again."
9-
# To avoid this, slow_click() is being used to
10-
# slow down Selenium actions.
11-
126
def test_github(self):
7+
# Selenium can trigger GitHub's anti-automation system:
8+
# "You have triggered an abuse detection mechanism."
9+
# "Please wait a few minutes before you try again."
10+
# To avoid this automation blocker, two steps are being taken:
11+
# 1. self.slow_click() is being used to slow down Selenium actions.
12+
# 2. The browser's User Agent is modified to avoid Selenium-detection
13+
# when running in headless mode on Chrome.
14+
if self.browser == "chrome" and self.headless:
15+
self.driver.quit()
16+
self.get_new_driver(
17+
agent="""Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_4) """
18+
"""AppleWebKit/537.36 (KHTML, like Gecko) """
19+
"""Chrome/75.0.3770.100 Safari/537.36""")
1320
self.open("https://github.com/")
1421
self.update_text("input.header-search-input", "SeleniumBase\n")
1522
self.slow_click('a[href="/seleniumbase/SeleniumBase"]')

examples/parameterized_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ class GoogleTestClass(BaseCase):
1010
["seleniumbase", "https://github.com/seleniumbase/SeleniumBase"],
1111
])
1212
def test_parameterized_google_search(self, search_term, expected_url):
13-
self.open('https://google.com')
13+
self.open('https://google.com/ncr')
1414
self.update_text('input[title="Search"]', search_term + '\n')
1515
self.assert_text(expected_url, '#search')

examples/raw_parameter_script.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,13 @@
3333
b.data = None
3434
b.environment = "test"
3535
b.user_agent = None
36+
b.extension_zip = None
37+
b.extension_dir = None
3638
b.database_env = "test"
3739
b.log_path = "latest_logs/"
3840
b.archive_logs = False
3941
b.disable_csp = False
42+
b.enable_sync = False
4043
b.visual_baseline = False
4144
b.save_screenshot_after_test = False
4245
b.timeout_multiplier = None
@@ -49,6 +52,7 @@
4952
b.demo_mode = False
5053
b.demo_sleep = 1
5154
b.message_duration = 2
55+
b.user_data_dir = None
5256
b.proxy_string = None
5357
b.ad_block_on = False
5458
b.highlights = None

examples/tour_examples/bootstrap_google_tour.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
class MyTourClass(BaseCase):
55

66
def test_google_tour(self):
7-
self.open('https://google.com')
7+
self.open('https://google.com/ncr')
88
self.wait_for_element('input[title="Search"]')
99

1010
self.create_bootstrap_tour() # OR self.create_tour(theme="bootstrap")

examples/tour_examples/google_tour.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
class MyTourClass(BaseCase):
55

66
def test_google_tour(self):
7-
self.open('https://google.com')
7+
self.open('https://google.com/ncr')
88
self.wait_for_element('input[title="Search"]')
99

1010
# Create a website tour using the ShepherdJS library with "dark" theme

examples/tour_examples/hopscotch_google_tour.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
class MyTourClass(BaseCase):
55

66
def test_google_tour(self):
7-
self.open('https://google.com')
7+
self.open('https://google.com/ncr')
88
self.wait_for_element('input[title="Search"]')
99

1010
self.create_hopscotch_tour() # OR self.create_tour(theme="hopscotch")

examples/tour_examples/introjs_google_tour.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
class MyTourClass(BaseCase):
55

66
def test_google_tour(self):
7-
self.open('https://google.com')
7+
self.open('https://google.com/ncr')
88
self.wait_for_element('input[title="Search"]')
99

1010
self.create_introjs_tour() # OR self.create_tour(theme="introjs")

examples/tour_examples/shepherd_google_tour.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
class MyTourClass(BaseCase):
55

66
def test_google_tour(self):
7-
self.open('https://google.com')
7+
self.open('https://google.com/ncr')
88
self.wait_for_element('input[title="Search"]')
99

1010
self.create_shepherd_tour(theme="dark")

requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
pip>=19.1.1
22
setuptools>=41.0.1
3+
wheel>=0.33.4
34
six
45
nose
56
ipdb
@@ -26,6 +27,6 @@ pyopenssl>=19.0.0
2627
colorama>=0.4.1
2728
pyotp>=2.2.7
2829
boto>=2.49.0
29-
flake8>=3.7.7
30+
flake8>=3.7.8
3031
certifi>=2019.6.16
3132
PyVirtualDisplay==0.2.1

0 commit comments

Comments
 (0)