0

May I know why the program is not starting with the test 1 when it runs and it starts with test 2 more precisely with the below code?

def test_click_login_link(self)
        self.driver.find_element(self.LOGIN_LINK).click()

Here is the full code:

import unittest
from selenium.webdriver.common.by import By
from selenium import webdriver
from time import sleep
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from webdriver_manager import chrome
from selenium.webdriver import ActionChains
from selenium.webdriver.common.keys import Keys
from selenium.common import NoSuchElementException

class TEST(unittest.TestCase)
    EMAIL = (By.XPATH, input[@placeholder='Enter your email'])
    PASSWORD = (By.XPATH, input[@placeholder='Enter your password'])
    LOGIN_BUTTON = (By.XPATH, [text()='Log in'])
    PASSWORD_ERROR_MESSAGE = (By.XPATH, [text()='Please enter your password!'])
    BUTTON_DISABLED = (By.XPATH, button[@data-test-id='login-button'])
    SIGN_UP_LINK = (By.LINK_TEXT, Sign up.)
    LOGIN_LINK = (By.XPATH, [text()='Log In.'])
    PERSONAL_SELECT = (By.XPATH, (input[@type='radio'])[2])
    CONTINUE_BUTTON = (By.XPATH, [text()='CONTINUE'])
    CONTINUE_BUTTON2 = (By.XPATH, 'button[@data-test-id=first-name-continue-btn]')
    CONTINUE_BUTTON3 = (By.XPATH, 'span[contains(.,CONTINUE)]')
    FIRST_NAME = (By.XPATH, 'input[@placeholder=Type your answer here...]')
    LAST_NAME = (By.XPATH, input[@type='text'])
    EMAIL_INSERT = (By.XPATH, [@class='MuiInputBase-input MuiFilledInput-input'])
    EMAIL_MESSAGE_ERROR = (By.XPATH, p[text()='Please enter a valid email address.'])

    def setUp(self)
        self.driver = webdriver.Chrome()
        self.driver.maximize_window()
        self.driver.implicitly_wait(10)
        self.driver.get(httpsjules.appsign-in)

    def tearDown(self)
        self.driver.quit()


    # test 1
    def test_email(self)
        self.driver.find_element(self.EMAIL_INSERT).send_keys(test1@microsoft.com)
        sleep(1)

    def test_verify_email_error_msg(self)
        self.test_email()
        expected_msg = Please enter your password!
        try
            actual_msg = self.driver.find_element(self.PASSWORD_ERROR_MESSAGE).text
        except NoSuchElementException
            actual_msg = None
        assert actual_msg != expected_msg, fError! The message is not displayed{actual_msg}, and expected{expected_msg}
        sleep(3)

    def test_verify_login_button_disabled(self)
        self.test_email()
        elem_login_button = self.driver.find_element(self.BUTTON_DISABLED)
        self.assertFalse(elem_login_button.is_enabled(), Button LOGIN it is not disabled)
        sleep(3)


    # test2
    def test_click_sign_up_link(self)
        self.driver.find_element(self.SIGN_UP_LINK).click()
        sleep(5)

    def test_url_check_sign_up(self, expected_url= httpsjules.appsign-up)
        actual_url = self.driver.current_url
        self.assertEqual(actual_url, expected_url, The url is incorrect)

    def test_click_login_link(self)
        self.driver.find_element(self.LOGIN_LINK).click()

    def test_url_check_sign_in(self, expected_url= httpsjules.appsign-in)
        actual_url = self.driver.current_url
        self.assertEqual(actual_url, expected_url, The url is incorrect)

As I said earlier the code should start with test 1.

Here is what I see in Pycharm: enter image description here

MMag
  • 1

0 Answers0