class DataReader:
    """
    This class includes basic reusable data helpers.
    """
    log = log_utils.custom_logger(logging.INFO)
    config = ConfigUtility()

    def __init__(self):
        self.cur_path = os.path.abspath(os.path.dirname(__file__))

    def load_test_data(self):
        """
        This methods is used for loading excel file data for UI cases
        :return: it returns excel records
        """
        records = None

        # noinspection PyBroadException
        prop = self.config.load_properties_file()
        base_test_data = prop.get('RAFT', 'base_test_data')
        ui_file_path = os.path.join(
            self.cur_path, r"../TestData/{}.xlsx".format(base_test_data))

        try:
            if ui_file_path is not None:
                records = exc.iget_records(file_name=ui_file_path)
        except Exception as ex:
            self.log.error("Failed to load test data.\n{}".format(ex))

        return records

    def get_data(self, tc_name, column_name):
        """
        This method is used for returning column data specific to ui test case name
        :param tc_name: it takes test case name as input parameter
        :param column_name: it takes the name of the column for which value has to be returned
        :return:
        """
        value = None
        excel_records = self.load_test_data()

        # noinspection PyBroadException

        try:
            if excel_records is not None:
                for record in excel_records:
                    if record['TC_Name'] == tc_name:
                        value = record[column_name]
                        break
                    else:
                        continue

        except Exception as ex:
            self.log.error("Failed to get test data.\n{}".format(ex))

        return value
class DriverFactory:
    """
    This class contains the reusable methods for getting the driver instances
    """
    log = custom_logger(logging.INFO)
    config = ConfigUtility()

    def __init__(self, platform):
        self.platform = platform
        self.cur_path = os.path.abspath(os.path.dirname(__file__))
        self.prop = self.config.load_properties_file()

    def get_driver_instance(self):

        if self.platform == "android":

            app_location = os.path.join(
                self.cur_path, r"../MobileApp/",
                self.prop.get('Cap_Android', 'app_name'))

            desired_caps = {
                'automationName':
                self.prop.get('Cap_Android', 'automation_name'),
                'deviceName':
                self.prop.get('Cap_Android', 'device_name'),
                'udid':
                self.prop.get('Cap_Android', 'ud_id'),
                'platformName':
                'android',
                'platformVersion':
                self.prop.get('Cap_Android', 'platform_version'),
                'appPackage':
                self.prop.get('Cap_Android', 'app_package'),
                'appActivity':
                self.prop.get('Cap_Android', 'app_activity'),
                'app':
                app_location,
                'noReset':
                self.prop.get('Cap_Android', 'no_reset'),
                'autoGrantPermissions':
                self.prop.get('Cap_Android', 'auto_grant_permissions')
            }

            driver = webdriver.Remote(command_executor=self.prop.get(
                'Grid', 'appium_server'),
                                      desired_capabilities=desired_caps)

            return driver

        elif self.platform == "ios":
            pass
class BaseAPI:
    """This class defines the method and element identifications for main page."""

    log = log_utils.custom_logger(logging.INFO)

    def __init__(self):
        self.config = ConfigUtility()
        self.api = APIUtilily()
        self.prop = self.config.load_properties_file()
        # self.log = log_utils.custom_logger(logging.INFO)

    def verify_users(self):
        """
        This function is used to verify users
        :return: this function returns boolean status of element located
        """
        result = False
        res = self.api.get_api_response(
            endpoint=self.prop.get('RAFT', 'base_api'))
        if res is not None:
            res = res.json()
            self.log.info(res)
            result = True

        return result

    def verify_valid_user(self, email, first_name, last_name):
        """
        This function is used to verify email and username of a particular user
        :param last_name: user first name
        :param first_name: user last name
        :param email: user email address
        :return: status of the valid user
        """
        result = False
        res = self.api.get_api_response(
            endpoint=self.prop.get('RAFT', 'base_api'))
        if res is not None:
            res = res.json()
            self.log.info(res)

            if email == res['data'][0]['email'] and \
                    first_name == res['data'][0]['first_name'] and \
                    last_name == res['data'][0]['last_name']:
                result = True

        return result
Exemplo n.º 4
0
class DataReader:

    log = log_utils.custom_logger(logging.INFO)
    config = ConfigUtility()

    def __init__(self):
        self.cur_path = os.path.abspath(os.path.dirname(__file__))

    def load_test_data(self):

        records = None
        prop = self.config.load_properties_file()
        base_test_data = prop.get('RAFT', 'test_data')
        ui_file_path = os.path.join(
            self.cur_path, r"../TestData/{}.xlsx".format(base_test_data))

        try:
            if ui_file_path is not None:
                records = exc.iget_records(file_name=ui_file_path)
        except Exception as ex:
            self.log.error("Failed to load test data.", ex)

        return records

    def get_data(self, tc_name, column_name):

        value = None
        excel_records = self.load_test_data()

        try:
            if excel_records is not None:
                for record in excel_records:
                    if record['TC_Name'] == tc_name:
                        value = record[column_name]
                        break
                    else:
                        continue

        except Exception as ex:
            self.log.error("Failed to get test data.", ex)

        return value
