<s> from __future__ import absolute_import <EOL> from boto . mturk . test . support import unittest <EOL> sel_args = ( '<STR_LIT:localhost>' , <NUM_LIT> , '<STR_LIT>' , '<STR_LIT>' ) <EOL> class SeleniumFailed ( object ) : <EOL> def __init__ ( self , message ) : <EOL> self . message = message <EOL> def __nonzero__ ( self ) : <EOL> return False <EOL> def has_selenium ( ) : <EOL> try : <EOL> from selenium import selenium <EOL> globals ( ) . update ( selenium = selenium ) <EOL> sel = selenium ( * sel_args ) <EOL> try : <EOL> sel . do_command ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> except Exception as e : <EOL> if not '<STR_LIT>' in str ( e ) : <EOL> raise <EOL> result = True <EOL> except ImportError : <EOL> result = SeleniumFailed ( '<STR_LIT>' ) <EOL> except Exception : <EOL> msg = '<STR_LIT>' % e <EOL> result = SeleniumFailed ( msg ) <EOL> globals ( ) . update ( has_selenium = lambda : result ) <EOL> return result <EOL> identity = lambda x : x <EOL> def skip_unless_has_selenium ( ) : <EOL> res = has_selenium ( ) <EOL> if not res : <EOL> return unittest . skip ( res . message ) <EOL> return identity <EOL> def complete_hit ( hit_type_id , response = '<STR_LIT>' ) : <EOL> verificationErrors = [ ] <EOL> sel = selenium ( * sel_args ) <EOL> sel . start ( ) <EOL> sel . open ( "<STR_LIT>" ) <EOL> sel . click ( "<STR_LIT>" ) <EOL> sel . wait_for_page_to_load ( "<STR_LIT>" ) <EOL> sel . type ( "<STR_LIT:email>" , "<STR_LIT>" ) <EOL> sel . type ( "<STR_LIT:password>" , "<STR_LIT>" ) <EOL> sel . click ( "<STR_LIT>" ) <EOL> sel . wait_for_page_to_load ( "<STR_LIT>" ) <EOL> sel . open ( "<STR_LIT>" . format ( ** vars ( ) ) ) <EOL> sel . click ( "<STR_LIT>" ) <EOL> sel . wait_for_page_to_load ( "<STR_LIT>" ) <EOL> sel . type ( "<STR_LIT>" , response ) <EOL> sel . click ( "<STR_LIT>" ) <EOL> sel . wait_for_page_to_load ( "<STR_LIT>" ) <EOL> sel . click ( "<STR_LIT>" ) <EOL> sel . wait_for_page_to_load ( "<STR_LIT>" ) <EOL> sel . stop ( ) </s>
