StaleElementReferenceException
は参照先の要素がすでにページから取り除かれていたときに発生します。待機を入れるかどうかは関係しません。
iframe
を取得し直せば解決すると思います。
Like!
StaleElementReferenceExceptionのエラーを解消したいです。
time.sleep()を事前に入れているにもかかわらず、上記エラーが発生していまいます。
解決方法を教えて下さい。
StaleElementReferenceException
yoyaku=driver.find_element(By.LINK_TEXT, "予約を確認する・申し込む")
yoyaku.click()
time.sleep(0.5)
driver.switch_to.frame(iframe)
driver.switch_to.frame("left")
favorite=driver.find_element(By.LINK_TEXT, "お気に入りを指定して検索")
favorite.click()
search=driver.find_element(By.CLASS_NAME, "IPTBTN")
search.click()
time.sleep(1)
iframe = driver.find_element(By.CSS_SELECTOR, "html > frameset > frame:nth-child(2)")
driver.switch_to.frame(iframe) #←ここでエラーが発生していまいます。iframeを使いまわしていることも関係あるのでしょうか?
driver.switch_to.frame("content")
date=driver.find_element(By.ID, "nextSpan")
time.sleep(5)
date.click()
<img id="execNext" src="/reselve/IMAGES/pw2/p2_execNext.gif" title="手続きを進める" alt="次の手続き" onclick="doExecNext()" style="left: 441px; display: block;">
StaleElementReferenceException
は参照先の要素がすでにページから取り除かれていたときに発生します。待機を入れるかどうかは関係しません。
iframe
を取得し直せば解決すると思います。
@hiroki2003
Questioner