[英]how to wait for an iframe to load in selenium python with phantomjs
頁面的腳本是
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from selenium.webdriver.support import expected_conditions as EC
import unittest
import time, re, castro
class LoginTest(unittest.TestCase):
def setUp(self):
self.driver = webdriver.PhantomJS()
self.driver.maximize_window()
self.driver.get("xxx.html") # getting the page
"wanna wait her"
print self.driver.save_screenshot("fire.png")
def tearDown(self):
self.driver.quit()
if __name__ == '__main__' :
unittest.main()
iframe
HTML代碼:
<body>
<iframe src="http://thunder/spidio.net/CF9F4DA6B7533431/devinfo/devdect /d,,,_STN&pg=Post=&ckid=null&ord=123&p=mts&cid=0&pid=124" style="background-color: transparent; border : 0px none transparent; padding: 0px; overflow: hidden;" height="1" width"1">
</iframe>
</body>
請讓我知道如何讓selenium等待這個iframe加載到phantomjs與selenium使用python
您可以使用以下代碼等待所需的iframe
出現:
WebDriverWait(self.driver, 10).until(EC.presence_of_element_located((By.XPATH, "//iframe[starts-with(@src, 'http://thunder/spidio.net/CF9F4DA6B7533431/devinfo/devdect')]")))
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.