<s> from util import Util <EOL> from keywordgroup import KeywordGroup <EOL> from elementfinder import ElementFinder <EOL> class Element ( KeywordGroup ) : <EOL> def __init__ ( self ) : <EOL> self . _element_finder = ElementFinder ( ) <EOL> def element_find ( self , locator , requireRaise = True ) : <EOL> """<STR_LIT>""" <EOL> element = self . _element_finder . find ( locator ) <EOL> if not requireRaise and len ( element ) == <NUM_LIT:0> : <EOL> return None <EOL> if requireRaise and len ( element ) == <NUM_LIT:0> : <EOL> raise ValueError ( "<STR_LIT>" % locator ) <EOL> return element [ <NUM_LIT:0> ] <EOL> def click ( self , locator ) : <EOL> """<STR_LIT>""" <EOL> self . _info ( "<STR_LIT>" % locator ) <EOL> self . wait_for_element_present ( locator , <NUM_LIT:10> ) <EOL> element = self . element_find ( locator ) <EOL> element . click ( ) <EOL> if Util . captureScreenShot == "<STR_LIT:True>" : <EOL> self . capture_page_screenshot ( ) <EOL> def type ( self , locator , text ) : <EOL> """<STR_LIT>""" <EOL> self . _info ( "<STR_LIT>" % ( text , locator ) ) <EOL> self . wait_for_element_present ( locator , <NUM_LIT:10> ) <EOL> self . _input_text_into_text_field ( locator , text ) <EOL> if Util . captureScreenShot == "<STR_LIT:True>" : <EOL> self . capture_page_screenshot ( ) <EOL> def is_element_present ( self , locator ) : <EOL> """<STR_LIT>""" <EOL> return ( self . element_find ( locator , False ) != None ) <EOL> def page_should_contain_element ( self , locator ) : <EOL> """<STR_LIT>""" <EOL> if self . is_element_present ( locator ) : <EOL> self . _info ( '<STR_LIT>' % locator ) <EOL> else : <EOL> self . _warn ( '<STR_LIT>' % locator ) <EOL> def page_should_not_contain_element ( self , locator ) : <EOL> """<STR_LIT>""" <EOL> if not self . is_element_present ( locator ) : <EOL> self . _info ( '<STR_LIT>' % locator ) <EOL> else : <EOL> self . _warn ( '<STR_LIT>' % locator ) <EOL> def get_matching_element_count ( self , locator ) : <EOL> """<STR_LIT>""" <EOL> if self . _element_finder . find ( locator ) is None : <EOL> count = <NUM_LIT:0> <EOL> else : <EOL> count = len ( self . _element_finder . find ( locator ) ) <EOL> return str ( count ) <EOL> def get_text ( self , locator ) : <EOL> """<STR_LIT>""" <EOL> return self . _get_text ( locator ) <EOL> def get_value ( self , locator ) : <EOL> """<STR_LIT>""" <EOL> return self . _get_value ( locator ) <EOL> def verify_text ( self , locator , expectedText ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> actualText = self . _get_text ( locator ) <EOL> assert actualText == expectedText <EOL> self . _info ( '<STR_LIT>' % ( actualText , expectedText ) ) <EOL> except AssertionError : <EOL> self . _warn ( '<STR_LIT>' % ( actualText , expectedText ) ) <EOL> def verify_value ( self , locator , expectedValue ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> actualValue = self . _get_value ( locator ) <EOL> assert actualValue == expectedValue <EOL> self . _info ( '<STR_LIT>' % ( actualValue , expectedValue ) ) <EOL> except AssertionError : <EOL> self . _warn ( '<STR_LIT>' % ( actualValue , expectedValue ) ) <EOL> def ie_certificate_error_handler ( self ) : <EOL> Util . driver . get ( ( '<STR_LIT>' ) ) <EOL> def _input_text_into_text_field ( self , locator , text ) : <EOL> element = self . element_find ( locator ) <EOL> element . send_keys ( text ) <EOL> def _get_text ( self , locator ) : <EOL> element = self . element_find ( locator ) <EOL> return ( element . text ) . strip ( ) <EOL> def _get_value ( self , locator ) : <EOL> element = self . element_find ( locator ) <EOL> return ( element . get_attribute ( "<STR_LIT:value>" ) ) . strip ( ) </s>
