I'm trying to scrape account value and cash using the function scrapeAccCash. However, it doesn't detect the text written in their HTML code. What's the problem? This code is a minimal reproducible example.
from selenium import webdriver
from selenium.webdriver.common.by import By
from webdriver_manager.chrome import ChromeDriverManager
import time
def login():
driver.get(r'https://www.investopedia.com/simulator/home.aspx')
driver.implicitly_wait(10)
driver.find_element(By.ID, 'username').send_keys('garewof922@sofrge.com')
time.sleep(0.5)
driver.find_element(By.ID, 'password').send_keys('Epefx8yGqFzSZL/')
time.sleep(0.5)
driver.find_element(By.ID, 'login').click()
try:
driver.find_element(By.XPATH, '//a[@class="text-h6 white--text pl-8 pr-8 v-tab"]').click()
except:
login()
def scrapeAccCash():
account = driver.find_element(By.XPATH, '//div[@data-cy="account-value"]').text
cash = driver.find_element(By.XPATH, '//div[@data-cy="cash"]').text
print(account, ", ", cash)
return float(account), float(cash)
driver = webdriver.Chrome(executable_path=ChromeDriverManager().install())
login()
acc, cash = scrapeAccCash()