示例#1
0
class TestPhpTravelPage:
    @pytest.fixture(scope='function', autouse=True)
    def app_setup(self):

        self.webdriver = webdriver.Chrome()
        self.home_page = HomePage(self.webdriver)
        self.login_page = Login(self.webdriver)
        self.landing_page_hotel = LandingPageHotel(self.webdriver)
        self.valid_credentials = conf_reader.get_user_credentials()
        self.search_result_page = SearchResultPage(self.webdriver)

        yield
        self.webdriver.quit()

    @pytest.fixture(scope='function')
    def valid_login(self):
        """
        A fixture method to execute the common steps till performing login
        :return:
        """
        self.home_page.open_webpage()
        self.home_page.open_login_page()
        self.login_page.user_login(self.valid_credentials.email,
                                   self.valid_credentials.password)

    def test_home_page_pvt(self):
        self.home_page.open_webpage()
        self.home_page.implicitly_wait(10)
        assert self.home_page.is_loaded(self.home_page.key_locators)

    def test_landing_page_pvt(self, valid_login):
        assert self.landing_page_hotel.is_loaded(
            self.landing_page_hotel.key_locators)
示例#2
0
 def setUpClass(cls):
     cls.driver = webdriver.Firefox()
     cls.driver.get(login_url)
     #先登录
     a = Login(cls.driver)  #起始位置
     a.login()
     cls.student = AddStudentInfo(cls.driver)
     cls.student.gengduo()
示例#3
0
 def setUp(self):
     global driver, check, user
     browser = Browsers(browserType)
     driver = webdriver.Chrome(browser.select_browser())
     #登录
     user = Login(driver)
     user.login(address, account, password)
     check = AssertFunction()
     self.assertTrue(check.isElementExist(driver, e_personalDetails))
     self.assertIn('homepage', driver.current_url)
class TestAuthentication:
    @pytest.fixture(scope='function', autouse=True)
    def setup(self):
        """
        This fixture holds the common setup steps required to Login to the application
        returns: Home page of the application for authenticated users
        """
        self.webdriver = webdriver.Chrome()
        self.base_page = BasePage(self.webdriver)
        self.home_page = HomePage(self.webdriver)
        self.login_page = Login(self.webdriver)
        self.search_result_page = SearchResultPage(self.webdriver)
        self.valid_credentials = conf_reader.get_user_credentials()
        self.landing_page_hotel = LandingPageHotel(self.webdriver)
        self.home_page.open_login_page()

        yield
        self.webdriver.quit()

    def test_valid_user_login(self):
        """
        This method enters the correct credentials for a user in the application and
        :returns: Homepage of application after successful login.

        We verify this by asserting the presence of User's Image icon

        """

        self.login_page.user_login(self.valid_credentials.email,
                                   self.valid_credentials.password)

        assert self.landing_page_hotel.is_loaded(
            self.landing_page_hotel.key_locators)

    @pytest.mark.parametrize("user_name, password",
                             [('*****@*****.**', '********'),
                              ('*****@*****.**', 'demouser'),
                              ('', ''), ('*****@*****.**', '        ')])
    def test_invalid_login_scenarios(self, user_name, password):
        """
        Test- 1
        This test checks for all the invalid username/email and password combination by taking param
        from above
            Case 1 : Valid username and invalid password
            Case 2 : Invalid username and valid password
            Case 3 : Blank Username and Password
            Case 4 : Valid Username and Spaces as password

        returns: An error message indicating incorrect credentials
        """

        self.login_page.user_login_failed(user_name, password)
        assert self.login_page.get_error_message_from_alert(
        ) == "Invalid Email or Password"
示例#5
0
    def app_setup(self):

        self.webdriver = webdriver.Chrome()
        self.home_page = HomePage(self.webdriver)
        self.login_page = Login(self.webdriver)
        self.landing_page_hotel = LandingPageHotel(self.webdriver)
        self.valid_credentials = conf_reader.get_user_credentials()
        self.search_result_page = SearchResultPage(self.webdriver)

        yield
        self.webdriver.quit()
