<s> """<STR_LIT>""" <EOL> import os <EOL> import time <EOL> from bok_choy . page_object import PageObject <EOL> from bok_choy . promise import EmptyPromise <EOL> from bok_choy . javascript import js_defined , requirejs , wait_for_js <EOL> class SitePage ( PageObject ) : <EOL> """<STR_LIT>""" <EOL> SERVER_PORT = os . environ . get ( "<STR_LIT>" , <NUM_LIT> ) <EOL> def is_browser_on_page ( self ) : <EOL> title = self . name . lower ( ) . replace ( '<STR_LIT:_>' , '<STR_LIT:U+0020>' ) <EOL> return title in self . browser . title . lower ( ) <EOL> @ property <EOL> def url ( self ) : <EOL> return "<STR_LIT>" . format ( self . SERVER_PORT , self . name + "<STR_LIT>" ) <EOL> @ property <EOL> def output ( self ) : <EOL> """<STR_LIT>""" <EOL> text_list = self . q ( css = '<STR_LIT>' ) . text <EOL> if len ( text_list ) < <NUM_LIT:1> : <EOL> return None <EOL> else : <EOL> return text_list [ <NUM_LIT:0> ] <EOL> class ButtonPage ( SitePage ) : <EOL> """<STR_LIT>""" <EOL> name = "<STR_LIT>" <EOL> def click_button ( self ) : <EOL> """<STR_LIT>""" <EOL> self . q ( css = '<STR_LIT>' ) . first . click ( ) <EOL> class TextFieldPage ( SitePage ) : <EOL> """<STR_LIT>""" <EOL> name = "<STR_LIT>" <EOL> def enter_text ( self , text ) : <EOL> """<STR_LIT>""" <EOL> self . q ( css = '<STR_LIT>' ) . fill ( text ) <EOL> class SelectPage ( SitePage ) : <EOL> """<STR_LIT>""" <EOL> name = "<STR_LIT>" <EOL> def select_car ( self , car_value ) : <EOL> """<STR_LIT>""" <EOL> self . q ( css = '<STR_LIT>' . format ( car_value ) ) . first . click ( ) <EOL> def is_car_selected ( self , car ) : <EOL> return self . q ( css = '<STR_LIT>' . format ( car ) ) . selected <EOL> class CheckboxPage ( SitePage ) : <EOL> """<STR_LIT>""" <EOL> name = "<STR_LIT>" <EOL> def toggle_pill ( self , pill_name ) : <EOL> """<STR_LIT>""" <EOL> self . q ( css = "<STR_LIT>" . format ( pill_name ) ) . first . click ( ) <EOL> class AlertPage ( SitePage ) : <EOL> """<STR_LIT>""" <EOL> name = "<STR_LIT>" <EOL> def confirm ( self ) : <EOL> with self . handle_alert ( confirm = True ) : <EOL> self . q ( css = '<STR_LIT>' ) . first . click ( ) <EOL> def cancel ( self ) : <EOL> with self . handle_alert ( confirm = False ) : <EOL> self . q ( css = '<STR_LIT>' ) . first . click ( ) <EOL> def dismiss ( self ) : <EOL> with self . handle_alert ( ) : <EOL> self . q ( css = '<STR_LIT>' ) . first . click ( ) <EOL> class SelectorPage ( SitePage ) : <EOL> """<STR_LIT>""" <EOL> name = "<STR_LIT>" <EOL> @ property <EOL> def num_divs ( self ) : <EOL> """<STR_LIT>""" <EOL> return len ( self . q ( css = '<STR_LIT>' ) . results ) <EOL> @ property <EOL> def div_text_list ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . q ( css = '<STR_LIT>' ) . text <EOL> @ property <EOL> def div_value_list ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . q ( css = '<STR_LIT>' ) . attrs ( '<STR_LIT:value>' ) <EOL> @ property <EOL> def div_html_list ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . q ( css = '<STR_LIT>' ) . html <EOL> def ids_of_outer_divs_with_inner_text ( self , child_text ) : <EOL> """<STR_LIT>""" <EOL> return self . q ( css = '<STR_LIT>' ) . filter ( <EOL> lambda el : <EOL> child_text in [ inner . text for inner in el . find_elements_by_css_selector ( '<STR_LIT>' ) ] <EOL> ) . attrs ( '<STR_LIT:id>' ) <EOL> class DelayPage ( SitePage ) : <EOL> """<STR_LIT>""" <EOL> name = "<STR_LIT>" <EOL> def trigger_output ( self ) : <EOL> """<STR_LIT>""" <EOL> EmptyPromise ( self . q ( css = '<STR_LIT>' ) . is_present , "<STR_LIT>" ) . fulfill ( ) <EOL> self . q ( css = '<STR_LIT>' ) . first . click ( ) <EOL> EmptyPromise ( self . q ( css = '<STR_LIT>' ) . is_present , "<STR_LIT>" ) . fulfill ( ) <EOL> def make_broken_promise ( self ) : <EOL> """<STR_LIT>""" <EOL> return EmptyPromise ( <EOL> self . q ( css = '<STR_LIT>' ) . is_present , "<STR_LIT>" , <EOL> try_limit = <NUM_LIT:3> , try_interval = <NUM_LIT> <EOL> ) . fulfill ( ) <EOL> class SlowPage ( SitePage ) : <EOL> """<STR_LIT>""" <EOL> name = "<STR_LIT>" <EOL> def is_browser_on_page ( self ) : <EOL> return self . q ( css = '<STR_LIT>' ) . is_present ( ) <EOL> class NextPage ( SitePage ) : <EOL> """<STR_LIT>""" <EOL> name = "<STR_LIT>" <EOL> def is_browser_on_page ( self ) : <EOL> return self . q ( css = '<STR_LIT>' ) . is_present ( ) <EOL> def load_next ( self , page , delay_sec ) : <EOL> """<STR_LIT>""" <EOL> time . sleep ( delay_sec ) <EOL> page . visit ( ) <EOL> class FocusedPage ( SitePage ) : <EOL> """<STR_LIT>""" <EOL> name = "<STR_LIT>" <EOL> def focus_on_main_content ( self ) : <EOL> self . browser . execute_script ( "<STR_LIT>" ) <EOL> class VisiblePage ( SitePage ) : <EOL> """<STR_LIT>""" <EOL> name = "<STR_LIT>" <EOL> def is_visible ( self , name ) : <EOL> """<STR_LIT>""" <EOL> return self . q ( css = "<STR_LIT>" . format ( name ) ) . first . visible <EOL> def is_invisible ( self , name ) : <EOL> """<STR_LIT>""" <EOL> return self . q ( css = "<STR_LIT>" . format ( name ) ) . first . invisible <EOL> @ js_defined ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> class JavaScriptPage ( SitePage ) : <EOL> """<STR_LIT>""" <EOL> name = "<STR_LIT>" <EOL> @ wait_for_js <EOL> def trigger_output ( self ) : <EOL> """<STR_LIT>""" <EOL> self . q ( css = '<STR_LIT>' ) . first . click ( ) <EOL> @ wait_for_js <EOL> def reload_and_trigger_output ( self ) : <EOL> """<STR_LIT>""" <EOL> self . browser . refresh ( ) <EOL> self . wait_for_js ( ) <EOL> self . q ( css = '<STR_LIT>' ) . first . click ( ) <EOL> @ js_defined ( '<STR_LIT>' ) <EOL> class JavaScriptUndefinedPage ( SitePage ) : <EOL> """<STR_LIT>""" <EOL> name = "<STR_LIT>" <EOL> @ wait_for_js <EOL> def trigger_output ( self ) : <EOL> """<STR_LIT>""" <EOL> self . q ( css = '<STR_LIT>' ) . first . click ( ) <EOL> @ requirejs ( '<STR_LIT>' ) <EOL> class RequireJSPage ( SitePage ) : <EOL> """<STR_LIT>""" <EOL> name = "<STR_LIT>" <EOL> @ property <EOL> @ wait_for_js <EOL> def output ( self ) : <EOL> return super ( RequireJSPage , self ) . output <EOL> class AjaxNoJQueryPage ( SitePage ) : <EOL> """<STR_LIT>""" <EOL> name = "<STR_LIT>" <EOL> class AjaxPage ( SitePage ) : <EOL> """<STR_LIT>""" <EOL> name = "<STR_LIT>" <EOL> def click_button ( self ) : <EOL> """<STR_LIT>""" <EOL> self . q ( css = '<STR_LIT>' ) . first . click ( ) <EOL> class WaitsPage ( SitePage ) : <EOL> """<STR_LIT>""" <EOL> name = "<STR_LIT>" <EOL> def is_button_output_present ( self ) : <EOL> """<STR_LIT>""" <EOL> self . wait_for_element_presence ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . q ( css = '<STR_LIT>' ) . first . click ( ) <EOL> self . wait_for_element_presence ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> def is_class_absent ( self ) : <EOL> """<STR_LIT>""" <EOL> self . q ( css = '<STR_LIT>' ) . first . click ( ) <EOL> self . wait_for_element_absence ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> def is_button_output_visible ( self ) : <EOL> """<STR_LIT>""" <EOL> self . wait_for_element_presence ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . q ( css = '<STR_LIT>' ) . first . click ( ) <EOL> self . wait_for_element_visibility ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> def is_spinner_invisible ( self ) : <EOL> """<STR_LIT>""" <EOL> self . q ( css = '<STR_LIT>' ) . first . click ( ) <EOL> self . wait_for_element_invisibility ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> class AccessibilityPage ( SitePage ) : <EOL> """<STR_LIT>""" <EOL> name = "<STR_LIT>" <EOL> class ImagePage ( SitePage ) : <EOL> """<STR_LIT>""" <EOL> name = "<STR_LIT:image>" <EOL> class LongPage ( SitePage ) : <EOL> """<STR_LIT>""" <EOL> name = "<STR_LIT>" </s>
