I want to select an input field inside a modal. The first few are successfully being selected, but things that are not visible unless I scroll down are not being selected. The error messages say that the element is stale, or not visible. I’m trying to scroll down in the modal using selenium but I’m not able to select the modal itself. Below is the structure of what I’m trying to do:-
<code>from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
# Set the path to your WebDriver executable if not in your PATH
driver = webdriver.Chrome()
driver.get("URL_OF_YOUR_PAGE")
# Wait for the modal to be present (use explicit waits)
wait = WebDriverWait(driver, 10)
# Wait until the modal is present and visible
modal = wait.until(EC.presence_of_element_located((By.XPATH, '//modal[@au-target-id="4960"]')))
# Scroll down within the modal
actions = ActionChains(driver)
actions.move_to_element(modal).click().send_keys(Keys.PAGE_DOWN).perform()
# Perform additional actions if needed
<code>from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
# Set the path to your WebDriver executable if not in your PATH
driver = webdriver.Chrome()
# Open the webpage
driver.get("URL_OF_YOUR_PAGE")
# Wait for the modal to be present (use explicit waits)
wait = WebDriverWait(driver, 10)
try:
# Wait until the modal is present and visible
modal = wait.until(EC.presence_of_element_located((By.XPATH, '//modal[@au-target-id="4960"]')))
# Scroll down within the modal
actions = ActionChains(driver)
actions.move_to_element(modal).click().send_keys(Keys.PAGE_DOWN).perform()
# Perform additional actions if needed
# ...
finally:
# Close the driver
driver.quit()
</code>
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
# Set the path to your WebDriver executable if not in your PATH
driver = webdriver.Chrome()
# Open the webpage
driver.get("URL_OF_YOUR_PAGE")
# Wait for the modal to be present (use explicit waits)
wait = WebDriverWait(driver, 10)
try:
# Wait until the modal is present and visible
modal = wait.until(EC.presence_of_element_located((By.XPATH, '//modal[@au-target-id="4960"]')))
# Scroll down within the modal
actions = ActionChains(driver)
actions.move_to_element(modal).click().send_keys(Keys.PAGE_DOWN).perform()
# Perform additional actions if needed
# ...
finally:
# Close the driver
driver.quit()
I tried simply selecting the input field, the doesn’t work.
I’m trying to scroll down the modal but I’m stuck there.
<code>DevTools listening on ws://127.0.0.1:62074/devtools/browser/5c6417de-f0a9-4a10-b99c-ba18dcd6e60a
An error occurred: Message: javascript error: {"status":60,"value":"[object HTMLDivElement] has no size and location"}
(Session info: chrome=125.0.6422.61)
GetHandleVerifier [0x00007FF61C4322C2+60002]
(No symbol) [0x00007FF61C3ACA59]
(No symbol) [0x00007FF61C267EDA]
(No symbol) [0x00007FF61C26DD0E]
(No symbol) [0x00007FF61C270661]
(No symbol) [0x00007FF61C270700]
(No symbol) [0x00007FF61C2BE783]
(No symbol) [0x00007FF61C2BD9E6]
(No symbol) [0x00007FF61C306097]
(No symbol) [0x00007FF61C2DC28A]
(No symbol) [0x00007FF61C2FBCC7]
(No symbol) [0x00007FF61C2DC033]
(No symbol) [0x00007FF61C2A9657]
(No symbol) [0x00007FF61C2AA251]
GetHandleVerifier [0x00007FF61C743E2D+3278285]
GetHandleVerifier [0x00007FF61C790190+3590448]
GetHandleVerifier [0x00007FF61C7861D0+3549552]
GetHandleVerifier [0x00007FF61C4E1DE6+779654]
(No symbol) [0x00007FF61C3B7ACF]
(No symbol) [0x00007FF61C3B2EE4]
(No symbol) [0x00007FF61C3B3072]
(No symbol) [0x00007FF61C3A2C4F]
BaseThreadInitThunk [0x00007FF9919A257D+29]
RtlUserThreadStart [0x00007FF99362AA48+40]
<code>DevTools listening on ws://127.0.0.1:62074/devtools/browser/5c6417de-f0a9-4a10-b99c-ba18dcd6e60a
An error occurred: Message: javascript error: {"status":60,"value":"[object HTMLDivElement] has no size and location"}
(Session info: chrome=125.0.6422.61)
Stacktrace:
GetHandleVerifier [0x00007FF61C4322C2+60002]
(No symbol) [0x00007FF61C3ACA59]
(No symbol) [0x00007FF61C267EDA]
(No symbol) [0x00007FF61C26DD0E]
(No symbol) [0x00007FF61C270661]
(No symbol) [0x00007FF61C270700]
(No symbol) [0x00007FF61C2BE783]
(No symbol) [0x00007FF61C2BD9E6]
(No symbol) [0x00007FF61C306097]
(No symbol) [0x00007FF61C2DC28A]
(No symbol) [0x00007FF61C2FBCC7]
(No symbol) [0x00007FF61C2DC033]
(No symbol) [0x00007FF61C2A9657]
(No symbol) [0x00007FF61C2AA251]
GetHandleVerifier [0x00007FF61C743E2D+3278285]
GetHandleVerifier [0x00007FF61C790190+3590448]
GetHandleVerifier [0x00007FF61C7861D0+3549552]
GetHandleVerifier [0x00007FF61C4E1DE6+779654]
(No symbol) [0x00007FF61C3B7ACF]
(No symbol) [0x00007FF61C3B2EE4]
(No symbol) [0x00007FF61C3B3072]
(No symbol) [0x00007FF61C3A2C4F]
BaseThreadInitThunk [0x00007FF9919A257D+29]
RtlUserThreadStart [0x00007FF99362AA48+40]
</code>
DevTools listening on ws://127.0.0.1:62074/devtools/browser/5c6417de-f0a9-4a10-b99c-ba18dcd6e60a
An error occurred: Message: javascript error: {"status":60,"value":"[object HTMLDivElement] has no size and location"}
(Session info: chrome=125.0.6422.61)
Stacktrace:
GetHandleVerifier [0x00007FF61C4322C2+60002]
(No symbol) [0x00007FF61C3ACA59]
(No symbol) [0x00007FF61C267EDA]
(No symbol) [0x00007FF61C26DD0E]
(No symbol) [0x00007FF61C270661]
(No symbol) [0x00007FF61C270700]
(No symbol) [0x00007FF61C2BE783]
(No symbol) [0x00007FF61C2BD9E6]
(No symbol) [0x00007FF61C306097]
(No symbol) [0x00007FF61C2DC28A]
(No symbol) [0x00007FF61C2FBCC7]
(No symbol) [0x00007FF61C2DC033]
(No symbol) [0x00007FF61C2A9657]
(No symbol) [0x00007FF61C2AA251]
GetHandleVerifier [0x00007FF61C743E2D+3278285]
GetHandleVerifier [0x00007FF61C790190+3590448]
GetHandleVerifier [0x00007FF61C7861D0+3549552]
GetHandleVerifier [0x00007FF61C4E1DE6+779654]
(No symbol) [0x00007FF61C3B7ACF]
(No symbol) [0x00007FF61C3B2EE4]
(No symbol) [0x00007FF61C3B3072]
(No symbol) [0x00007FF61C3A2C4F]
BaseThreadInitThunk [0x00007FF9919A257D+29]
RtlUserThreadStart [0x00007FF99362AA48+40]