Esempio n. 1
0
class MainGooglePage:
    _button_enter = [By.ID, "gb_70"]
    _email_input = [By.ID, "identifierId"]
    _password_input = [By.XPATH, "//input[@type='password']"]
    _next_button = [By.ID, "identifierNext"]
    _next_button_password = [By.ID, "passwordNext"]
    _mail_button = [By.XPATH, "//a[text()='Почта']"]

    def __init__(self, driver, path_before_config):
        self.file_config = Config(path_before_config)
        self._delay = self.file_config.get("wait_in_second")
        self._driver = driver

    def click_enter_button(self):
        self._driver.find_element(*self._button_enter).click()

    def click_next_button(self):
        self._driver.find_element(*self._next_button).click()

    def click_next_button_password(self):
        self._driver.find_element(*self._next_button_password).click()

    def edit_email_input(self):
        input_text = self.file_config.get("email")
        self._driver.find_element(*self._email_input).send_keys(input_text)

    def edit_password_input(self):
        input_text = self.file_config.get("password")
        time.sleep(
            5
        )  # загрузка скрытого поля пароля, не стал придумывать для него ожидние
        self._driver.find_element(*self._password_input).send_keys(input_text)

    def click_mail_button(self):
        self._driver.find_element(*self._mail_button).click()
Esempio n. 2
0
    def setup_teardown(self, request, driver_transfer, path_before_config):
        driver_transfer.start()
        file_config = Config(path_before_config)
        delay = file_config.get("wait_in_second")
        driver_transfer.instance.implicitly_wait(delay)
        driver_transfer.instance.maximize_window()

        request.addfinalizer(driver_transfer.stop)
Esempio n. 3
0
class UsingApi:
    def __init__(self, path_before_config):
        self.file_config = Config(path_before_config)
        self.text_mail = 'Text_mail_for_check_{}'.format(
            datetime.now().strftime('%d%m%Y%H%M%S'))

    def send_email_api_method(self):
        smtp_obj = smtplib.SMTP('smtp.gmail.com', 587)
        smtp_obj.starttls()
        name_email = self.file_config.get("email")
        password_mail = self.file_config.get("password")
        smtp_obj.login(name_email, password_mail)
        smtp_obj.sendmail(name_email, name_email, self.text_mail)
        smtp_obj.quit()
Esempio n. 4
0
    def test_check_translate(self, driver_transfer, path_before_config):
        file_config = Config(path_before_config)
        url = file_config.get("url")

        driver_transfer.instance.get(url)
        main_yandex_page = MainYandexPage(driver_transfer.instance,
                                          path_before_config)
        assert main_yandex_page.check_download_page()
        main_yandex_page.click_tab_translate()

        text_for_translate = "текст для перевода"
        text_for_check_translate = "text for translation"
        delay = file_config.get("wait_in_second")
        translation_page = TranslatePage(driver_transfer.instance, delay)
        assert translation_page.check_download_page()
        translation_page.click_change_direction_translate_button()
        assert translation_page.verification_of_translation(
            text_for_translate, text_for_check_translate)
Esempio n. 5
0
 def test_send_mail_in_gmail(self, driver_transfer, path_before_config):
     with allure.step('Step 1: send mail from api'):
         file_config = Config(path_before_config)
         api_methods = UsingApi(path_before_config)
         api_methods.send_email_api_method()
     with allure.step('Step 2: go to google homepage'):
         url = file_config.get("url")
         driver_transfer.instance.get(url)
     with allure.step('Step 3: click to enter button'):
         main_google_page = MainGooglePage(driver_transfer.instance,
                                           path_before_config)
         main_google_page.click_enter_button()
     with allure.step('Step 4: login in account'):
         main_google_page.edit_email_input()
         main_google_page.click_next_button()
         main_google_page.edit_password_input()
         main_google_page.click_next_button_password()
     with allure.step('Step 5: click mail button'):
         main_google_page.click_mail_button()
     with allure.step('Step 6: checking that the email has arrived'):
         mail_page = MailPage(driver_transfer.instance, path_before_config,
                              api_methods.text_mail)
         assert mail_page.checking_that_the_email_has_arrived()
Esempio n. 6
0
class MailPage:
    _first_element_in_mail = (By.XPATH, '//table[@role="grid"]//tbody//tr[1]')

    def __init__(self, driver, path_before_config, text_letter):
        self.file_config = Config(path_before_config)
        self._delay = int(self.file_config.get("wait_in_second"))
        self._driver = driver
        self.text_of_letter = text_letter
        self.wait_download_page()

    def wait_download_page(self):
        WebDriverWait(self._driver, self._delay).until(
            expected_conditions.presence_of_element_located(self._first_element_in_mail))

    def checking_that_the_email_has_arrived(self):
        try:
            xpath_element = '//span[text()="{}"]'.format(self.text_of_letter)
            mail_text_element = [By.XPATH, xpath_element]
            element = self._driver.find_element(*mail_text_element)
        except NoSuchElementException:
            return False
        return True
Esempio n. 7
0
 def __init__(self, path_before_config):
     self.file_config = Config(path_before_config)
     self.text_mail = 'Text_mail_for_check_{}'.format(
         datetime.now().strftime('%d%m%Y%H%M%S'))
Esempio n. 8
0
 def __init__(self, driver, path_before_config):
     self.file_config = Config(path_before_config)
     self._delay = self.file_config.get("wait_in_second")
     self._driver = driver
 def __init__(self, driver, path_before_config):
     file_config = Config(path_before_config)
     self._text_for_check_download = file_config.get(
         "text_for_check_download_start_page")
     self._delay = file_config.get("wait_in_second")
     self._driver = driver
Esempio n. 10
0
 def __init__(self, driver, path_before_config, text_letter):
     self.file_config = Config(path_before_config)
     self._delay = int(self.file_config.get("wait_in_second"))
     self._driver = driver
     self.text_of_letter = text_letter
     self.wait_download_page()