class MainPageTests(unittest.TestCase):
    """
    This class contains the executable test cases.
    """

    data_reader = DataReader()
    config = ConfigUtility()
    log = log_utils.custom_logger(logging.INFO)

    def setUp(self):
        self.main_page = MainPage(self.driver)
        self.exe_status = ExecutionStatus(self.driver)
        self.prop = self.config.load_properties_file()

    def tearDown(self):
        pass
        # self.login_page.logout_from_app()

    @pytest.fixture(autouse=True)
    def class_level_setup(self, request):
        """
        This method is used for one time setup of test execution process.
        :return: it returns nothing
        """

        if self.data_reader.get_data(request.function.__name__,
                                     "Runmode") != "Y":
            pytest.skip("Excluded from current execution run.")

    @allure.testcase("Verify Main Screen Elements")
    def test_verify_main_screen_elements(self):
        """
        This test is validating the presence of main screen elements.
        :return: return test status
        """
        test_name = sys._getframe().f_code.co_name

        self.log.info("###### TEST EXECUTION STARTED :: " + test_name +
                      " ######")

        with allure.step("Verify Presence of Main Screen Elements Successful"):
            result = self.main_page.verify_main_screen_elements()
            self.exe_status.mark_final(
                test_step="Verify Presence of Main Screen Elements Successful",
                result=result)

    def test_verify_supertackle_reset(self):
        """
        This test is validating the presence of main screen elements.
        :return: return test status
        """
        test_name = sys._getframe().f_code.co_name

        self.log.info("###### TEST EXECUTION STARTED :: " + test_name +
                      " ######")

        with allure.step("Verify Super Tackle Functionality"):
            result_1 = self.main_page.verify_super_tackle_functionality(
                self.data_reader.get_data(test_name, "MovePoint"))
            self.exe_status.mark(test_step="Verify Super Tackle Functionality",
                                 result=result_1)

        with allure.step("Verify Reset Button Functionality"):
            result = self.main_page.verify_reset_button_functionality()
            self.exe_status.mark_final(
                test_step="Verify Reset Button Functionality", result=result)
Exemplo n.º 6
0
class MainTest(unittest.TestCase):
    """
    This class contains the executable test cases.
    """

    data_reader = DataReader()
    config = ConfigUtility()
    log = log_utils.custom_logger(logging.INFO)

    def setUp(self):
        self.mainpage = Mainpage(self.driver)
        self.exe_status = ExecutionStatus(self.driver)
        self.prop = self.config.load_properties_file()

    # def tearDown(self):
    #     self.login_page.logout_from_app()

    def string_generator(self,
                         string_size=8,
                         chars=string.ascii_uppercase + string.digits):
        """
        This function is used to generate random string
        :return: it returns random string
        """
        return ''.join(random.choice(chars) for _ in range(string_size))

    @pytest.fixture(autouse=True)
    def class_level_setup(self, request):
        """
        This method is used for one time setup of test execution process.
        :return: it returns nothing
        """

        if self.data_reader.get_data(request.function.__name__,
                                     "Runmode") != "Y":
            pytest.skip("Excluded from current execution run.")

    @allure.testcase("Validate  startscan btn Test")
    def test_validate_start_scan_buttons(self):
        """
        This test is used to verify the start scan button availability. (positive scenario)
        :return: return test status
        """
        test_name = sys._getframe().f_code.co_name

        self.log.info("###### TEST EXECUTION STARTED :: " + test_name +
                      " ######")

        with allure.step("Validate  startscan btn Test successful"):
            result = self.mainpage.verify_start_scan_button()
            self.exe_status.mark_final(
                test_step="Validate  startscan btnSuccessful", result=result)

    @allure.testcase("Validate  stopscan btn Test")
    def test_validate_stop_scan_buttons(self):
        """
        This test is is used to verify the stop scan button availability. (positive scenario)
        :return: return test status
        """
        test_name = sys._getframe().f_code.co_name

        self.log.info("###### TEST EXECUTION STARTED :: " + test_name +
                      " ######")
        with allure.step("Validate  stopscan btn Successful"):
            result = self.mainpage.verify_stop_scan_button()
            self.exe_status.mark_final(
                test_step="Validate  stopscan btn Successful", result=result)

    def test_validate_vertical_scroll_find_element(self):
        """
        This method is used to verify  scrolling the page vertically (positive scenario)
        :return: return test status
        """
        test_name = sys._getframe().f_code.co_name

        self.log.info("###### TEST EXECUTION STARTED :: " + test_name +
                      " ######")
        with allure.step(
                "Validate vertical scroll and find element  Successful"):
            result = self.mainpage.verify_medical_screen_elements()
            self.exe_status.mark_final(
                test_step=
                "Validate vertical scroll and find find element Successful",
                result=result)

    def test_validate_connecting_medical_device_to_app(self):
        """
        This method is used to verify  connecting of medical device with app (positive scenario)
        :return: return test status
        """
        test_name = sys._getframe().f_code.co_name

        self.log.info("###### TEST EXECUTION STARTED :: " + test_name +
                      " ######")
        with allure.step(
                "Validate connecting  medical device with app  Successful"):
            result = self.mainpage.verify_medicaldevice_pairing()
            self.exe_status.mark_final(
                test_step="connecting  medical device with app", result=result)

    def test_validate_retrieve_all_buttons(self):
        """
       This method is used to verify  pressing on all retrieve buttons (positive scenario)
        :return: return test status
        """
        test_name = sys._getframe().f_code.co_name

        self.log.info("###### TEST EXECUTION STARTED :: " + test_name +
                      " ######")
        with allure.step(
                "Validate pressing on all retrive buttons is Successful"):
            result = self.mainpage.verify_retrieve_all_buttons()
            self.exe_status.mark_final(
                test_step="pressing on all retrieve buttons", result=result)

    if __name__ == '__main__':
        unittest.main(verbosity=2)
