Skip to content

Commit 3a58c51

Browse files
committed
Update the Wordle-solver example tests
1 parent 6f2fabe commit 3a58c51

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

examples/wordle_archive_test.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,16 @@ def test_wordle(self):
6969
archive = "https://web.archive.org/web/"
7070
url = "https://www.nytimes.com/games/wordle/index.html"
7171
past_wordle = archive + date + "/" + url
72-
print(past_wordle)
72+
print("\n" + past_wordle)
7373
self.open(past_wordle)
7474
self.click("game-app::shadow game-modal::shadow game-icon")
7575
self.initialize_word_list()
7676
keyboard_base = "game-app::shadow game-keyboard::shadow "
7777
word = random.choice(self.word_list)
78-
total_attempts = 0
78+
num_attempts = 0
7979
success = False
8080
for attempt in range(6):
81-
total_attempts += 1
81+
num_attempts += 1
8282
word = random.choice(self.word_list)
8383
letters = []
8484
for letter in word:
@@ -101,7 +101,9 @@ def test_wordle(self):
101101
self.modify_word_list(word, letter_status)
102102

103103
self.save_screenshot_to_logs()
104-
print('\nWord: "%s"\nAttempts: %s' % (word.upper(), total_attempts))
105-
if not success:
104+
if success:
105+
print('Word: "%s"\nAttempts: %s' % (word.upper(), num_attempts))
106+
else:
107+
print('Final guess: "%s" (Not the correct word!)' % word.upper())
106108
self.fail("Unable to solve for the correct word in 6 attempts!")
107109
self.sleep(3)

examples/wordle_test.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ def test_wordle(self):
6060
self.click('svg[data-testid="icon-close"]')
6161
self.initialize_word_list()
6262
word = random.choice(self.word_list)
63-
total_attempts = 0
63+
num_attempts = 0
6464
success = False
6565
for attempt in range(6):
66-
total_attempts += 1
66+
num_attempts += 1
6767
word = random.choice(self.word_list)
6868
letters = []
6969
for letter in word:
@@ -74,7 +74,7 @@ def test_wordle(self):
7474
self.click(button)
7575
row = (
7676
'div[class*="lbzlf"] div[class*="Row-module"]:nth-of-type(%s) '
77-
% total_attempts
77+
% num_attempts
7878
)
7979
tile = row + 'div:nth-child(%s) div[class*="module_tile__3ayIZ"]'
8080
self.wait_for_element(tile % "5" + '[data-state*="e"]')
@@ -89,7 +89,9 @@ def test_wordle(self):
8989
self.modify_word_list(word, letter_status)
9090

9191
self.save_screenshot_to_logs()
92-
print('\nWord: "%s"\nAttempts: %s' % (word.upper(), total_attempts))
93-
if not success:
92+
if success:
93+
print('\nWord: "%s"\nAttempts: %s' % (word.upper(), num_attempts))
94+
else:
95+
print('Final guess: "%s" (Not the correct word!)' % word.upper())
9496
self.fail("Unable to solve for the correct word in 6 attempts!")
9597
self.sleep(3)

0 commit comments

Comments
 (0)