Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to wait for an iframe to load in selenium python with phantomjs

Script for page to get is

 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()

HTML Code for iframe:

<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>

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

like image 269
Amit Chahal Avatar asked Feb 16 '17 13:02

Amit Chahal


People also ask

How do you wait for a frame in selenium?

WebDriverWait wait = new WebDriverWait(driver,10); wait. until(ExpectedConditions. frameToBeAvailableAndSwitchToIt(frameName); The above code will wait for a given frame up to 10 seconds .


1 Answers

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')]")))
like image 148
Andersson Avatar answered Oct 13 '22 21:10

Andersson