Ejemplo n.º 1
0
class DatabasesListActions(object):
    def __init__(self, driver):
        self.selenium_utils = SeleniumUtils(driver)
        self.driver = driver

    def click_add_database_icon(self):
        self.selenium_utils.click(DatabasesListPage.ADD_DB_BUTTON)
Ejemplo n.º 2
0
class CreateChartActions(object):
    def __init__(self, driver):
        self.selenium_utils = SeleniumUtils(driver)
        self.driver = driver

    def create_new_chart(self, data_source_name, viz_type="table"):
        self.selenium_utils.click(CreateChartPage.CHOOSE_DATA_SOURCE)
        self.selenium_utils.find_element(
            *CreateChartPage.DATA_SOURCE_INPUT).send_keys(data_source_name)
        self.selenium_utils.find_element(
            *CreateChartPage.DATA_SOURCE_INPUT).send_keys(Keys.RETURN)
        self.selenium_utils.click(CreateChartPage.CREATE_CHART_BTN)
class HomePageActions(object):
    def __init__(self, driver):
        self.selenium_utils = SeleniumUtils(driver)
        self.driver = driver

    def click_sources(self):
        self.selenium_utils.click(HomePage.SOURCES)

    def click_charts(self):
        self.selenium_utils.click(HomePage.CHARTS)

    def click_dashboard(self):
        self.selenium_utils.click(HomePage.DASHBOARDS)

    def select_database_option(self):
        self.selenium_utils.click(HomePage.DATABASES_OPTION)

    def select_tables_option(self):
        self.selenium_utils.click(HomePage.TABLES_OPTION)
Ejemplo n.º 4
0
 def __init__(self, driver):
     self.selenium_utils = SeleniumUtils(driver)
     self.driver = driver
     self.login_actions = LoginActions(self.driver)
     self.homepage_actions = HomePageActions(self.driver)
     self.database_list_actions = DatabasesListActions(self.driver)
     self.add_database_actions = AddDatabaseActions(self.driver)
     self.db_tables_list_actions = DbTablesListActions(self.driver)
     self.add_db_table_actions = AddDbTableActions(self.driver)
     self.charts_list_actions = ChartsListActions(self.driver)
     self.create_chart_actions = CreateChartActions(self.driver)
     self.generic_slice_actions = GenericVizActions(self.driver)
class LoginActions(object):
    def __init__(self, driver):
        self.selenium_utils = SeleniumUtils(driver)
        self.driver = driver

    def open_browser(self):
        self.driver.get("http://rvf.lab.guavus.com:8888/")
        self.driver.maximize_window()

    def login(self, username, password):
        self.selenium_utils.fill_textbox(
            self.selenium_utils.wait_for_visibility_of_element_located(
                LoginPage.USERNAME), username)
        self.selenium_utils.fill_textbox(
            self.selenium_utils.find_element(*LoginPage.PASSWORD), password)
        self.selenium_utils.click(LoginPage.SUBMIT_BUTTON)
Ejemplo n.º 6
0
 def __init__(self, driver):
     self.selenium_utils = SeleniumUtils(driver)
     self.driver = driver
Ejemplo n.º 7
0
class ChartsListActions(object):
    def __init__(self, driver):
        self.selenium_utils = SeleniumUtils(driver)
        self.driver = driver

    def add_chart(self, chart_name):
        if ChartsListActions(self.driver).check_chart_present(chart_name) == 1:
            self.selenium_utils.click(ChartsListPage.DELETE_CHART_BUTTON)
            self.selenium_utils.click(ChartsListPage.CONFIRM_DELETE_OK)
        self.selenium_utils.click(ChartsListPage.ADD_CHART_ICON)

    def check_chart_present(self, chart_name):
        self.selenium_utils.click(ChartsListPage.FILTER_CHART_LIST_BTN)
        self.selenium_utils.click(ChartsListPage.FILTER_NAME_OPTION)
        self.selenium_utils.click(ChartsListPage.FILTER_ACTION)
        self.selenium_utils.fill_textbox(
            self.selenium_utils.find_element(
                *ChartsListPage.FILTER_ACTION_INPUT), "Equal To")
        self.selenium_utils.find_element(
            *ChartsListPage.FILTER_ACTION_INPUT).send_keys(Keys.RETURN)
        self.selenium_utils.fill_textbox(
            self.selenium_utils.find_element(*ChartsListPage.CHART_NAME_INPUT),
            chart_name)
        self.selenium_utils.click(ChartsListPage.SEARCH_BUTTON)
        try:
            print self.selenium_utils.wait_for_presence_of_element_located(
                ChartsListPage.CHART_NAME_FOUND, timeout=2)
            return 1
        except TimeoutException:
            return 0