Exemplo n.º 7
0
class DriverFactory:
    """
    This class contains the reusable methods for getting the driver instances
    """
    log = custom_logger(logging.INFO)
    config = ConfigUtility()

    def __init__(self, browser, platform, environment, url=""):
        self.platform = platform
        self.browser = browser
        self.environment = environment
        self.url = url
        self.cur_path = os.path.abspath(os.path.dirname(__file__))
        self.prop = self.config.load_properties_file()

    def get_driver_instance(self):

        if self.browser == "chrome":

            chrome_capabilities = webdriver.DesiredCapabilities.CHROME
            chrome_capabilities['platform'] = self.platform
            chrome_capabilities['browserName'] = 'chrome'
            chrome_capabilities['javascriptEnabled'] = True

            options = chromeOptions()
            options.add_argument("--disable-infobars")
            options.add_argument("--disable-extensions")
            options.add_argument("--disable-notifications")
            options.add_argument("--start-maximized")
            options.add_argument("--disable-web-security")
            options.add_argument("--no-proxy-server")
            options.add_argument("--enable-automation")
            options.add_argument("--disable-save-password-bubble")
            options.add_experimental_option('prefs', {'credentials_enable_service': False,
                                                      'profile': {'password_manager_enabled': False}})

            driver = webdriver.Remote(
                command_executor=self.prop.get('GRID', 'GRID_SERVER'),
                desired_capabilities=chrome_capabilities, options=options)

        elif self.browser == "firefox":

            firefox_capabilities = webdriver.DesiredCapabilities.FIREFOX
            firefox_capabilities['platform'] = self.platform
            firefox_capabilities['browserName'] = 'firefox'
            firefox_capabilities['javascriptEnabled'] = True
            firefox_capabilities['marionette'] = True

            options = ffOptions()
            options.log.level = 'trace'

            driver = webdriver.Remote(command_executor=self.prop.get('GRID', 'GRID_SERVER'),
                                      desired_capabilities=firefox_capabilities, options=options)

        elif self.browser == "safari":

            safari_capabilities = webdriver.DesiredCapabilities.SAFARI
            safari_capabilities['platform'] = self.platform
            safari_capabilities['browserName'] = 'safari'
            safari_capabilities['javascriptEnabled'] = True

            driver = webdriver.Remote(
                command_executor=self.prop.get('GRID', 'GRID_SERVER'),
                desired_capabilities=safari_capabilities)

        elif self.browser == "edge":

            edge_capabilities = webdriver.DesiredCapabilities.EDGE
            edge_capabilities['platform'] = self.platform
            edge_capabilities['browserName'] = 'MicrosoftEdge'
            edge_capabilities['javascriptEnabled'] = True

            driver = webdriver.Remote(
                command_executor=self.prop.get('GRID', 'GRID_SERVER'),
                desired_capabilities=edge_capabilities)

        elif self.browser == "sauce":
            username = self.prop.get('CLOUD', 'sl_username')
            automate_key = self.prop.get('CLOUD', 'sl_key')
            url = "https://" + username + ":" + automate_key + "@ondemand.saucelabs.com:443/wd/hub"

            caps = {}
            caps['browserName'] = "Safari"
            caps['appiumVersion'] = "1.8.1"
            caps['deviceName'] = "iPhone X Simulator"
            caps['deviceOrientation'] = "portrait"
            caps['platformVersion'] = "11.3"
            caps['platformName'] = "iOS"
            caps['name'] = "iPhone X Execution"

            driver = webdriver.Remote(
                command_executor=url,
                desired_capabilities=caps)

        elif self.browser == "browserstack_desktop":
            username = self.prop.get('CLOUD', 'bs_username')
            automate_key = self.prop.get('CLOUD', 'bs_key')
            url = "http://" + username + ":" + automate_key + "@hub.browserstack.com:80/wd/hub"

            caps = {}
            caps['browser'] = 'Firefox'
            caps['browser_version'] = '61.0'
            caps['os'] = 'OS X'
            caps['os_version'] = 'High Sierra'
            caps['resolution'] = '1024x768'
            caps['name'] = "Mac Safari Execution"
            caps['browserstack.debug'] = True
            caps['browserstack.networkLogs'] = True

            driver = webdriver.Remote(
                command_executor=url,
                desired_capabilities=caps)

        elif self.browser == "browserstack_mobile":
            username = self.prop.get('CLOUD', 'bs_username')
            automate_key = self.prop.get('CLOUD', 'bs_key')
            url = "http://" + username + ":" + automate_key + "@hub-cloud.browserstack.com/wd/hub"

            caps={}

            caps['device'] = 'Google Pixel'
            caps['os_version'] = '7.1'
            caps['name'] = "Google Pixcel Execution"

            driver = webdriver.Remote(
                command_executor=url,
                desired_capabilities=caps)

        elif self.browser == "local_edge":

            driver_location = os.path.join(self.cur_path, r"../ExternalDrivers/MicrosoftWebDriver.exe")
            os.environ["webdriver.edge.driver"] = driver_location

            edge_capabilities = webdriver.DesiredCapabilities.EDGE
            driver = webdriver.Edge(capabilities=edge_capabilities, executable_path=driver_location)

        elif self.browser == "local_firefox":
            driver_location = os.path.join(self.cur_path, r"../ExternalDrivers/geckodriver.exe")
            os.environ["webdriver.gecko.driver"] = driver_location

            browser_profile = webdriver.FirefoxProfile()
            browser_profile.set_preference("dom.webnotifications.enabled", False)

            options = ffOptions()
            options.log.level = 'trace'
            firefox_capabilities = webdriver.DesiredCapabilities.FIREFOX
            firefox_capabilities['marionette'] = True
            driver = webdriver.Firefox(capabilities=firefox_capabilities, executable_path=driver_location,
                                       options=options, log_path='/tmp/geckodriver.log',
                                       firefox_profile=browser_profile)

        elif self.browser == "local_chrome":
            driver_location = os.path.join(self.cur_path, r"../ExternalDrivers/chromedriver.exe")
            os.environ["webdriver.chrome.driver"] = driver_location

            options = chromeOptions()
            options.add_argument("--disable-infobars")
            options.add_argument("--disable-extensions")
            options.add_argument("--disable-notifications")
            options.add_argument("--start-maximized")
            options.add_argument("--disable-web-security")
            options.add_argument("--no-proxy-server")
            options.add_argument("--enable-automation")
            options.add_argument("--disable-save-password-bubble")
            options.add_experimental_option('prefs', {'credentials_enable_service': False,
                                                      'profile': {'password_manager_enabled': False}})

            driver = webdriver.Chrome(driver_location, options=options)

        else:
            driver_location = os.path.join(self.cur_path, r"../ExternalDrivers/chromedriver.exe")
            os.environ["webdriver.chrome.driver"] = driver_location

            options = chromeOptions()
            options.add_argument("--disable-infobars")
            options.add_argument("--disable-extensions")
            options.add_argument("--disable-notifications")
            options.add_argument("--start-maximized")
            options.add_argument("--disable-web-security")
            options.add_argument("--no-proxy-server")
            options.add_argument("--enable-automation")
            options.add_argument("--disable-save-password-bubble")
            options.add_experimental_option('prefs', {'credentials_enable_service': False,
                                                      'profile': {'password_manager_enabled': False}})

            driver = webdriver.Chrome(driver_location, options=options)

        if "chrome" in self.browser:
            driver.fullscreen_window()

        if self.environment == "staging":
            test_data = self.prop.get('RAFT', 'staging_test_data')
            self.config.change_properties_file('RAFT', 'base_test_data', test_data)
            self.url = self.prop.get('RAFT', 'staging_url')
            self.config.change_properties_file('RAFT', 'base_url', self.url)

        elif self.environment == "prod":
            test_data = self.prop.get('RAFT', 'prod_test_data')
            self.config.change_properties_file('RAFT', 'base_test_data', test_data)
            self.url = self.prop.get('RAFT', 'prod_url')
            self.config.change_properties_file('RAFT', 'base_url', self.url)

        else:
            test_data = self.prop.get('RAFT', 'staging_test_data')
            self.config.change_properties_file('RAFT', 'base_test_data', test_data)
            self.url = self.prop.get('RAFT', 'staging_url')
            self.config.change_properties_file('RAFT', 'base_url', self.url)

        driver.get(self.url)

        return driver
