Skip to content

Instantly share code, notes, and snippets.

@adamgoucher
Created January 15, 2013 18:10
Show Gist options
  • Save adamgoucher/4540597 to your computer and use it in GitHub Desktop.
Save adamgoucher/4540597 to your computer and use it in GitHub Desktop.
ideas on how to mark browsers as being remote or not -- or more accurately whether they can use the localfiledetecter that is in send_keys. with the additional twist of being a wrapper around webdriver and not being in the project itself
class Remote(object):
IS_A_REMOTE_BROWSER = True
def send_keys(self):
if self.IS_A_REMOTE_BROWSER:
print('%s is a remote' % self.__class__.__name__)
print('send_keys')
class Firefox(Remote):
IS_A_REMOTE_BROWSER = False
class Tailored(Remote):
IS_A_REMOTE_BROWSER = True
if __name__ == '__main__':
Firefox().send_keys()
Remote().send_keys()
Tailored().send_keys()
class Remote(object):
def send_keys(self):
if self.__class__.__name__ not in ['Firefox']:
print('%s is a remote' % self.__class__.__name__)
print('send_keys')
class Firefox(Remote):
pass
class Tailored(Remote):
pass
if __name__ == '__main__':
Firefox().send_keys()
Remote().send_keys()
Tailored().send_keys()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment