This repository was archived by the owner on Nov 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathverbalMemory.py
More file actions
44 lines (35 loc) · 1.32 KB
/
verbalMemory.py
File metadata and controls
44 lines (35 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium import webdriver
import time
# Initialize the WebDriver
driver = webdriver.Chrome()
# Navigate to the website
driver.get("https://humanbenchmark.com/tests/verbal-memory")
# Accept Cookies
time.sleep(1.5)
try:
driver.find_element(By.XPATH, "//span[contains(text(),'AGREE')]").click()
except Exception:
print("No cookie acceptance button found, or already accepted.")
# Start the test
try:
WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, "//button[contains(text(),'Start')]"))).click()
except Exception:
print("Start button not found")
# Initialize word list
wordList = []
try:
while True:
# Get the current word
word = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.CLASS_NAME, "word"))).text
# Click 'SEEN' if the word is in the list, otherwise click 'NEW' and add to the list
if word in wordList:
driver.find_element(By.XPATH, "//button[contains(text(),'SEEN')]").click()
else:
driver.find_element(By.XPATH, "//button[contains(text(),'NEW')]").click()
wordList.append(word)
time.sleep(10)
except Exception:
driver.quit()