(self)
| 71 | self.skip(message) |
| 72 | |
| 73 | def test_wordle(self): |
| 74 | self.skip_if_incorrect_env() |
| 75 | random.seed() |
| 76 | year = "2022" |
| 77 | month = random.randint(3, 5) |
| 78 | day = random.randint(1, 30) |
| 79 | date = str(year) + "0" + str(month) + str(day) |
| 80 | archive = "https://web.archive.org/web/" |
| 81 | url = "https://www.nytimes.com/games/wordle/index.html" |
| 82 | past_wordle = archive + date + "/" + url |
| 83 | print("\n" + past_wordle) |
| 84 | self.goto(past_wordle) |
| 85 | self.wait_for_element("#wm-ipp-base") |
| 86 | self.remove_elements("#wm-ipp-base") |
| 87 | self.click("game-app::shadow game-modal::shadow game-icon") |
| 88 | self.initialize_word_list() |
| 89 | keyboard_base = "game-app::shadow game-keyboard::shadow " |
| 90 | word = random.choice(self.word_list) |
| 91 | num_attempts = 0 |
| 92 | found_word = False |
| 93 | for attempt in range(6): |
| 94 | num_attempts += 1 |
| 95 | word = random.choice(self.word_list) |
| 96 | letters = [] |
| 97 | for letter in word: |
| 98 | letters.append(letter) |
| 99 | button = 'button[data-key="%s"]' % letter |
| 100 | self.click(keyboard_base + button) |
| 101 | button = "button.one-and-a-half" |
| 102 | self.click(keyboard_base + button) |
| 103 | row = 'game-app::shadow game-row[letters="%s"]::shadow ' % word |
| 104 | tile = row + "game-tile:nth-of-type(%s)" |
| 105 | self.wait_for_element(tile % "5" + '::shadow [data-state$="t"]') |
| 106 | self.wait_for_element( |
| 107 | tile % "5" + '::shadow [data-animation="idle"]' |
| 108 | ) |
| 109 | letter_status = [] |
| 110 | for i in range(1, 6): |
| 111 | letter_eval = self.get_attribute(tile % str(i), "evaluation") |
| 112 | letter_status.append(letter_eval) |
| 113 | if letter_status.count("correct") == 5: |
| 114 | found_word = True |
| 115 | break |
| 116 | self.word_list.remove(word) |
| 117 | self.modify_word_list(word, letter_status) |
| 118 | |
| 119 | self.save_screenshot_to_logs() |
| 120 | if found_word: |
| 121 | print('Word: "%s"\nAttempts: %s' % (word.upper(), num_attempts)) |
| 122 | else: |
| 123 | print('Final guess: "%s" (Not the correct word!)' % word.upper()) |
| 124 | self.fail("Unable to solve for the correct word in 6 attempts!") |
| 125 | self.sleep(3) |
nothing calls this directly
no test coverage detected