class AddDbTableActions(object):
    def __init__(self, driver):
        self.selenium_utils = SeleniumUtils(driver)
        self.driver = driver

    def add_table_details(self, database_name, schema_name, table_name):
        self.selenium_utils.click(AddDBTable.DATABASE_NAME)
        self.selenium_utils.fill_textbox(
            self.selenium_utils.find_element(*AddDBTable.SELECT_DB),
            database_name)
        self.selenium_utils.find_element(*AddDBTable.SELECT_DB).send_keys(
            Keys.RETURN)
        self.selenium_utils.fill_textbox(
            self.selenium_utils.find_element(*AddDBTable.SCHEMA_NAME),
            schema_name)
        self.selenium_utils.fill_textbox(
            self.selenium_utils.find_element(*AddDBTable.TABLE_NAME),
            table_name)
        self.selenium_utils.click(AddDBTable.SAVE_BUTTON)
Ejemplo n.º 9
0
class DbTablesListActions(object):
    def __init__(self, driver):
        self.selenium_utils = SeleniumUtils(driver)
        self.driver = driver

    def add_db_table(self, table_name):
        if DbTablesListActions(
                self.driver).check_table_present(table_name) == 1:
            self.selenium_utils.click(DbTablesListPage.DELETE_TABLE_BUTTON)
            self.selenium_utils.click(DbTablesListPage.CONFIRM_DELETE_OK)
        self.selenium_utils.click(DbTablesListPage.ADD_TABLE_BUTTON)

    def check_table_present(self, table_name):
        self.selenium_utils.click(DbTablesListPage.CLOSE_SQL_LAB_FILTER)
        self.selenium_utils.click(DbTablesListPage.FILTER_BUTTON)
        self.selenium_utils.click(DbTablesListPage.FILTER_TABLE_NAME_OPTION)
        self.selenium_utils.click(DbTablesListPage.FILTER_ACTION)
        self.selenium_utils.fill_textbox(
            self.selenium_utils.find_element(
                *DbTablesListPage.FILTER_ACTION_INPUT), "Equal To")
        self.selenium_utils.find_element(
            *DbTablesListPage.FILTER_ACTION_INPUT).send_keys(Keys.RETURN)
        self.selenium_utils.fill_textbox(
            self.selenium_utils.find_element(
                *DbTablesListPage.TABLE_NAME_INPUT), table_name)
        self.selenium_utils.click(DbTablesListPage.SEARCH_BUTTON)
        try:
            self.selenium_utils.wait_for_presence_of_element_located(
                DbTablesListPage.TABLE_NAME_FOUND, 2000)
            return 1
        except NoSuchElementException:
            return 0

    def check_table_creation_msg(self):
        self.selenium_utils.wait_for_visibility_of_element_located(
            DbTablesListPage.ALERT_DIV)
        msg = self.selenium_utils.find_element(
            *DbTablesListPage.ALERT_DIV).text
        return msg
