如何使用phantomjs等待iframe在硒python中加载 [英] how to wait for an iframe to load in selenium python with phantomjs

查看:118
本文介绍了如何使用phantomjs等待iframe在硒python中加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

要获取页面的脚本是

 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>

请让我知道如何让硒等待使用python使用硒将iframe加载到phantomjs中

please let me know how to make selenium wait for this iframe to be loaded in phantomjs with selenium using python

推荐答案

您可以使用下面的代码等待直到出现所需的iframe:

You can use below code to wait until required iframe appears:

WebDriverWait(self.driver, 10).until(EC.presence_of_element_located((By.XPATH, "//iframe[starts-with(@src, 'http://thunder/spidio.net/CF9F4DA6B7533431/devinfo/devdect')]")))

这篇关于如何使用phantomjs等待iframe在硒python中加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