Exemplo n.º 8
0
class DriverFactory:
    """
    This class contains the reusable methods for getting the driver instances
    """
    log = custom_logger(logging.INFO)
    config = ConfigUtility()

    def __init__(self, browser, platform, environment, url=""):
        self.platform = platform
        self.browser = browser
        self.environment = environment
        self.url = url
        self.cur_path = os.path.abspath(os.path.dirname(__file__))
        self.prop = self.config.load_properties_file()

    def get_driver_instance(self):

        if self.browser == "chrome":

            chrome_capabilities = webdriver.DesiredCapabilities.CHROME
            chrome_capabilities['platform'] = self.platform
            chrome_capabilities['browserName'] = 'chrome'
            chrome_capabilities['javascriptEnabled'] = True

            options = chromeOptions()
            options.add_argument("--disable-infobars")
            options.add_argument("--disable-extensions")
            options.add_argument("--disable-notifications")
            options.add_argument("--start-maximized")
            options.add_argument("--disable-web-security")
            options.add_argument("--no-proxy-server")
            options.add_argument("--enable-automation")
            options.add_argument("--disable-save-password-bubble")
            options.add_experimental_option(
                'prefs', {
                    'credentials_enable_service': False,
                    'profile': {
                        'password_manager_enabled': False
                    }
                })

            driver = webdriver.Remote(command_executor=self.prop.get(
                'GRID', 'GRID_SERVER'),
                                      desired_capabilities=chrome_capabilities,
                                      options=options)

        elif self.browser == "firefox":

            firefox_capabilities = webdriver.DesiredCapabilities.FIREFOX
            firefox_capabilities['platform'] = self.platform
            firefox_capabilities['browserName'] = 'firefox'
            firefox_capabilities['javascriptEnabled'] = True
            firefox_capabilities['marionette'] = True

            options = ffOptions()
            options.log.level = 'trace'

            driver = webdriver.Remote(
                command_executor=self.prop.get('GRID', 'GRID_SERVER'),
                desired_capabilities=firefox_capabilities,
                options=options)

        elif self.browser == "safari":

            safari_capabilities = webdriver.DesiredCapabilities.SAFARI
            safari_capabilities['platform'] = self.platform
            safari_capabilities['browserName'] = 'safari'
            safari_capabilities['javascriptEnabled'] = True

            driver = webdriver.Remote(command_executor=self.prop.get(
                'GRID', 'GRID_SERVER'),
                                      desired_capabilities=safari_capabilities)

        elif self.browser == "sauce":

            username = self.prop.get('CLOUD', 'sl_username')
            automate_key = self.prop.get('CLOUD', 'sl_key')
            url = "https://{}:{}@ondemand.saucelabs.com:443/wd/hub".format(
                username, automate_key)
            caps = {
                'browserName': "Safari",
                'appiumVersion': "1.8.1",
                'deviceName': "iPhone X Simulator",
                'deviceOrientation': "portrait",
                'platformVersion': "11.3",
                'platformName': "iOS",
                'name': "iPhone X Execution"
            }

            driver = webdriver.Remote(command_executor=url,
                                      desired_capabilities=caps)

        elif self.browser == "browserstack_web":

            username = self.prop.get('CLOUD', 'bs_username')
            automate_key = self.prop.get('CLOUD', 'bs_key')
            url = "http://{}:{}@hub.browserstack.com:80/wd/hub".format(
                username, automate_key)

            caps = {
                'browser': 'Firefox',
                'browser_version': '61.0',
                'os': 'OS X',
                'os_version': 'High Sierra',
                'resolution': '1024x768',
                'name': "Mac Safari Execution",
                'browserstack.debug': True,
                'browserstack.networkLogs': True
            }

            driver = webdriver.Remote(command_executor=url,
                                      desired_capabilities=caps)

        elif self.browser == "browserstack_mobile":

            username = self.prop.get('CLOUD', 'bs_username')
            automate_key = self.prop.get('CLOUD', 'bs_key')
            url = "http://{}:{}@hub.browserstack.com:80/wd/hub".format(
                username, automate_key)

            caps = {
                'device': 'Google Pixel',
                'os_version': '7.1',
                'name': "Google Pixcel Execution"
            }

            driver = webdriver.Remote(command_executor=url,
                                      desired_capabilities=caps)

        elif self.browser == "local_chrome":

            options = chromeOptions()
            options.add_argument("--disable-infobars")
            options.add_argument("--disable-extensions")
            options.add_argument("--disable-notifications")
            options.add_argument("--start-maximized")
            options.add_argument("--disable-web-security")
            options.add_argument("--no-proxy-server")
            options.add_argument("--enable-automation")
            options.add_argument("--disable-save-password-bubble")
            options.add_experimental_option(
                'prefs', {
                    'credentials_enable_service': False,
                    'profile': {
                        'password_manager_enabled': False
                    }
                })

            driver = webdriver.Chrome(ChromeDriverManager().install(),
                                      options=options)

        elif self.browser == "local_firefox":

            browser_profile = webdriver.FirefoxProfile()
            browser_profile.set_preference("dom.webnotifications.enabled",
                                           False)

            options = ffOptions()
            options.log.level = 'trace'
            firefox_capabilities = webdriver.DesiredCapabilities.FIREFOX
            firefox_capabilities['marionette'] = True

            driver = webdriver.Firefox(
                capabilities=firefox_capabilities,
                executable_path=GeckoDriverManager().install(),
                options=options,
                service_log_path='/tmp/geckodriver.log',
                firefox_profile=browser_profile)

        else:

            options = chromeOptions()
            options.add_argument("--disable-infobars")
            options.add_argument("--disable-extensions")
            options.add_argument("--disable-notifications")
            options.add_argument("--start-maximized")
            options.add_argument("--disable-web-security")
            options.add_argument("--no-proxy-server")
            options.add_argument("--enable-automation")
            options.add_argument("--disable-save-password-bubble")
            options.add_experimental_option(
                'prefs', {
                    'credentials_enable_service': False,
                    'profile': {
                        'password_manager_enabled': False
                    }
                })

            driver = webdriver.Chrome(ChromeDriverManager().install(),
                                      options=options)

        if "chrome" in self.browser:
            driver.fullscreen_window()

        if self.environment == "staging":
            test_data = self.prop.get('RAFT', 'staging_test_data')
            self.config.change_properties_file('RAFT', 'base_test_data',
                                               test_data)
            self.url = self.prop.get('RAFT', 'staging_url')
            self.config.change_properties_file('RAFT', 'base_url', self.url)

        elif self.environment == "prod":
            test_data = self.prop.get('RAFT', 'prod_test_data')
            self.config.change_properties_file('RAFT', 'base_test_data',
                                               test_data)
            self.url = self.prop.get('RAFT', 'prod_url')
            self.config.change_properties_file('RAFT', 'base_url', self.url)

        else:
            test_data = self.prop.get('RAFT', 'staging_test_data')
            self.config.change_properties_file('RAFT', 'base_test_data',
                                               test_data)
            self.url = self.prop.get('RAFT', 'staging_url')
            self.config.change_properties_file('RAFT', 'base_url', self.url)

        driver.get(self.url)

        return driver