示例#6
0
class TestTours:
    @pytest.fixture(scope='function', autouse=True)
    def setup(self):
        """Tours
        This fixture holds the common setup steps required to Login to the application
        returns: Home page of the application for authenticated users
        """
        self.webdriver = webdriver.Chrome()
        self.home_page = HomePage(self.webdriver)
        self.login_page = Login(self.webdriver)
        self.search_result_page = SearchResultPage(self.webdriver)
        self.valid_credentials = conf_reader.get_user_credentials()
        self.landing_page_tours = LandingPageTour(self.webdriver)
        self.home_page.open_login_page()
        self.login_page.user_login(self.valid_credentials.email,
                                   self.valid_credentials.password)
        self.landing_page_tours.click_tour_button()

        yield
        self.webdriver.quit()

    def test_error_handling_for_garbage_values_in_tours_field(self):
        """
        Test- 7:
        Action : User tries to search a tour by giving garbage input in searchbox
        Returns: An error is displayed
        Asserted : That the correct error message is displayed

        """
        invalid_str = 'asdasdfadfaf'
        time.sleep(5)
        self.landing_page_tours.enter_garbage_value_to_tour_field(invalid_str)

        assert self.webdriver.find_element(By.XPATH, self.landing_page_tours._err_srch_box_tours) \
                   .text == 'No matches found'

    def test_error_thrown_on_exceeding_max_adult_tourists(self):
        """
        Test- 8
        Action: User searches with valid guests , and then makes the change in the URL
        return: There should be an error displayed for exceeding max guests
        Asserted: The correct error message is displayed
        """
        error_message = 'Maximum Number of Adults exceeded for this tour'
        self.webdriver.get(
            "https://www.phptravels.net/tours/united-arab-emirates/dubai/Sheraton"
            "-Trip?date=10/08/2019&adults=7")

        error_text = self.webdriver.find_element(
            By.XPATH, self.landing_page_tours._err_max_tourists_exceeded).text
        error_text = str(error_text).lstrip().rstrip()

        assert error_text == error_message
    def setup(self):
        """
        This fixture holds the common setup steps required to Login to the application
        returns: Home page of the application for authenticated users
        """
        self.webdriver = webdriver.Chrome()
        self.base_page = BasePage(self.webdriver)
        self.home_page = HomePage(self.webdriver)
        self.login_page = Login(self.webdriver)
        self.search_result_page = SearchResultPage(self.webdriver)
        self.valid_credentials = conf_reader.get_user_credentials()
        self.landing_page_hotel = LandingPageHotel(self.webdriver)
        self.home_page.open_login_page()

        yield
        self.webdriver.quit()
示例#8
0
    def setup(self):
        """Tours
        This fixture holds the common setup steps required to Login to the application
        returns: Home page of the application for authenticated users
        """
        self.webdriver = webdriver.Chrome()
        self.home_page = HomePage(self.webdriver)
        self.login_page = Login(self.webdriver)
        self.search_result_page = SearchResultPage(self.webdriver)
        self.valid_credentials = conf_reader.get_user_credentials()
        self.landing_page_tours = LandingPageTour(self.webdriver)
        self.home_page.open_login_page()
        self.login_page.user_login(self.valid_credentials.email,
                                   self.valid_credentials.password)
        self.landing_page_tours.click_tour_button()

        yield
        self.webdriver.quit()
示例#9
0
 def login_1(self,username,passwd,expect):
     '''登录成功'''
     self.zentaologin.input_username(username)
     self.zentaologin.input_passwd(passwd)
     self.zentaologin.keep_loginon()
     self.zentaologin.click_login()
     time.sleep(3)
     user_name = Login.get_login_username(self)
     self.assertTrue(user_name == expect)
示例#10
0
class TestLogin(unittest.TestCase):
    """测试注册/登录功能"""
    def setUp(self):
        self.driver = webdriver.Firefox()
        self.driver.get(login_url)
        self.a = Login(self.driver)

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

    @ddt.data(*test_datas)
    def test_login(self, data):
        """测试数据-成功 testvera1,123456"""
        print("测试数据:%s" % data)

        self.a.login(data["user"], data["psw"])
        result = self.a.is_login_success("登录成功")
        print("登录的实际结果: %s" % result)
        self.assertTrue(result == data["expect"])
示例#11
0
 def setUp(self):
     global driver, check, sip, group, user
     browser = Browsers(browserType)
     driver = webdriver.Chrome(browser.select_browser())
     #登录
     user = Login(driver)
     user.login(address, account, password)
     check = AssertFunction()
     self.assertTrue(check.isElementExist(driver, e_personalDetails))
     self.assertIn('homepage', driver.current_url)
     #添加线路
     sip = SipPage(driver)
     sip.into_sip()
     #添加线路
     sip.add_sip(sipAccount, sipPassword, sipIp, sipPort, city)
     #断言
     self.assertTrue(check.isElementExist(driver, e_assertSip, sipAccount))
     #添加客户组导入号码
     group = cusManage(driver)
     group.cus_manage()
     group.add_group(groupName, number)
     self.assertTrue(check.isElementExist(driver, e_deleteGroup, groupName))
示例#12
0
 def setUp(self):
     self.driver = webdriver.Firefox()
     self.driver.get(login_url)
     self.a = Login(self.driver)
