Search

[python, μ…€λ ˆλ‹ˆμ›€] νŠΉμ • element κ°€ 클릭 μ•ˆ λ λ•Œ (Message: element not interactable 였λ₯˜)

νƒ€μž…
νŠΈλŸ¬λΈ”μŠˆνŒ…
νƒœκ·Έ
python
selenium
μƒνƒœ
Published
생성일
2022/12/22 06:46
μ΅œμ’… νŽΈμ§‘ μΌμ‹œ
2023/02/24 11:36
2 more properties

μ—λŸ¬ 상황

μ…€λ ˆλ‹ˆμ›€μ—μ„œ νŠΉμ • element λ₯Ό 클릭해야 ν•˜λŠ” 상황이닀.
name = WebDriverWait(driver, 10).until( EC.element_to_be_clickable( (By.CSS_SELECTOR, "span.place_bluelink") ) ) name.click()
Python
볡사
span.place_bluelink element λ₯Ό clickable ν•  λ•ŒκΉŒμ§€ explicit ν•˜κ²Œ 기닀리도둝 ν–ˆλŠ”λ°λ„ click 이 되질 μ•Šμ•˜λ‹€.
μ•„λž˜μ˜ μ—λŸ¬ 문ꡬ가 좜λ ₯됐닀
Message: element not interactable

μ—λŸ¬ ν•΄κ²°

ꡬ글링을 ν•΄λ³΄λ‹ˆ 두 가지 μ •λ„μ˜ 해결방법이 μžˆμ—ˆλ‹€.

해결법1

click() λŒ€μ‹  Keys.ENTER λ₯Ό μ‚¬μš©ν•œλ‹€.
from selenium.webdriver.common.keys import Keys name = WebDriverWait(driver, 10).until( EC.element_to_be_clickable( (By.CSS_SELECTOR, "span.place_bluelink") ) ) name.send_keys(Keys.ENTER)
Python
볡사
ν•˜μ§€λ§Œ λ‚˜ 같은 경우 μœ„ λ°©λ²•μœΌλ‘œλŠ” ν•΄κ²°λ˜μ§€ μ•Šμ•˜λ‹€.

해결법2

js scrpit λ₯Ό μ‚¬μš©ν•œλ‹€.
name = WebDriverWait(driver, 10).until( EC.element_to_be_clickable( (By.CSS_SELECTOR, "span.place_bluelink") ) ) driver.execute_script("arguments[0].click();", name)
Python
볡사
이 λ°©λ²•μœΌλ‘œ ν•΄κ²°ν–ˆλ‹€.
μ°Έκ³  :