Exemplo n.º 9
0
class DriverFactory:

    log = custom_logger(logging.INFO)
    config = ConfigUtility()

    def __init__(self, browser, platform, environment, url=""):
        self.platform = platform
        self.browser = browser
        self.environment = environment
        self.url = url
        self.cur_path = os.path.abspath(os.path.dirname(__file__))
        self.prop = self.config.load_properties_file()

    def get_driver_instance(self):

        if self.browser == "chrome":

            chrome_capabilities = webdriver.DesiredCapabilities.CHROME
            chrome_capabilities['platform'] = self.platform
            chrome_capabilities['browserName'] = 'chrome'
            chrome_capabilities['javascriptEnabled'] = True

            options = chromeOptions()
            options.add_argument("--disable-infobars")
            options.add_argument("--disable-extensions")
            options.add_argument("--disable-notifications")
            options.add_argument("--start-maximized")
            options.add_argument("--disable-web-security")
            options.add_argument("--no-proxy-server")
            options.add_argument("--enable-automation")
            options.add_argument("--disable-save-password-bubble")
            options.add_experimental_option(
                'prefs', {
                    'credentials_enable_service': False,
                    'profile': {
                        'password_manager_enabled': False
                    }
                })

            driver = webdriver.Remote(command_executor=self.prop.get(
                'GRID', 'GRID_SERVER'),
                                      desired_capabilities=chrome_capabilities,
                                      options=options)

        elif self.browser == "firefox":

            firefox_capabilities = webdriver.DesiredCapabilities.FIREFOX
            firefox_capabilities['platform'] = self.platform
            firefox_capabilities['browserName'] = 'firefox'
            firefox_capabilities['javascriptEnabled'] = True
            firefox_capabilities['marionette'] = True

            options = ffOptions()
            options.log.level = 'trace'

            driver = webdriver.Remote(
                command_executor=self.prop.get('GRID', 'GRID_SERVER'),
                desired_capabilities=firefox_capabilities,
                options=options)

        elif self.browser == "safari":

            safari_capabilities = webdriver.DesiredCapabilities.SAFARI
            safari_capabilities['platform'] = self.platform
            safari_capabilities['browserName'] = 'safari'
            safari_capabilities['javascriptEnabled'] = True

            driver = webdriver.Remote(command_executor=self.prop.get(
                'GRID', 'GRID_SERVER'),
                                      desired_capabilities=safari_capabilities)

        else:
            test_data = self.prop.get('RAFT', 'staging_test_data')
            self.config.change_properties_file('RAFT', 'base_test_data',
                                               test_data)
            self.url = self.prop.get('RAFT', 'staging_url')
            self.config.change_properties_file('RAFT', 'base_url', self.url)

        driver.get(self.url)

        return driver
 def __init__(self):
     self.config = ConfigUtility()
     self.api = APIUtilily()
     self.prop = self.config.load_properties_file()
