<s> """<STR_LIT>""" <EOL> import json <EOL> import logging <EOL> import os <EOL> import os . path <EOL> import requests <EOL> import sys <EOL> import saunter . ConfigWrapper <EOL> import saunter . browser <EOL> from selenium . webdriver . common . by import By <EOL> from selenium . common . exceptions import WebDriverException <EOL> from selenium . common . exceptions import TimeoutException <EOL> from saunter . exceptions import ProfileNotFound <EOL> from selenium . webdriver . remote . webelement import WebElement <EOL> from selenium . webdriver . common . desired_capabilities import DesiredCapabilities <EOL> from saunter . testcase . base import BaseTestCase <EOL> from selenium . webdriver import FirefoxProfile <EOL> import py . test <EOL> from _pytest . mark import MarkInfo <EOL> import saunter . saucelabs <EOL> from saunter . matchers import Matchers <EOL> class SaunterTestCase ( BaseTestCase ) : <EOL> """<STR_LIT>""" <EOL> def setup_method ( self , method ) : <EOL> """<STR_LIT>""" <EOL> self . cf = self . config = saunter . ConfigWrapper . ConfigWrapper ( ) <EOL> self . current_method_name = method . __name__ <EOL> default_browser = self . cf [ "<STR_LIT>" ] [ self . cf [ "<STR_LIT>" ] [ "<STR_LIT>" ] ] <EOL> self . browser = saunter . browser . Browser ( default_browser , self . cf ) <EOL> self . driver = self . browser . driver <EOL> if hasattr ( self . browser , '<STR_LIT>' ) : <EOL> self . proxy = self . browser . proxy <EOL> if "<STR_LIT>" in self . cf [ "<STR_LIT>" ] [ self . cf [ "<STR_LIT>" ] [ "<STR_LIT>" ] ] and self . cf [ "<STR_LIT>" ] [ self . cf [ "<STR_LIT>" ] [ "<STR_LIT>" ] ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] and hasattr ( self . driver , "<STR_LIT>" ) : <EOL> s = saunter . saucelabs . SauceLabs ( self . cf [ "<STR_LIT>" ] [ "<STR_LIT:username>" ] , self . cf [ "<STR_LIT>" ] [ "<STR_LIT:key>" ] ) <EOL> s . update_name ( self . driver . session_id , self . current_method_name ) <EOL> self . verificationErrors = [ ] <EOL> self . matchers = Matchers ( self . driver , self . verificationErrors ) <EOL> self . _screenshot_number = <NUM_LIT:1> <EOL> def teardown_method ( self , method ) : <EOL> """<STR_LIT>""" <EOL> if hasattr ( self , "<STR_LIT>" ) : <EOL> if "<STR_LIT>" in self . cf [ "<STR_LIT>" ] [ self . cf [ "<STR_LIT>" ] [ "<STR_LIT>" ] ] and not self . cf [ "<STR_LIT>" ] [ self . cf [ "<STR_LIT>" ] [ "<STR_LIT>" ] ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] and self . cf [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] : <EOL> self . take_named_screenshot ( "<STR_LIT>" ) <EOL> if hasattr ( self , "<STR_LIT>" ) : <EOL> self . driver . quit ( ) <EOL> if hasattr ( self . browser , '<STR_LIT>' ) : <EOL> self . config [ '<STR_LIT>' ] [ '<STR_LIT>' ] . append ( self . proxy ) <EOL> def take_numbered_screenshot ( self ) : <EOL> if self . config . has_option ( "<STR_LIT>" , "<STR_LIT>" ) : <EOL> if self . cf . getboolean ( "<STR_LIT>" , "<STR_LIT>" ) : <EOL> method_dir = self . _screenshot_prep_dirs ( ) <EOL> self . driver . get_screenshot_as_file ( os . path . join ( method_dir , str ( self . _screenshot_number ) . zfill ( <NUM_LIT:3> ) + "<STR_LIT>" ) ) <EOL> self . _screenshot_number = self . _screenshot_number + <NUM_LIT:1> <EOL> if self . config . has_option ( "<STR_LIT>" , "<STR_LIT>" ) : <EOL> if self . cf . getboolean ( "<STR_LIT>" , "<STR_LIT>" ) : <EOL> sys . stdout . write ( os . linesep + "<STR_LIT>" % image_path + os . linesep ) <EOL> def take_named_screenshot ( self , name ) : <EOL> method_dir = self . _screenshot_prep_dirs ( ) <EOL> image_path = os . path . join ( method_dir , str ( name ) + "<STR_LIT>" ) <EOL> self . driver . get_screenshot_as_file ( image_path ) <EOL> if "<STR_LIT>" in self . cf and self . cf [ "<STR_LIT>" ] . lower ( ) == "<STR_LIT>" : <EOL> sys . stdout . write ( os . linesep + "<STR_LIT>" % image_path + os . linesep ) </s>