示例#13
0
 def setUpClass(cls):
     cls.driver = webdriver.Firefox()
     cls.bug = ZenTaoBug(cls.driver)
     cls.a = Login(cls.driver)
     cls.a.login()
 def test_login(self):
     obj_login = Login()
     obj_login.allow_access()
 def setUpClass(cls):
     cls.driver = webdriver.Firefox()
     cls.addbug = Addbug(cls.driver)
     cls.login = Login(cls.driver)
示例#16
0
class LoginAndLandOnAnalyze(unittest.TestCase):

    @pytest.fixture(autouse=True)
    def objectSetup(self, getDriver):
        log = cl.customLogger(logging.DEBUG)
        log.info("=" * 50)
        log.info("Login Operation")
        self.lp = Login(getDriver)

    def test_T1login_and_land_analyze(self):
        self.lp.sendUsername()
        self.lp.sendPassword()
        self.lp.clicklogIn()
        assert self.lp.verifyUser()

    def test_T2go_to_first_respondant(self):
        assert self.lp.verifyOnFirstRespondant()

    def test_T3verify_filter(self):
        assert self.lp.verifyFilter()

    def test_T4verify_delete_respondant(self):
        assert self.lp.verifyDeleteRespondant()

    def test_T5verify_export_respondant(self):
        assert self.lp.verifyExportRespondant()

    def test_T6verify_edit_respondant(self):
        assert self.lp.verifyEditRespondant()
示例#17
0
from behave import *
from selene.browser import *
from pages.login_page import Login

login_page = Login()


@given('I have opened login page')
def step_impl(context):
    open_url("/login")


@when('I login with "{username}" name and "{password}" password')
def step_impl(context, username, password):
    login_page.login(username, password)


@then('I see "{text}" text')
def step_impl(context, text):
    message = login_page.get_Message()
    assert message == text


@when('I refresh cookie')
def step_impl(context):
    driver().delete_all_cookies()
    driver().refresh()


