Example #1
0
class MainPage(BasePage):
    locators = MainPageLocators()

    def go_to_python_events(self):
        self.click(self.locators.PYTHON_EVENTS)
        return PythonEventsPage(self.driver)

    def iframe_run_command(self, command, timeout=10):
        # enable interactive shell
        self.click(self.locators.START_SHELL)

        # switch to main frame
        iframe = self.find(self.locators.MAIN_FRAME)
        self.driver.switch_to.frame(iframe)

        # switch to console
        console = self.find(self.locators.CONSOLE)
        self.driver.switch_to.frame(console)

        # switch to terminal
        terminal = self.find(self.locators.TERMINAL)
        self.driver.switch_to.frame(terminal)

        # wait terminal ready
        self.find(self.locators.TERMINAL_READY, timeout=timeout)

        # send command to terminal
        terminal_body = self.find(self.locators.IFRAME_BODY)
        terminal_body.send_keys(Keys.RETURN)
        terminal_body.send_keys(Keys.RETURN)
        terminal_body.send_keys(Keys.RETURN)
        terminal_body.send_keys(command + Keys.RETURN)
class MainPage(BasePage):
    locators = MainPageLocators()
    
    def authorize(self, email, password):
        self.click(self.locators.BUTTON_LOGIN)
        self.send(self.locators.FORM_EMAIL, email)
        self.send(self.locators.FORM_PASSWORD, password)
        self.send(self.locators.FORM_PASSWORD, Keys.RETURN)
Example #3
0
class LoginPage(BasePage):
    locators = MainPageLocators()

    def login(self, user, password):
        self.fill_input(self.locators.EMAIL_INPUT, user)
        self.fill_input(self.locators.PASSWORD_INPUT, password)
        self.click(self.locators.LOGIN_BUTTON)
        return
Example #4
0
class MainPage(BasePage):
    locators = MainPageLocators()

    def auth(self, login, password):
        """ Авторизация с главной страницы """
        self.click(self.locators.OPEN_LOGIN_FORM_BUTTON)
        self.send_keys(self.locators.EMAIL_FIELD, login)
        self.send_keys(self.locators.PASSWORD_FIELD, password)
        self.click(self.locators.LOGIN_BUTTON)
Example #5
0
class MainPage(BasePage):
    """ Главная страница """
    locators = MainPageLocators()

    def auth(self, login, password):
        """ Авторизация """
        self.click(self.locators.OPEN_AUTH_LINK)
        self.send_keys(self.locators.LOGIN_INPUT, login)
        self.send_keys(self.locators.PASSWORD_INPUT, password)
        self.click(self.locators.AUTH_BUTTON)

    def go_to_catalog(self):
        """ Переход к списку объявлений из категории 'Личные вещи' """
        self.click(self.locators.MORE_CATEGORIES_BUTTON)
        self.click(self.locators.PERSONAL_CATALOG_BUTTON)

        return CatalogPage(self.driver)
class MainPage(BasePage):
    locators = MainPageLocators()

    def go_to_registration(self):
        self.click(self.locators.REGISTRATION)
        return RegistrationPage(self.driver, self.config)

    def login(self, username, password):
        self.find(self.locators.USERNAME_FIELD).send_keys(username)
        self.find(self.locators.PASSWORD_FIELD).send_keys(password)
        self.click(self.locators.SUBMIT)

        try:
            welcome_locators = WelcomeLocators()
            self.find(welcome_locators.LOGOUT, 1)
            return WelcomePage(self.driver, self.config)
        except TimeoutException:
            return self
Example #7
0
class MainPage(BasePage):
    locators = MainPageLocators()

    def create_campaign(self, site_name, campaign_name):
        try:
            self.click(self.locators.CREATE_FIRST_CAMPAIGN_HREF)
        except TimeoutException:
            self.click(self.locators.CREATE_NOT_FIRST_CAMPAIGN_HREF)
        self.click(self.locators.TRAFIC_BUTTON)
        self.send(self.locators.SITE_NAME_FIELD, site_name)
        self.send(self.locators.CAMPAIGN_NAME_FIELD, campaign_name)
        self.click(self.locators.BANNER_OPTION)
        self.click(self.locators.DOWNLOAD_IMAGE_BUTTON)

        form = self.find(self.locators.DOWNLOAD_IMAGE_INPUT)
        form.send_keys(os.path.realpath((os.path.join(os.path.dirname(__file__), '..', '..', 'images', 'image.jpg'))))

        self.click(self.locators.SAVE_IMAGE)
        self.click(self.locators.SUBMIT_BUTTON)

    def create_segment(self, name):
        self.click(self.locators.GO_TO_SEGMENTS)
        try:
            self.click(self.locators.CREATE_FIRST_SEGMENT_HREF)
        except TimeoutException:
            self.click(self.locators.CREATE_NOT_FIRST_SEGMENT_HREF)

        segment_name = self.find(self.locators.SEGMENT_NAME)
        segment_name.clear()
        self.send(self.locators.SEGMENT_NAME, name)

        self.click(self.locators.ADD_SEGMENT)
        self.click(self.locators.OK_MY_MIR)
        self.click(self.locators.CHECKBOX)
        self.click(self.locators.ADD_SEGMENT_SUBMIT)
        self.click(self.locators.CREATE_SEGMENT_SUBMIT)
        self.find((By.XPATH, self.locators.CREATED_SEGMENT.format(name)))

    def delete_segment(self, name):
        self.click(self.locators.GO_TO_SEGMENTS)
        self.click((By.XPATH, self.locators.CREATED_SEGMENT_DELETE_BUTTON.format(name)))
        self.click(self.locators.DELETE_CONFIRM_BUTTON)
        self.click(self.locators.GO_TO_SEGMENTS)
