def __init__(self, webdriver_provider=None, screenshot_util=None):
        '''
        Constructor.

        Kwargs:
            webdriver_provider: Override the default WebdriverManager instance.
            screenshot_util: Override the default screenshot util method.

        '''
        if WTF_CONFIG_READER.get(self.CAPTURE_SCREENSHOT_SETTING, True):
            self.capture_screenshot = True
        else:
            self.capture_screenshot = False
        self.max_screenshot_name_len = int(
            WTF_CONFIG_READER.get(self.MAX_SCREENSHOT_NAME_LEN_SETTING, 20))

        if webdriver_provider == None:
            self._webdriver_provider = WTF_WEBDRIVER_MANAGER
        else:
            self._webdriver_provider = webdriver_provider

        if screenshot_util == None:
            self._screenshot_util = WebScreenShotUtil
        else:
            self._screenshot_util = screenshot_util
Beispiel #2
0
    def __init__(self, webdriver_provider=None, screenshot_util=None):
        '''
        Constructor.

        Kwargs:
            webdriver_provider: Override the default WebdriverManager instance.
            screenshot_util: Override the default screenshot util method.

        '''
        if WTF_CONFIG_READER.get(self.CAPTURE_SCREENSHOT_SETTING, True):
            self.capture_screenshot = True
        else:
            self.capture_screenshot = False
        self.max_screenshot_name_len = int(
            WTF_CONFIG_READER.get(self.MAX_SCREENSHOT_NAME_LEN_SETTING, 20))

        if webdriver_provider == None:
            self._webdriver_provider = WTF_WEBDRIVER_MANAGER
        else:
            self._webdriver_provider = webdriver_provider

        if screenshot_util == None:
            self._screenshot_util = WebScreenShotUtil
        else:
            self._screenshot_util = screenshot_util
    def test_createWebDriver_WithLocalBrowser(self):
        '''
        This will test this by opening firefox and trying to fetch Google with it.

        This test will normally be commented out since it spawns annoying browser windows.
        When making changes to WebDriverFactory, please run this test manually.
        '''
        config_reader = mock(ConfigReader)
        when(config_reader).get(
            WebDriverFactory.DRIVER_TYPE_CONFIG).thenReturn("LOCAL")
        when(config_reader).get(
            WebDriverFactory.BROWSER_TYPE_CONFIG).thenReturn("PHANTOMJS")

        try:
            phantom_js_path = WTF_CONFIG_READER.get(
                WebDriverFactory.PHANTOMEJS_EXEC_PATH)
            when(config_reader).get(
                WebDriverFactory.PHANTOMEJS_EXEC_PATH).thenReturn(
                    phantom_js_path)
        except KeyError:
            when(config_reader).get(
                WebDriverFactory.PHANTOMEJS_EXEC_PATH).thenRaise(KeyError())

        driver_factory = WebDriverFactory(config_reader)
        self._driver = driver_factory.create_webdriver()

        # This whould open a local instance of Firefox.
        self._driver.get("http://www.google.com")

        # Check if we can use this instance of webdriver.
        self._driver.find_element_by_name('q')  # google's famous q element.
    def test_create_phantomjs_driver(self):
        config_reader = mock(ConfigReader)
        when(config_reader).get(
            WebDriverFactory.DRIVER_TYPE_CONFIG).thenReturn("LOCAL")
        when(config_reader).get(
            WebDriverFactory.BROWSER_TYPE_CONFIG).thenReturn("PHANTOMJS")

        # Check if the person running this test has a config specified for
        # phantom JS, otherwise use default.
        try:
            path = WTF_CONFIG_READER.get(WebDriverFactory.PHANTOMEJS_EXEC_PATH)
            when(config_reader).get(
                WebDriverFactory.PHANTOMEJS_EXEC_PATH).thenReturn(path)
        except KeyError:
            when(config_reader).get(
                WebDriverFactory.PHANTOMEJS_EXEC_PATH).thenRaise(KeyError())

        driver_factory = WebDriverFactory(config_reader)
        self._driver = driver_factory.create_webdriver()

        # This whould open a local instance of Firefox.
        self._driver.get("http://www.google.com")

        # Check if we can use this instance of webdriver.
        self._driver.find_element_by_name('q')  # google's famous q element.
    def test_createWebDriver_WithLocalBrowser(self):
        '''
        This will test this by opening firefox and trying to fetch Google with it.

        This test will normally be commented out since it spawns annoying browser windows.
        When making changes to WebDriverFactory, please run this test manually.
        '''
        config_reader = mock(ConfigReader)
        when(config_reader).get(
            WebDriverFactory.DRIVER_TYPE_CONFIG).thenReturn("LOCAL")
        when(config_reader).get(
            WebDriverFactory.BROWSER_TYPE_CONFIG).thenReturn("PHANTOMJS")

        try:
            phantom_js_path = WTF_CONFIG_READER.get(WebDriverFactory.PHANTOMEJS_EXEC_PATH)
            when(config_reader).get(
                WebDriverFactory.PHANTOMEJS_EXEC_PATH).thenReturn(phantom_js_path)
        except KeyError:
            when(config_reader).get(
                WebDriverFactory.PHANTOMEJS_EXEC_PATH).thenRaise(KeyError())

        driver_factory = WebDriverFactory(config_reader)
        self._driver = driver_factory.create_webdriver()

        # This whould open a local instance of Firefox.
        self._driver.get("http://www.google.com")

        # Check if we can use this instance of webdriver.
        self._driver.find_element_by_name('q')  # google's famous q element.
    def setUp(self):
        self.expected_subject = WTF_CONFIG_READER.get("email.expected_subject")
        self.expected_message = WTF_CONFIG_READER.get("email.expected_message")
        
        email_config = WTF_CONFIG_READER.get("email")
        account_config = email_config['primary']

        email_server = account_config['server']
        username = account_config['username']
        password = account_config['password']

        email_type = account_config['type']
        if email_type == 'IMAP':
            self.mail = IMapEmailAccountObject(email_server, username, password)
        else:
            raise TypeError("Unsupported email type '{0}'".format(type)) 
    def test_create_phantomjs_driver(self):
        config_reader = mock(ConfigReader)
        when(config_reader).get(
            WebDriverFactory.DRIVER_TYPE_CONFIG).thenReturn("LOCAL")
        when(config_reader).get(
            WebDriverFactory.BROWSER_TYPE_CONFIG).thenReturn("PHANTOMJS")

        # Check if the person running this test has a config specified for
        # phantom JS, otherwise use default.
        try:
            path = WTF_CONFIG_READER.get(WebDriverFactory.PHANTOMEJS_EXEC_PATH)
            when(config_reader).get(
                WebDriverFactory.PHANTOMEJS_EXEC_PATH).thenReturn(path)
        except KeyError:
            when(config_reader).get(
                WebDriverFactory.PHANTOMEJS_EXEC_PATH).thenRaise(KeyError())

        driver_factory = WebDriverFactory(config_reader)
        self._driver = driver_factory.create_webdriver()

        # This whould open a local instance of Firefox.
        self._driver.get("http://www.google.com")

        # Check if we can use this instance of webdriver.
        self._driver.find_element_by_name('q')  # google's famous q element.