@when(
    'I login through the http with "{username}" name and "{password}" password'
示例#18
0
 def setUpClass(cls):
     cls.driver = webdriver.Chrome()
     cls.add_free = FreeBuy(cls.driver)
     a = Login(cls.driver)
     a.login()
示例#19
0
 def objectSetup(self, getDriver):
     log = cl.customLogger(logging.DEBUG)
     log.info("=" * 50)
     log.info("Login Operation")
     self.lp = Login(getDriver)
示例#20
0
class TestHotel:
    @pytest.fixture(scope='function', autouse=True)
    def setup(self):
        """
        This fixture holds the common setup steps required to Login to the application
        returns: Home page of the application for authenticated users
        """
        self.webdriver = webdriver.Chrome()
        self.base_page = BasePage(self.webdriver)
        self.home_page = HomePage(self.webdriver)
        self.login_page = Login(self.webdriver)
        self.search_result_page = SearchResultPage(self.webdriver)
        self.valid_credentials = conf_reader.get_user_credentials()
        self.landing_page_hotel = LandingPageHotel(self.webdriver)
        self.home_page.open_login_page()
        self.login_page.user_login(self.valid_credentials.email,
                                   self.valid_credentials.password)
        self.webdriver.get("https://www.phptravels.net/m-thhotels")

        yield
        self.webdriver.quit()

    def test_user_can_not_search_with_blank_hotel_or_city_name(
            self, data_trip_with_out_hotel_name):
        """
        Test- 2
        This test ensures the mandatory details of city/hotel name are compulsorily given by users.

        This test will fail , but that indicates that user can perform search with blank hotel name

        """
        self.landing_page_hotel.search_and_select_city(
            data_trip_with_out_hotel_name.hotel_name)
        self.landing_page_hotel.select_checkin_and_checkout_dates(
            data_trip_with_out_hotel_name.check_in_date,
            data_trip_with_out_hotel_name.check_out_date)
        self.landing_page_hotel.click_search_button()

        assert not self.search_result_page.is_loaded(
            self.search_result_page.key_locators)
        """assert here should have been on The Search button is not clickable or 
        that there is an error message.
        but since that demands a different implementation, 
        My assertion is for search result page not loaded"""

    def test_checkout_date_can_not_be_prior_to_checkin_date(
            self, data_check_out_before_check_in_details):
        """
        Test- 3: Assuming that user is entering a Checkout date which is prior to checkin date
        (which is possible as per current implementation) for hotel search ,
        This test will fail to indicate that the input provided is incorrect

        """
        self.landing_page_hotel.search_and_select_city(
            data_check_out_before_check_in_details.hotel_name)
        self.landing_page_hotel.select_checkin_and_checkout_dates(
            data_check_out_before_check_in_details.check_in_date,
            data_check_out_before_check_in_details.check_out_date)

        assert data_check_out_before_check_in_details.check_in_date < data_check_out_before_check_in_details.check_out_date

    def test_number_of_guests_can_not_be_zero_or_less(self,
                                                      data_number_of_guests):
        """
        Test- 4
        The number of guests can not be zero or less and thus negative values should not be allowed
        This test will fail if User gives 0 as input for number of guests

        We are currently giving 0 as input for guests , thus this will fail
        """
        adult_guests = 0
        child_guests = 0
        self.landing_page_hotel.search_and_select_city(
            data_number_of_guests.hotel_name)
        self.landing_page_hotel.select_checkin_and_checkout_dates(
            data_number_of_guests.check_in_date,
            data_number_of_guests.check_out_date)
        self.landing_page_hotel.enter_number_of_guests(adult_guests,
                                                       child_guests)

        assert self.landing_page_hotel.get_number_of_guests() > 0

    def test_number_of_guests_can_not_exceed_five(self, setup,
                                                  data_number_of_guests):
        """
        Test- 5
        The number of guests , if more than 5 would need a bulk booking ,
        this is a scenario which is more near to real life booking by a customer.
        (Wee can define our own upper limit , idea is big numbers as 100000 should not be allowed)
        """
        adult_guests = 10
        child_guests = 0
        self.landing_page_hotel.search_and_select_city(
            data_number_of_guests.hotel_name)
        self.landing_page_hotel.select_checkin_and_checkout_dates(
            data_number_of_guests.check_in_date,
            data_number_of_guests.check_out_date)
        self.landing_page_hotel.enter_number_of_guests(adult_guests,
                                                       child_guests)

        assert self.landing_page_hotel.get_number_of_guests() <= 5

    def test_checkin_date_can_not_be_in_past(self, setup,
                                             data_number_of_guests):
        """
        Test- 6
        There can not be a hotel search for a past date. If a user is trying to make such a booking,
        This should give user an error
        """

        self.landing_page_hotel.search_and_select_city(
            data_number_of_guests.hotel_name)
        self.landing_page_hotel.select_checkin_and_checkout_dates(
            data_number_of_guests.check_in_date,
            data_number_of_guests.check_out_date)
        todays_date = date.today()
        required_format_today = todays_date.strftime("%d/%m/%Y")

        assert required_format_today > data_number_of_guests.check_in_date
        """The assert should be that the search button is not clickable, 
示例#21
0
 def setUpClass(cls):
     cls.driver = webdriver.Firefox()
     cls.zentaologin = Login(cls.driver)
示例#22
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     self.base_selenium = BaseSelenium()
     self.login_page = Login()
     self.home_page = HomePage()
示例#23
0
 def setUpClass(cls):
     cls.driver = webdriver.Chrome()
     cls.login_page = Login(cls.driver)
     cls.driver.maximize_window()
示例#24
0
 def startLogin(self):
     driver = ChromeDriver.getFromChrome(ChromeDriver)
     login = Login(driver)
     login.sendUsername()
     login.sendPassword()
     login.clicklogIn()
示例#25
0
 def tearDown(self):
     Login.is_alert(self)
     self.driver.delete_all_cookies()
     self.driver.refresh()
示例#26
0
 def test_login_jenkins(self):
     driver = self.driver
     lp = Login(driver)
     lp.enter_user_name()
     lp.enter_password()
     lp.click_signin_button()
示例#27
0
    def is_add_student_success(self, text):
        #判断text“学生名称”在列表里 包含 00:43
        #“学生名称”在当前页
        #t = self.driver.page_source #获取当前页整个html源码, 方法1
        body = ("tag name", "body") #获取当前页所有tag的名字
        t2 = self.find(body).text
        #print(t2)
        return text in t2

    def is_add_success(self,s_id):
        #第二种判断 学号,判断方法是多种多样的
        t = self.get_text(self.loc_r)
        print("获取的学号:%s" %t)
        return s_id == t #此时可以看下网页代码,如果不是纯文本,包含空格和其他时,可以用包含

if __name__ == '__main__':
    from selenium import webdriver
    driver = webdriver.Firefox()
    driver.get("http://47.104.190.48:8000/login")
    a = Login(driver)
    a.login()  #先登录
    b = AddStudentInfo(driver) #到添加学生页面
    b.gengduo()
    b.add_student("20000008", "zzzsss")

    result = b.is_add_student_success("zzzsss")
    print("结果: %s"%result)

    t3 = b.is_add_success("20000008")
    print(t3)
示例#28
0
 def setUpClass(cls):
     cls.driver = webdriver.Firefox()  #打开浏览器
     cls.zentao = ZenTaoBug(cls.driver)
     cls.l = Login(cls.driver)
     cls.l.login()  #登录