Example #8
0
class MainPage(BasePage):
    locators = MainPageLocators()

    def go_to_campaigns(self):
        self.click(self.locators.ENTER_TO_CABINET)
        return CampaignsPage(self.driver)

    def go_to_login(self):
        self.click(self.locators.ENTER_TO_CABINET)
        return LoginPage(self.driver)

    def send_login_password(self, login, password):
        self.click(self.locators.AUTHORIZATION, timeout=12)
        self.find(self.locators.LOGIN_FRAME)
        self.find(self.locators.LOGIN_INPUT).send_keys(login)
        self.find(self.locators.PASSWORD_INPUT).send_keys(password)

    def get_campaigns_page(self, login, password):
        self.send_login_password(login, password)
        return self.go_to_campaigns()
Example #9
0
class MainPage(BasePage):
    locators = MainPageLocators()
Example #10
0
class MainPage(BasePage):
    locators = MainPageLocators()

    def go_to_home(self):
        self.click(self.locators.HOME_HREF)

    def go_to_python(self):
        self.click(self.locators.PYTHON_HREF)

    def go_to_wikipedia_history(self, ac):
        element = self.find(self.locators.PYTHON_HREF)
        ac.move_to_element(element).perform()
        self.click(self.locators.WIKIPEDIA_HISTORY_HREF)

    def go_to_flask(self, ac):
        windows_before = self.find_click_switch(find_locator=self.locators.PYTHON_HREF,
                                                click_locator=self.locators.FLASK_HREF,
                                                ac=ac)
        return windows_before

    def go_to_centos(self, ac):
        windows_before = self.find_click_switch(find_locator=self.locators.LINUX_LI,
                                                click_locator=self.locators.CENTOS_DOWNLOAD_HREF,
                                                ac=ac)
        return windows_before

    def go_to_wireshark_news(self, ac):
        windows_before = self.find_click_switch(find_locator=self.locators.NETWORK_LI,
                                                click_locator=self.locators.WIRESHARK_NEWS_HREF,
                                                ac=ac)
        return windows_before

    def go_to_wireshark_download(self, ac):
        windows_before = self.find_click_switch(find_locator=self.locators.NETWORK_LI,
                                                click_locator=self.locators.WIRESHARK_DOWNLOAD_HREF,
                                                ac=ac)
        return windows_before

    def go_to_tcp_dump_examples(self, ac):
        windows_before = self.find_click_switch(find_locator=self.locators.NETWORK_LI,
                                                click_locator=self.locators.TCP_DUMP_EXAMPLES,
                                                ac=ac)
        return windows_before

    def go_to_wikipedia_api(self, ac):
        windows_before = self.find_click_switch(find_locator=self.locators.WIKIPEDIA_API_HREF,
                                                click_locator=self.locators.WIKIPEDIA_API_HREF,
                                                ac=ac)
        return windows_before

    def go_to_popular_mechanic(self, ac):
        windows_before = self.find_click_switch(find_locator=self.locators.POPULAR_MECHANIC_HREF,
                                                click_locator=self.locators.POPULAR_MECHANIC_HREF,
                                                ac=ac)
        return windows_before

    def go_to_wikipedia_smtp(self, ac):
        windows_before = self.find_click_switch(find_locator=self.locators.WIKIPEDIA_SMTP_HREF,
                                                click_locator=self.locators.WIKIPEDIA_SMTP_HREF,
                                                ac=ac)
        return windows_before

    def find_click_switch(self, find_locator, click_locator, ac):
        element = self.find(find_locator)
        ac.move_to_element(element).perform()
        self.click(click_locator)
        self.wait_number_of_windows(number_win=2)
        windows_before = self.driver.current_window_handle
        windows_after = self.driver.window_handles
        new_window = [x for x in windows_after if x != windows_before][0]
        self.driver.switch_to.window(new_window)
        return windows_before

    def go_back(self, before_win):
        self.driver.close()
        self.driver.switch_to.window(before_win)