Screenshot doesn't save as expected on Windows, but works on iOS

We tested this code on both iOS and Windows. On iOS, it saves as expected in the base directory of the .py file. However, when working in Windows, the screenshot is not saved anywhere on the machine. Screenshot code:

def test_python_webpage(self):
    driver = self.driver
    driver.maximize_window()
    driver.get(self.base_url + "/")
    driver.get_screenshot_as_file('base_url.png') 

      

Any thoughts on why this file isn't saved when executed on a Windows computer, but works fine on iOS?

Note. This happens in all three browsers (IE 11, Chrome 38.0.2125.111 and FF). I am working with PyCharm 3.4.1 for scripting.

+3


source to share


1 answer


Try this snippet which is in Python



from selenium import webdriver
browser = webdriver.Firefox()
browser.get('http://www.google.com/')
browser.save_screenshot('screenshot.png')
browser.quit()

      

+1


source







All Articles