Skip to content

Commit 96cbd51

Browse files
committed
Update example tests
1 parent c09098e commit 96cbd51

File tree

6 files changed

+24
-14
lines changed

6 files changed

+24
-14
lines changed

examples/wordle_archive_test.py renamed to examples/old_wordle_script.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
""" Solve the Wordle game using SeleniumBase.
2-
This test runs on archived versions of Wordle, containing Shadow-DOM. """
1+
"""
2+
Solve the Wordle game using SeleniumBase.
3+
This test runs on archived versions of Wordle, containing Shadow-DOM.
4+
"""
35

46
import ast
57
import random
@@ -86,7 +88,7 @@ def test_wordle(self):
8688
keyboard_base = "game-app::shadow game-keyboard::shadow "
8789
word = random.choice(self.word_list)
8890
num_attempts = 0
89-
success = False
91+
found_word = False
9092
for attempt in range(6):
9193
num_attempts += 1
9294
word = random.choice(self.word_list)
@@ -105,13 +107,13 @@ def test_wordle(self):
105107
letter_eval = self.get_attribute(tile % str(i), "evaluation")
106108
letter_status.append(letter_eval)
107109
if letter_status.count("correct") == 5:
108-
success = True
110+
found_word = True
109111
break
110112
self.word_list.remove(word)
111113
self.modify_word_list(word, letter_status)
112114

113115
self.save_screenshot_to_logs()
114-
if success:
116+
if found_word:
115117
print('Word: "%s"\nAttempts: %s' % (word.upper(), num_attempts))
116118
else:
117119
print('Final guess: "%s" (Not the correct word!)' % word.upper())

examples/raw_parameter_script.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
8080
sb.maximize_option = False
8181
sb._disable_beforeunload = False
8282
sb.save_screenshot_after_test = False
83+
sb.no_screenshot_after_test = False
8384
sb.page_load_strategy = None
8485
sb.timeout_multiplier = None
8586
sb.pytest_html_report = None

examples/test_apple_site.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,15 @@ def test_apple_developer_site_webdriver_instructions(self):
88
self.demo_mode = True
99
self.demo_sleep = 0.5
1010
self.message_duration = 2.0
11-
if self.headless and (
12-
self.browser == "chrome" or self.browser == "edge"
13-
):
14-
self.get_new_driver(browser=self.browser, headless2=True)
11+
if self.headless:
12+
if self._multithreaded:
13+
print("Skipping test in headless multi-threaded mode.")
14+
self.skip("Skipping test in headless multi-threaded mode.")
15+
elif self.undetectable:
16+
print("Skipping test in headless undetectable mode.")
17+
self.skip("Skipping test in headless undetectable mode.")
18+
elif self.browser == "chrome" or self.browser == "edge":
19+
self.get_new_driver(browser=self.browser, headless2=True)
1520
self.open("https://developer.apple.com/search/")
1621
title = "Testing with WebDriver in Safari"
1722
self.type('[placeholder*="developer.apple.com"]', title + "\n")

examples/test_get_locale_code.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
class LocaleTests(BaseCase):
55
def test_get_locale_code(self):
6-
self.open("data:,")
6+
self.open("about:blank")
77
locale_code = self.get_locale_code()
88
message = '\nLocale Code = "%s"' % locale_code
99
print(message)

examples/visual_testing/test_layout_fail.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def test_applitools_change(self):
2222
# Click a button that changes the text of an element
2323
self.click('a[href="?diff1"]')
2424
# Click a button that makes a hidden element visible
25-
self.click("button")
25+
self.slow_click("button")
2626
print("(This test should fail)") # due to image now seen
2727
self.check_window(name="helloworld", level=3)
2828

examples/wordle_test.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def test_wordle(self):
6464
self.initialize_word_list()
6565
word = random.choice(self.word_list)
6666
num_attempts = 0
67-
success = False
67+
found_word = False
6868
for attempt in range(6):
6969
num_attempts += 1
7070
word = random.choice(self.word_list)
@@ -74,25 +74,27 @@ def test_wordle(self):
7474
button = 'button[data-key="%s"]' % letter
7575
self.click(button)
7676
button = 'button[class*="oneAndAHalf"]'
77+
self.wait_for_ready_state_complete()
7778
self.click(button)
7879
row = (
7980
'div[class*="lbzlf"] div[class*="Row-module"]:nth-of-type(%s) '
8081
% num_attempts
8182
)
8283
tile = row + 'div:nth-child(%s) div[class*="module_tile__3ayIZ"]'
8384
self.wait_for_element(tile % "5" + '[data-state*="e"]')
85+
self.wait_for_ready_state_complete()
8486
letter_status = []
8587
for i in range(1, 6):
8688
letter_eval = self.get_attribute(tile % str(i), "data-state")
8789
letter_status.append(letter_eval)
8890
if letter_status.count("correct") == 5:
89-
success = True
91+
found_word = True
9092
break
9193
self.word_list.remove(word)
9294
self.modify_word_list(word, letter_status)
9395

9496
self.save_screenshot_to_logs()
95-
if success:
97+
if found_word:
9698
print('\nWord: "%s"\nAttempts: %s' % (word.upper(), num_attempts))
9799
else:
98100
print('Final guess: "%s" (Not the correct word!)' % word.upper())

0 commit comments

Comments
 (0)