Ejemplo n.º 10
0
class GenericVizActions(object):
    def __init__(self, driver):
        self.selenium_utils = SeleniumUtils(driver)
        self.driver = driver

    def remove_time_range_filter(self):
        self.selenium_utils.click_through_js(
            self.selenium_utils.find_element(
                *GenericVizProperties.DATA_SOURCE_EXPANDER))
        self.selenium_utils.click_through_js(
            self.selenium_utils.find_element(
                *GenericVizProperties.PUBLICATION_EXPANDER))
        self.selenium_utils.click_through_js(
            self.selenium_utils.find_element(
                *GenericVizProperties.SUBSCRIPTION_EXPANDER))
        self.selenium_utils.click_through_js(
            self.selenium_utils.find_element(
                *GenericVizProperties.ADVANCED_OPTIONS_EXPANDER))
        time.sleep(2)
        self.selenium_utils.click(GenericVizProperties.TIME_RANGE_EDIT)
        self.selenium_utils.click(
            GenericVizProperties.TIME_RANGE_NO_FILTER_OPTION)
        self.selenium_utils.click(GenericVizProperties.TIME_RANGE_OK_BTN)
        self.selenium_utils.click(GenericVizProperties.TIME_EXPANDER)

    def select_columns_not_group_by(self, column_name):
        time.sleep(2)
        self.selenium_utils.click(GenericVizProperties.GROUP_BY_EXPANDER)
        time.sleep(1)
        self.selenium_utils.click(GenericVizProperties.NOT_GROUP_BY_COLUMNS)
        self.selenium_utils.fill_textbox(
            self.selenium_utils.find_element(
                *GenericVizProperties.NOT_GROUP_BY_COLUMNS_INPUT), column_name)
        self.selenium_utils.find_element(
            *GenericVizProperties.NOT_GROUP_BY_COLUMNS_INPUT).send_keys(
                Keys.RETURN)

    def select_row_limit_not_group_by(self, row_limit):
        time.sleep(2)
        self.selenium_utils.click(GenericVizProperties.NOT_GROUP_BY_ROW_LIMIT)
        self.selenium_utils.fill_textbox(
            self.selenium_utils.find_element(
                *GenericVizProperties.NOT_GROUP_BY_ROW_LIMIT_INPUT), row_limit)
        self.selenium_utils.find_element(
            *GenericVizProperties.NOT_GROUP_BY_ROW_LIMIT_INPUT).send_keys(
                Keys.RETURN)

    def run_query(self):
        self.selenium_utils.scroll_into_view(
            self.selenium_utils.find_element(
                *GenericVizProperties.RUN_QUERY_BUTTON))
        self.selenium_utils.click(GenericVizProperties.RUN_QUERY_BUTTON)
        time.sleep(7)

    def save_chart(self, chart_name):
        self.selenium_utils.scroll_into_view(
            self.selenium_utils.find_element(
                *GenericVizProperties.SAVE_BUTTON))
        self.selenium_utils.click(GenericVizProperties.SAVE_BUTTON)
        self.selenium_utils.wait_for_visibility_of_element_located(
            GenericVizProperties.SAVE_CHART_MODAL)
        self.selenium_utils.fill_textbox(
            self.selenium_utils.find_element(
                *GenericVizProperties.SAVE_AS_CHART_NAME), chart_name)
        self.selenium_utils.click(GenericVizProperties.SAVE_CHART_MODAL_BTN)
        time.sleep(7)
Ejemplo n.º 11
0
class AddDatabaseActions(object):
    def __init__(self, driver):
        self.selenium_utils = SeleniumUtils(driver)
        self.driver = driver

    def add_database_details(self, database_name, sql_alchemy_uri, extra):
        self.selenium_utils.fill_textbox(
            self.selenium_utils.wait_for_visibility_of_element_located(
                AddDatabasePage.DATABASE_NAME), database_name)
        self.selenium_utils.fill_textbox(
            self.selenium_utils.find_element(*AddDatabasePage.SQL_ALCHEMY_URI),
            sql_alchemy_uri)
        if extra:
            self.selenium_utils.scroll_into_view(
                self.selenium_utils.find_element(*AddDatabasePage.SAVE_BUTTON))
            self.selenium_utils.fill_textbox(
                self.selenium_utils.find_element(*AddDatabasePage.EXTRA),
                extra)
        self.selenium_utils.scroll_into_view(
            self.selenium_utils.find_element(*AddDatabasePage.DATABASE_NAME))
        self.selenium_utils.click(AddDatabasePage.TEST_CONNECTION_BUTTON)
        msg = AddDatabaseActions(self.driver).get_alert_message()
        assert "Seems OK" in msg
        self.selenium_utils.scroll_into_view(
            self.selenium_utils.find_element(*AddDatabasePage.SAVE_BUTTON))
        self.selenium_utils.click(AddDatabasePage.SAVE_BUTTON)
        time.sleep(5)

    def get_alert_message(self):
        msg = ""
        try:
            WebDriverWait(self.driver, 3).until(EC.alert_is_present(),
                                                'Timed out waiting for alert')
            alert = self.driver.switch_to.alert
            msg = alert.text
            alert.accept()
        except TimeoutException:
            print("no alert")
        return msg