我想從這個頁面轉到這個
參考
您可以在以下位置找到一些相關討論:
- 通過Selenium和python切換到iframe
- selenium.common.exceptions.NoSuchElementException:訊息:沒有這樣的元素:嘗試使用硒單擊“下一步”按鈕時無法定位元素
- python中的硒:NoSuchElementException:訊息:沒有這樣的元素:無法定位元素
uj5u.com熱心網友回復:
嘗試
driver.switch_to.frame("idIframeChampionnat")
button = driver.find_element_by_xpath("//a[contains(text(), 'minin U15')]")
button.click()
或者
driver.switch_to.frame("idIframeChampionnat")
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//a[contains(text(), 'minin U15')]"))).click()
這是我在 groovy 中的代碼示例(抱歉,還沒有 python env),與您的非常相似,即使沒有超時,它也可以在回圈中完美運行 20 次。
@Test(invocationCount = 20)
void test() {
driver.get('https://resultats.ffbb.com/organisation/b5e6211d5970.html')
driver.switchTo().frame(
driver.findElement(By.xpath("//iframe[@id='idIframeChampionnat']"))
)
driver.findElement(By.xpath("//a[contains(text(), 'minin U15')]")).click()
driver.switchTo().defaultContent()
assert driver.getCurrentUrl() ==
'https://resultats.ffbb.com/championnat/b5e6211f621a.html?r=200000002810394&d=200000002911791&p=2'
}
所以,我沒有想法。也許只是driver.switch_to.default_content()在點擊后添加?
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/391988.html
