From 52a404663100d8b31bc28cf3fba34b0d891b34a2 Mon Sep 17 00:00:00 2001 From: Samirgorai Date: Sun, 31 Dec 2023 22:16:22 +0530 Subject: [PATCH] "Yahoo Finance Premium instituting recaptcha #254" Cause of the error might be that in username page contains multiple names with 'id=login-username' because of it was not able to login and resulting in error and providing us message:"Unable to login and/or retrieve the appropriate cookies. This is " most likely due to Yahoo Finance instituting recaptcha, which " this package does not support." i changed the method of finding the element to By.XPATH Signed-off-by: Samir Gorai --- yahooquery/headless.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/yahooquery/headless.py b/yahooquery/headless.py index 4fd2db2..aac2b8f 100644 --- a/yahooquery/headless.py +++ b/yahooquery/headless.py @@ -39,7 +39,8 @@ def login(self): try: self.driver.execute_script("window.open('{}');".format(self.LOGIN_URL)) self.driver.switch_to.window(self.driver.window_handles[-1]) - self.driver.find_element(By.ID, "login-username").send_keys(self.username) + #self.driver.find_element(By.ID, "login-username").send_keys(self.username) + self.driver.find_element(By.XPATH, "//input[@id='login-username']").send_keys(self.username) self.driver.find_element(By.XPATH, "//input[@id='login-signin']").click() password_element = WebDriverWait(self.driver, 10).until( EC.presence_of_element_located((By.ID, "login-passwd"))