5

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

1 Answer 1

8

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')]")))
Sign up to request clarification or add additional context in comments.

5 Comments

I'm using the above code to wait for the iframe but it terminates the connection as soon as the page load , the iframe basically loads a video , how can i wait until the video completes, i have two options 1) that to wait until an alert is given after the completion of iframe 2) that to wait until the video completes what should i prefer and how to accomplish it
Is there any new elements present after video playback completion? Something like "Play again", "Next video" or something like that? Can you share page URL or it is confidential info?
can i DM you somewhere
What does it mean DM? sorry, I don't know this abbreviation
direct message rather than posting here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.