Try to search your question here, if you can't find : Ask Any Question Now ?

Python Selenium: How to fix 'StaleElementReferenceException'

HomeCategory: stackoverflowPython Selenium: How to fix 'StaleElementReferenceException'
Avatarpushpa asked 2 weeks ago

I’m trying to extract past one year prices from (https://www.deribit.com/prinx_chart).

I’ve tried several ways to do that, however I always end up losing login details and unable to download the file.
Here’s my recent code:

from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import TimeoutException

options = webdriver.ChromeOptions()
preferences = {"download.default_directory" : "D:scrapping",
               "safebrowsing.enabled": False}
options.add_experimental_option("prefs", preferences)

driver = webdriver.Chrome(options = options, 
                          executable_path = 'D:\chromedriver.exe')
driver.maximize_window()
driver.get('https://www.deribit.com/')

driver.find_element_by_xpath("""//input[@type = "email"]""").send_keys(************).click()
driver.find_element_by_xpath("""//input[@type = "password"]""").send_keys(*********).click()

driver.find_element_by_name("go").click()
driver.get('https://www.deribit.com/prinx_chart')
driver.implicitly_wait(20)

element1 = driver.find_element_by_xpath("""//button[@title="1 year"]""")
element2 = driver.find_element_by_xpath("""//div[@class="pull-right context-menu btn-group"]""")
element3 = driver.find_element_by_xpath("""//*[@id="chartmenu"]/li/a""")

hoverover = ActionChains(driver).move_to_element(element1).move_to_element(
    element2).move_to_element(element3).click().perform()

As I said, unable to download the file and get an error which says not signed in. Where am I wrong here? Please help!

1 Answers
Best Answer
AvatarMikhail answered 2 weeks ago
Your Answer

1 + 20 =

Popular Tags

WP Facebook Auto Publish Powered By : XYZScripts.com