Beispiel #8
0
    def setUp(self):
        self.expected_subject = WTF_CONFIG_READER.get("email.expected_subject")
        self.expected_message = WTF_CONFIG_READER.get("email.expected_message")

        email_config = WTF_CONFIG_READER.get("email")
        account_config = email_config['primary']

        email_server = account_config['server']
        username = account_config['username']
        password = account_config['password']

        email_type = account_config['type']
        if email_type == 'IMAP':
            self.mail = IMapEmailAccountObject(email_server, username,
                                               password)
        else:
            raise TypeError("Unsupported email type '{0}'".format(type))
Beispiel #9
0
def print_debug(*args, **kwargs):
    """
    Print if and only if the debug flag is set true in the config.yaml file.
    
    Args:
        args : var args of print arguments.

    """
    if WTF_CONFIG_READER.get("debug", False) == True:
        print(*args, **kwargs)
Beispiel #10
0
def print_debug(*args, **kwargs):
    """
    Print if and only if the debug flag is set true in the config.yaml file.
    
    Args:
        args : var args of print arguments.

    """
    if WTF_CONFIG_READER.get("debug", False) == True:
        print(*args, **kwargs)
 def __init__(self):
     config = """
     selenium:
         type: REMOTE
         remote_url: {0}
         browser: FIREFOX
         desired_capabilities:
             platform: WINDOWS
             name: Unit Testing WD-acceptance-tests WebDriverFactory
     """.format(WTF_CONFIG_READER.get("selenium.remote_url"))
     # TODO: Might be good to replace this with a local grid to avoid using up SauceLab automation hours.
     self.map = yaml.load(config)