Exemplo n.º 11
0
class Mainpage(BaseHelpers):
    """This class defines the method and element identifications for Main page."""

    config = ConfigUtility()
    log = custom_logger(logging.INFO)

    # def __init__(self, driver):
    #     super().__init__(driver)
    #     self.driver = driver
    #     self.mp = MainPage
    #     self.prop = self.config.load_properties_file()
    #
    # welcome_page_login_link = "//android.widget.TextView[contains(@text, 'Login')]"
    # email = "//android.widget.TextView[contains(@text,'Email')]//following::android.widget.EditText[1]"
    # password = "******"
    # login_button = "//android.widget.TextView[contains(@text, 'Log in')]"
    # logout_button = "//android.widget.TextView[contains(@text, 'Logout')]"
    # logout_scroll_view_class = "android.widget.ScrollView"
    # logout_text_class = "android.widget.TextView"
    # logout_text = "Logout"
    #
    number_firstpage = "//android.widget.TextView[@text='NUM 1']"
    number_secondpage = "//android.widget.TextView[@text='NUM 2']"
    start_scan_button = "//android.widget.Button[@text='START SCAN']"
    stop_scan_button = "//android.widget.Button[@text='STOP SCAN']"
    init_with_mac = "//android.widget.Button[@text='INIT WITH MAC']"
    disconnect_button = "//android.widget.Button[@text='DISCONNECT']"
    connect_button = "//android.widget.Button[@text='CONNECT']"
    connected = "//android.widget.TextView[@text='Connected']"
    disconnected = "//android.widget.TextView[@text='Disconnected']"
    start_observing_button = "//android.widget.Button[@text='START OBSERVING']"
    stop_observing_button = "//android.widget.Button[@text='STOP OBSERVING']"
    test_cache = "//android.widget.Button[@text='TEST CACHE']"
    clear_cache = "//android.widget.Button[@text='CLEAR CACHE']"
    scanning = "//android.widget.TextView[@text='Scanning']"
    bond_status1 = "//android.widget.TextView[@text='Bond Status: Not bonded']"
    bond_status2 = "//android.widget.TextView[@text='Bond Status: Bonded']"
    connection_status1 = "//android.widget.TextView=[@text='Connection Status: RxBleConnectionState{CONNECTING}']"
    connection_status2 = "//android.widget.TextView=[@text='Connection Status: RxBleConnectionState{DISCONNECTED}']"
    scroll_grey_screen = "//android.widget.ScrollView=[@text='']"
    pairing_request_ok = "//android.widget.Button=[@text='OK']"
    show_device_info = "//android.widget.Button=[@text='SHOW DEVICE INFO']"
    # retrieve buttons
    retrieve_new = "//android.widget.Button[@text='RETRIEVE NEW']"
    retrieve_all = "//android.widget.Button[@text='RETRIEVE ALL']"
    retrieve_oldest = "//android.widget.Button[@text='RETRIEVE OLDEST']"
    retrieve_newest = "//android.widget.Button[@text='RETRIEVE NEWEST']"
    retrieve_sequence_num = "//android.widget.Button[@text='RETRIEVE SEQ. #']"
    retrieve_from_sequence_num = "//android.widget.Button[@text='RETRIEVE FROM SEQ. #']"
    # state buttons
    save_state = "//android.widget.Button=[@text='SAVE STATE']"
    restore_state = "//android.widget.Button=[@text='RESTORE STATE']"
    # GET buttons
    get_features = "//android.widget.Button=[@text='GET FEATURES']"
    get_current_time = "//android.widget.Button=[@text='GET CURRENT TIME']"
    get_battery_level = "//android.widget.Button=[@text='GET BATTERY LEVEL']"
    get_local_timeinfo = "//android.widget.Button=[@text='GET LOCAL TIME INFO']"
    get_refresh_timeinfo = "//android.widget.Button=[@text='GET REF TIME INFO']"
    get_model_number = "//android.widget.Button=[@text='GET MODEL #']"
    get_manufacture_name = "//android.widget.Button=[@text='GET MAN. NAME']"
    get_serial_number = "//android.widget.Button=[@text='GET SERIAL #']"
    get_hw_rev = "//android.widget.Button=[@text='GET HW REV']"
    get_fw_rev = "//android.widget.Button=[@text='GET FW REV']"
    get_sw_rev = "//android.widget.Button=[@text='GET SW REV']"
    get_sys_id = "//android.widget.Button=[@text='GET SYS ID']"
    get_pnp_id = "//android.widget.Button=[@text='GET PNP ID']"
    get_Fw_Rev_class = "android.widget.Button"
    get_Fw_Rev_Text = "GET FW REV"
    scroll_view_class = "android.widget.ScrollView"
    stpo_scan = "STOP SCAN"
    # medical device info
    medical_device_info_1 = "//android.widget.TextView[@text='Contour7830H6086398 (54:6C:0E:CB:D5:E1)']"  # Contour
    medical_device_info_2 = "//android.widget.TextView[@text='meter+06647277 (10:CE:A9:3B:D7:57)']"  # Accu-Chek Guide

    def verify_start_scan_button(self):
        """
        This method is used to verify the start scan button availabilty.
        :return: this method returns boolean value for element present start scan button
        """
        self.mouse_click_action_on_element_present(self.number_secondpage)
        result = self.is_element_present(self.start_scan_button,
                                         max_time_out=30)

        if not result:
            self.log.error("Unable to find start scan button")

        return result

    def verify_stop_scan_button(self):
        """
        This method is used to verify the stop scan button availabilty.
        :return: this method returns boolean value for element present stop scan button
        """

        result = self.is_element_present(self.stop_scan_button)

        if not result:
            self.log.error("Unable to find stop scan button.")

        return result

    def verify_medical_screen_elements(self):
        """
        This method is used to verify  scrolling the page vertically.
        :return: this method returns boolean value for element present and scrolling successful
        """
        self.vertical_scroll(self.scroll_view_class, self.get_Fw_Rev_class,
                             self.get_Fw_Rev_Text)
        self.vertical_scroll(self.scroll_view_class, self.get_Fw_Rev_class,
                             self.stpo_scan)
        self.wait_for_sync()
        result = self.is_element_present(self.stop_scan_button)

        if not result:
            self.log.error("Unable to scroll  application.")

        return result

    def verify_medicaldevice_pairing(self):
        """
        This method is used to verify  connecting of medical device with app (positive scenario)
        :return: return test status
        """
        self.mouse_click_action_on_element_present(self.number_firstpage)
        self.mouse_click_action_on_element_present(self.start_scan_button)
        self.mouse_click_action_on_element_present(self.stop_scan_button)
        self.mouse_click_action_on_element_present(self.medical_device_info_2)
        self.mouse_click_action_on_element_present(self.connect_button)
        self.wait_for_sync()
        self.wait_for_sync()
        self.wait_for_sync()
        result = self.is_element_present(self.retrieve_all)

        if not result:
            self.log.error("Unable to connect medical device.")

        return result

    def verify_retrieve_all_buttons(self):
        """
        This method is used to verify  pressing on all retrieve buttons (positive scenario)
        :return: return test status
        """
        self.wait_for_sync()
        self.wait_for_sync()
        self.mouse_click_action_on_element_present(self.retrieve_all)
        self.device_back_button_click()
        self.wait_for_sync()
        self.mouse_click_action_on_element_present(self.retrieve_oldest)
        self.device_back_button_click()
        self.wait_for_sync()
        self.mouse_click_action_on_element_present(self.retrieve_newest)
        self.device_back_button_click()
        self.wait_for_sync()
        self.mouse_click_action_on_element_present(self.retrieve_new)
        self.wait_for_sync()
        self.device_back_button_click()
        self.wait_for_sync()
        self.mouse_click_action_on_element_present(self.retrieve_sequence_num)
        self.wait_for_sync()
        self.device_back_button_click()
        self.wait_for_sync()
        self.mouse_click_action_on_element_present(
            self.retrieve_from_sequence_num)
        self.wait_for_sync()
        self.device_back_button_click()
        result = self.is_element_present(self.retrieve_from_sequence_num)

        if not result:
            self.log.error("Unable to press all the retrieve buttons.")

        return result