Skip to content

Instantly share code, notes, and snippets.

@kurozumi kurozumi/browser.py
Last active Aug 4, 2016

Embed
What would you like to do?
【Python】Seleniumをwith構文でまとめる
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
You can’t perform that action at this time.