Selenium can't find non-visible element within scrollable div even though it is in the source

Viewed 58

So I want Selenium to click the below shown element (symbol="DKNG") which upon page launch is not within the viewport but in a scrollable div and thus also in the source.

<span class="inner-EJ_LFrif symbolNameText-EJ_LFrif">DKNG</span>

This approach works in case the element is visible right from page launch:

WebDriverWait(driver, 20).until(ec.element_to_be_clickable((By.XPATH, "//span[text()='" + symbol + "']"))).click()

But the desired case if the element is not visible on viewport on page launch doesn't work:

# Search the target element
target_element_in_panel = driver.find_element(By.XPATH, "//span[text()='" + symbol + "']")

actions = ActionChains(driver)
actions.move_to_element(target_element_in_panel).perform()
target_element_in_panel.click()

# returns -> selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//span[text()='DKNG']"}

The source page requires login (free content), here's the snip. Target element is in the scrollable div (yellow highlighted).

enter image description here

0 Answers
Related