Last active
August 4, 2016 12:04
-
-
Save kurozumi/89221abc124dad636250d07330ef338d to your computer and use it in GitHub Desktop.
【Python】Seleniumをwith構文でまとめる
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from selenium import webdriver | |
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary | |
class Firefox(object): | |
def __init__(self, binary=None): | |
if binary is None: | |
self.driver = webdriver.Firefox() | |
else: | |
binary = FirefoxBinary(binary) | |
self.driver = webdriver.Firefox(firefox_binary=binary) | |
def __enter__(self): | |
return self.driver | |
def __exit__(self, exception_type, exception_value, traceback): | |
self.driver.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment