所以这是我的代码的一部分。我把所有这些都张贴在这里太久了,但这是我遇到问题的部分。
wait.until(EC.url_changes('https://www.reddit.com/'))
#go to inbox
wait.until(EC.presence_of_element_located((By.CLASS_NAME, "_1x6pySZ2CoUnAfsFhGe7J1")))
go_to_msgs = driver.find_element_by_xpath('//a[@href="/message/inbox"]')
go_to_msgs.click()
#go to sent messages
wait.until(EC.presence_of_element_located((By.XPATH, "//iframe[@class='saPujbGMyXRwqISHcmJH9']")))
iframe1 = driver.find_element_by_xpath("//iframe[@class='saPujbGMyXRwqISHcmJH9']")
driver.switch_to.frame(iframe1)
#this is where it breaks
wait.until(EC.presence_of_element_located((By.XPATH, '//a[@href="https://www.reddit.com/message/sent/"]')))
go_to_compose = driver.find_element_by_xpath('//a[@href="https://www.reddit.com/message/sent/"]')
go_to_compose.click()
切换到iframe后,找不到链接。这很奇怪,因为当我查找页面时,链接位于此iframe中,我认为这就是为什么找不到它的原因。即使切换到此框架,它仍然无法找到已发送消息的链接。