python截屏保存本地_如何使用python将截图保存在特定文件夹中

我写了下面的截图脚本。目前,它将文件保存在python文件所在的同一目录中。我想把截图保存在一个特定的文件夹中。在from selenium import webdriver

import option

import time

#PhantomJS

driver = webdriver.PhantomJS(executable_path=r'D:\PhantomJS\phantomjs-2.1.1-

windows\bin\phantomjs.exe')

#Selenium

#driver = webdriver.Chrome("D:\Selenium\Chrome\chromedriver.exe")

#Maximizes window to full screen

driver.maximize_window()

#Gets the URL for OMS

driver.get(option.OMS_QUERY)

#Gets the username & Password

driver.find_element_by_xpath(option.LOG_IN).click()

driver.find_element_by_id("username").send_keys(option.USERNAME)

driver.find_element_by_xpath(option.ENTER).click()

time.sleep(3)

driver.find_element_by_id("password").send_keys(option.PASSWORD)

driver.find_element_by_xpath(option.ENTER).click()

time.sleep(15)

#Saves the screenshot for OMS_SWR

driver.save_screenshot('oms_swr.png')

#Gets the URL for DMS

driver.get(option.DMS_QUERY)

time.sleep(15)

#Saves the screenshot for DMS_SWR

driver.save_screenshot('dms_swr.png')

driver.quit()

你可能感兴趣的:(python截屏保存本地)