Skip to content

Commit

Permalink
DavidBurns correcting screenshot code across drivers. fixes issue 1351
Browse files Browse the repository at this point in the history
r13244
  • Loading branch information
AutomatedTester committed Aug 5, 2011
1 parent 8e317be commit 16647c9
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
6 changes: 6 additions & 0 deletions py/CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
Selenium 2.4
* Bug Fixes

Selenium 2.3
* Bug Fixes

Selenium 2.2
* Ability to get screenshots from Exceptions if they are given
* Access to Remote StackTrace on error
Expand Down
2 changes: 2 additions & 0 deletions py/selenium/webdriver/chrome/webdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
# limitations under the License.

import httplib
import base64
from selenium.webdriver.remote.command import Command
from selenium.webdriver.remote.webdriver import WebDriver as RemoteWebDriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from service import Service
Expand Down
18 changes: 18 additions & 0 deletions py/selenium/webdriver/ie/webdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@
from selenium.webdriver.common import utils
from selenium.webdriver.remote.webdriver import WebDriver as RemoteWebDriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from selenium.webdriver.remote.command import Command
from ctypes import *
import time
import os
import base64

DEFAULT_TIMEOUT = 30
DEFAULT_PORT = 0
Expand Down Expand Up @@ -53,3 +55,19 @@ def quit(self):
self.iedriver.StopServer(self.ptr)
del self.iedriver
del self.ptr

def save_screenshot(self, filename):
"""
Gets the screenshot of the current window. Returns False if there is
any IOError, else returns True. Use full paths in your filename.
"""
png = self._execute(Command.SCREENSHOT)['value']
try:
f = open(filename, 'wb')
f.write(base64.decodestring(png))
f.close()
except IOError:
return False
finally:
del png
return True

0 comments on commit 16647c9

Please sign in to comment.