Beispiel #12
0
 def __init__(self):
     config = """
     selenium:
         type: REMOTE
         remote_url: {0}
         browser: FIREFOX
         desired_capabilities:
             platform: Windows 7
             name: Unit Testing WD-acceptance-tests WebDriverFactory
     """.format(WTF_CONFIG_READER.get("selenium.remote_url"))
     # TODO: Might be good to replace this with a local grid to avoid using up SauceLab automation hours.
     self.map = yaml.load(config)
 def __init__(self):
     config = """
     selenium:
         type: REMOTE
         remote_url: {0}
         browser: FIREFOX
         desired_capabilities:
             platform: WINDOWS
             name: Unit Testing WD-acceptance-tests WebDriverFactory
     """.format(WTF_CONFIG_READER.get("selenium.remote_url"))
     # Currently using free open source sauce account loaded from encrpyed env var to test this
     # on Travis CI.
     self.map = yaml.load(config)
 def __init__(self):
     config = """
     selenium:
         type: REMOTE
         remote_url: {0}
         browser: FIREFOX
         desired_capabilities:
             platform: WINDOWS
             name: Unit Testing WD-acceptance-tests WebDriverFactory
     """.format(WTF_CONFIG_READER.get("selenium.remote_url"))
     # Currently using free open source sauce account loaded from encrpyed env var to test this
     # on Travis CI.
     self.map = yaml.load(config)
 def __init__(self):
     config = """
     selenium:
         type: REMOTE
         remote_url: {0}
         browser: OTHER
         desired_capabilities:
             platform: OS X 10.9
             version: 7
             device-orientation: portrait
             device: iPhone Simulator
             name: Unit Testing WD-acceptance-tests WebDriverFactory
     """.format(WTF_CONFIG_READER.get("selenium.remote_url"))
     # Currently using free open source sauce account loaded from encrpyed env var to test this
     # on Travis CI.
     self.map = yaml.load(config)
 def __init__(self):
     config = """
     selenium:
         type: REMOTE
         remote_url: {0}
         browser: OTHER
         desired_capabilities:
             platform: OS X 10.9
             version: 7
             device-orientation: portrait
             device: iPhone Simulator
             name: Unit Testing WD-acceptance-tests WebDriverFactory
     """.format(WTF_CONFIG_READER.get("selenium.remote_url"))
     # Currently using free open source sauce account loaded from encrpyed env var to test this
     # on Travis CI.
     self.map = yaml.load(config)
    def __init__(self, webdriver_provider=None, screenshot_util=None):
        '''
        Constructor
        '''
        if WTF_CONFIG_READER.get("selenium.take_screenshot", True):
            self.capture_screenshot = True
        else:
            self.capture_screenshot = False
        
        if webdriver_provider == None:
            self._webdriver_provider = WTF_WEBDRIVER_MANAGER
        else:
            self._webdriver_provider = webdriver_provider

        if screenshot_util == None:
            self._screenshot_util = WebScreenShotUtil
        else:
            self._screenshot_util = screenshot_util 
Beispiel #18
0
    def __init__(self, webdriver_provider=None, screenshot_util=None):
        '''
        Constructor.
        
        Kwargs:
            webdriver_provider: Override the default WebdriverManager instance.
            screenshot_util: Override the default screenshot util method.

        '''
        if WTF_CONFIG_READER.get("selenium.take_screenshot", True):
            self.capture_screenshot = True
        else:
            self.capture_screenshot = False
        
        if webdriver_provider == None:
            self._webdriver_provider = WTF_WEBDRIVER_MANAGER
        else:
            self._webdriver_provider = webdriver_provider

        if screenshot_util == None:
            self._screenshot_util = WebScreenShotUtil
        else:
            self._screenshot_util = screenshot_util 
Beispiel #19
0
def get_admin_user():
    return WTF_CONFIG_READER.get("admin_user", "admin")
Beispiel #20
0
def password():
    "Correct password"
    return WTF_CONFIG_READER.get('test_data.password')
Beispiel #21
0
def login():
    "Correct login"
    return WTF_CONFIG_READER.get('test_data.login')
 def setUp(self):
     self.driver = WTF_WEBDRIVER_MANAGER.new_driver()
     self.base_url = WTF_CONFIG_READER.get("selenium.baseurl")
Beispiel #23
0
def get_search_provider():
    "Configure this via the 'search_provider' setting."
    return WTF_CONFIG_READER.get("search_provider", "http://www.google.com")
Beispiel #24
0
def get_admin_password():
    return WTF_CONFIG_READER.get("admin_password", "password")
Beispiel #25
0
def get_admin_user():
    return WTF_CONFIG_READER.get("admin_user", "admin")
Beispiel #26
0
def url_address():
    "Application under test URL"
    return WTF_CONFIG_READER.get('test_data.url')
Beispiel #27
0
def get_search_provider():
    "Configure this via the 'search_provider' setting."
    return WTF_CONFIG_READER.get("search_provider", "http://www.google.com")
Beispiel #28
0
def get_admin_password():
    return WTF_CONFIG_READER.get("admin_password", "password")