예제 #1
0
 def test01(self):
     #滑屏
     sleep(5)
     self.a.swipe(700, 500, 100, 500, 1000)
     self.a.swipe(700, 500, 100, 500, 1000)
     self.a.swipe(700, 500, 100, 500, 1000)
     self.a.swipe(700, 500, 100, 500, 1000)
     self.a.swipe(800, 500, 100, 500, 1000)
     sleep(3)
     self.a.swipe(800, 500, 100, 500, 1000)
     sleep(3)
     self.a.find_element_by_class_name('android.widget.Button').click()
     sleep(5)
    #登陆用户名
     Login().LoginStart().send_keys('zhangkairui1')
     #登陆密码
     sleep(2)
     Login().LoginPasswd().send_keys('123456')
     #点击登陆
     sleep(2)
     Login().LoginOver().click()
     # 首页
     sleep(2)
     #点击学习
     HomePage().Study().click()
     sleep(2)
     #确认按钮
     HomePage().Sure().click()
     #学习页面
     sleep(5)
     StudyPage().SelectClass().click()
     sleep(6)
     StudyPage().SelectClassHour().click()
     sleep(5)
     self.a.swipe(500, 1000, 500, 100, 1000)
     # self.a.swipe(500, 1000, 500, 100, 1000)
     sleep(2)
     self.a.tap([(114,1633)])
     sleep(10)
     self.a.tap([(114,1633)])
     sleep(2)
     #返回首页
     Bake().Bake().click()
     sleep(2)
     Bake().Bake().click()
     sleep(3)
     self.a.find_element_by_id('com.ihimee.bwqs:id/main_tab_settings').click()
     a=self.a.find_element_by_id('com.ihimee.bwqs:id/user_name').text
     b='张凯瑞zhangkairui'
     self.assertEqual(b,a,msg='登陆成功')
예제 #2
0
    def test_can_user_make_purchase(self, username, password):
        home_page = HomePage(self.driver)

        home_page.visit_login_page()
        login_page = LoginPage(self.driver)
        login_page.login(username, password)
        home_page = HomePage(self.driver)
        home_page.search_item('2017 Rollerblade Hombre')
        search_page = SearchPage(self.driver)
        search_page.select_rollerblade()
        item_page = ItemPage(self.driver)
        item_page.add_item_to_cart()
        checkout_page = CheckoutPage(self.driver)
        checkout_page.insert_address_information("Av. Buenos Aires #809",
                                                 "Res. Las Palmas",
                                                 "Santo Domingo",
                                                 "Distrito Nacional", "10011",
                                                 "8095942092")
class TestLoginDDT(PUnittest):

    driver = ENGINE.get_driver()
    homePage = HomePage(driver)
    navigateBar = NavigateBar(driver)
    loginPage = LoginPage(driver)
    login_test_data = ParseTestData().get_test_data('login')

    @classmethod
    def setUpClass(cls):
        pass

    @classmethod
    def tearDownClass(cls):
        pass

    def setUp(self):
        logger.info(' {0} >> {1} '.format(self.__class__.__name__,
                                          self._testMethodName).center(
                                              100, '*'))
        self.homePage.browser.navigate_to('https://www.utest.com/')
        self.homePage.sign_in_button().click()

    def tearDown(self):
        logger.info('*' * 100 + '\n')

    @ddt.data(*login_test_data)
    @ddt.unpack
    def test_login(self, condition, username, password):
        login_status, check_result = self.loginPage.LoginWebsite(
            username, password)
        self.assertTrue(check_result)
        if 'success' in condition:
            self.assertTrue(login_status)
            self.homePage.Logout()
        elif 'fail' in condition:
            self.assertFalse(login_status)
        self.homePage.key_actions.send_specific_keys('numlock')
        self.homePage.mouse_actions.double_click(
            self.homePage.sign_in_button())
    def test_present_all_elements(self):
        route_url = '/about/gettingstarted/'
        self.add_rout_in_url_and_go_to_url(route_url)
        getting_started_page = GettingStarted()
        base_page = BasePage()

        elements_on_getting_started_page_locators = getting_started_page.getting_started_element_list
        HomePage().check_element_on_page(
            elements_on_getting_started_page_locators)
        '''Go to the iframe'''
        iframe_widget = IframeWidget()
        '''Locators in tweets widget'''
        psd_link = iframe_widget.the_psf_link_locator
        button_load_more_tweets = iframe_widget.button_load_more_tweets_locator

        tweets_locator = iframe_widget.tweet_locator
        '''Get list with the tweets'''
        tweets = base_page.get_list_elements(tweets_locator)
        len_tweets = len(tweets)
        print('\n---------len list--------\n' + str(len_tweets))

        base_page.scroll_into_view(button_load_more_tweets)
        base_page.push(button_load_more_tweets)
        '''Get list with the tweets after click in load more tweet button'''
        tweets_after = base_page.get_list_elements(tweets_locator)  #
        len_tweets_after_click = len(tweets_after)
        print('\n-----len after click list------\n' +
              str(len_tweets_after_click))

        assert len_tweets < len_tweets_after_click, \
            '''Check the len two list'''

        base_page.push(psd_link)
        current_url = base_page.get_current_url()
        expect_url = 'https://twitter.com'
        assert (expect_url in current_url) is False, \
            '''Check on conformity expected url and current url'''
예제 #5
0
def homepage(browser):
    return HomePage(browser)
예제 #6
0
 def __init__(self):
     self.page = HomePage()
예제 #7
0
class HomeSteps:
    def __init__(self):
        self.page = HomePage()

    def navigate_to_item1(self):
        self.page.click(self.page.CONTENT_ITEM1)

    def navigate_to_item2(self):
        self.page.click(self.page.CONTENT_ITEM2)

    def navigate_to_item3(self):
        self.page.click(self.page.CONTENT_SLIDER)

    def click_more_to_item(self, item_no):
        element = self.page.find_elements(
            self.page.FEATURED_ITEM_MORE_BTNs)[item_no]
        print(element)
        self.page.click_javascript_with_element(element)

    def close_page(self):
        self.page.close_current_page()

    def restart_pages(self):
        self.page.restart_webdriver()
예제 #8
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from Src.Engine import ENGINE
from Page.BasePage import BasePage
from Page.HomePage import HomePage
from Page.NavigateBar import NavigateBar
from Utils.ParseTestData import ParseTestData

driver = ENGINE.get_driver()
homePage = HomePage(driver)
navigateBar = NavigateBar(driver)

login_success_data = ParseTestData().get_test_data('login_success')
login_success_username = login_success_data[0][
    1] if login_success_data else '*****@*****.**'
login_success_password = login_success_data[0][
    2] if login_success_data else 'Python3.6!'


class LoginPage(BasePage):
    def username_textbox(self, get_locator=False):
        return self._define_element(get_locator=get_locator)

    def username_empty_prompt(self, get_locator=False):
        return self._define_element(get_locator=get_locator)

    def password_textbox(self, get_locator=False):
        return self._define_element(get_locator=get_locator)

    def password_empty_prompt(self, get_locator=False):
예제 #9
0
 def get_HomePage(self):
     """返回首页实例化对象"""
     return HomePage(self.driver)
예제 #10
0
 def test_login_with_valid_credentials(self,Username,Password,LoginName):
    LoginPage.login(self,Username,Password)
    self.assertEqual(LoginName,HomePage.get_login_name(self))
    print(HomePage.get_login_name(self))
    def test_present_elements(self):
        """Test present all element on home page"""

        home_page = HomePage()
        base_page = BasePage()
        '''Lists with locator'''
        header_element_list_locators = base_page.header_element_list
        main_nav_bar_list_elements_locator = MainNavigationMenu.main_nav_bar_list_elements
        launch_interactive_shell_list_locator = home_page.launch_interactive_shell_list
        first_part_widgets_list_locator = home_page.first_part_widget_list
        second_part_widget_list_locator = home_page.second_part_widget_list
        third_part_widget_list_locator = home_page.third_part_widget_list
        fourth_part_widget_list_locator = home_page.fourth_part_widget_list
        navigation_menu_in_footer_list_locator = base_page.navigation_menu_in_footer_list
        lower_part_of_footer_list_locator = base_page.lower_part_of_footer_list
        '''check present widget in home page'''
        home_page.check_element_on_page(header_element_list_locators)

        home_page.check_element_on_page(main_nav_bar_list_elements_locator)
        home_page.check_element_on_page(launch_interactive_shell_list_locator)
        home_page.check_element_on_page(first_part_widgets_list_locator)
        home_page.check_element_on_page(second_part_widget_list_locator)
        home_page.check_element_on_page(third_part_widget_list_locator)
        home_page.check_element_on_page(fourth_part_widget_list_locator)
        home_page.check_element_on_page(navigation_menu_in_footer_list_locator)
        home_page.check_element_on_page(lower_part_of_footer_list_locator)
예제 #12
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from Page.NavigateBar import NavigateBar
from Page.HomePage import HomePage
from Utils.Paths import CHROME_DRIVER_PATH
from selenium import webdriver
import time

# 初始化driver,初始化各个页面类
driver = webdriver.Chrome(CHROME_DRIVER_PATH)
homePage = HomePage(driver)
navigateBar = NavigateBar(driver)

# 前往网站
homePage.browser.navigate_to('https://www.utest.com/articles')

# 检测左侧导航栏是否可见,如果不可见点击展开按钮将其展开
navigate_bar_visible = navigateBar.navigate_bar().is_displayed()
if not navigate_bar_visible:
    homePage.expand_navigate_button().click()

# 点击导航栏分页面按钮并验证分页面的显示是否正确
navigateBar.articles_button().click()
time.sleep(2)
title_label_text = homePage.title_label().get_text()
assert title_label_text == 'Software Testing Articles'

# 再依次操作其余4个按钮
navigate_bar_visible = navigateBar.navigate_bar().is_displayed()
if not navigate_bar_visible:
예제 #13
0
    def test_logo(self):
        base_page = BasePage()
        logo_locator = base_page.logo_image_link
        main_dropdown = MainNavigationMenu()

        about_in_main_menu_locator = main_dropdown.tab_about_tob_bar
        download_in_main_menu_locator = main_dropdown.tab_downloads_tob_bar
        documentation_in_main_menu_locator = main_dropdown.tab_documentation_tob_bar
        community_in_main_menu_locator = main_dropdown.tab_community_tob_bar
        success_stories_in_main_menu_locator = main_dropdown.tab_success_stories_tob_bar
        news_in_main_menu_locator = main_dropdown.tab_news_tob_bar
        events_in_main_menu_locator = main_dropdown.tab_events_tob_bar
        '''-----------------------------------------------------------------------------------'''

        base_page.push(about_in_main_menu_locator)
        assert base_page.is_element_present(logo_locator) is False, \
            '''Check present logo on the page after click in the item About'''
        base_page.push(logo_locator)

        home_page = HomePage()
        launch_shel_locator = home_page.launch_interactive_shell

        assert base_page.is_element_present(launch_shel_locator) is False, \
            '''After click on the logo, check is it the button Lounch Interactiv shell'''
        '''-----------------------------------------------------------------------------------'''

        base_page.push(download_in_main_menu_locator)
        assert base_page.is_element_present(logo_locator) is False, \
            '''Check present logo on the page after click in the item Downloads'''
        base_page.push(logo_locator)

        home_page = HomePage()
        launch_shel_locator = home_page.launch_interactive_shell

        assert base_page.is_element_present(launch_shel_locator) is False, \
            '''After click on the logo, check is it the button Lounch Interactiv shell'''
        '''-----------------------------------------------------------------------------------'''

        base_page.push(documentation_in_main_menu_locator)
        assert base_page.is_element_present(logo_locator) is False, \
            '''After click on the logo, check present logo on the page after click in the item Documentation'''
        base_page.push(logo_locator)

        home_page = HomePage()
        launch_shel_locator = home_page.launch_interactive_shell

        assert base_page.is_element_present(launch_shel_locator) is False, \
            '''Check is it the button Lounch Interactiv shell'''
        '''-----------------------------------------------------------------------------------'''

        base_page.push(community_in_main_menu_locator)
        assert base_page.is_element_present(logo_locator) is False, \
            '''After click on the logo, check present logo on the page after click in the item Community'''
        base_page.push(logo_locator)

        home_page = HomePage()
        launch_shel_locator = home_page.launch_interactive_shell

        assert base_page.is_element_present(launch_shel_locator) is False, \
            '''Check is it the button Lounch Interactiv shell'''
        '''-----------------------------------------------------------------------------------'''

        base_page.push(success_stories_in_main_menu_locator)
        assert base_page.is_element_present(logo_locator) is False, \
            '''After click on the logo, check present logo on the page after click in the item Success Stories'''
        base_page.push(logo_locator)

        home_page = HomePage()
        launch_shel_locator = home_page.launch_interactive_shell

        assert base_page.is_element_present(launch_shel_locator) is False, \
            '''Check is it the button Lounch Interactiv shell'''
        '''-----------------------------------------------------------------------------------'''

        base_page.push(news_in_main_menu_locator)
        assert base_page.is_element_present(logo_locator) is False, \
            '''After click on the logo, check present logo on the page after click in the item News'''
        base_page.push(logo_locator)

        home_page = HomePage()
        launch_shel_locator = home_page.launch_interactive_shell

        assert base_page.is_element_present(launch_shel_locator) is False, \
            '''Check is it the button Lounch Interactiv shell'''
        '''-----------------------------------------------------------------------------------'''

        base_page.push(events_in_main_menu_locator)
        assert base_page.is_element_present(logo_locator) is False, \
            '''After click on the logo, check present logo on the page after click in the item Events'''
        base_page.push(logo_locator)

        home_page = HomePage()
        launch_shel_locator = home_page.launch_interactive_shell

        assert base_page.is_element_present(launch_shel_locator) is False, \
            '''Check is it the button Lounch Interactiv shell'''

        path_into_screenshot = "C:/My/Projects/Pyscreen/"
        name_screen = "test"

        base_page.make_screenshot(path_into_screenshot, name_screen)
class TestSubPageTitle(PUnittest):

    driver = ENGINE.get_driver()
    homePage = HomePage(driver)
    navigateBar = NavigateBar(driver)

    @classmethod
    def setUpClass(cls):
        cls.homePage.browser.navigate_to('https://www.utest.com/')

    @classmethod
    def tearDownClass(cls):
        pass

    def setUp(self):
        logger.info(' {0} >> {1} '.format(self.__class__.__name__,
                                          self._testMethodName).center(
                                              100, '*'))

    def tearDown(self):
        logger.info('*' * 100 + '\n')

    def test_articles_title(self):
        navigate_bar_visible = self.navigateBar.navigate_bar().is_displayed()
        if not navigate_bar_visible:
            self.homePage.expand_navigate_button().click()
        self.navigateBar.articles_button().click()
        time.sleep(2)
        title_label_text = self.homePage.title_label().get_text()
        self.assertEqual(title_label_text, 'Software Testing Articles')

    def test_training_title(self):
        navigate_bar_visible = self.navigateBar.navigate_bar().is_displayed()
        if not navigate_bar_visible:
            self.homePage.expand_navigate_button().click()
        self.navigateBar.training_button().click()
        time.sleep(2)
        title_label_text = self.homePage.title_label().get_text()
        self.assertEqual(title_label_text, 'Software Testing Courses')

    def test_forums_title(self):
        navigate_bar_visible = self.navigateBar.navigate_bar().is_displayed()
        if not navigate_bar_visible:
            self.homePage.expand_navigate_button().click()
        self.navigateBar.forums_button().click()
        time.sleep(2)
        title_label_text = self.homePage.title_label().get_text()
        self.assertEqual(title_label_text, 'xxxxxxxxxxxxxxxx')

    def test_tools_title(self):
        navigate_bar_visible = self.navigateBar.navigate_bar().is_displayed()
        if not navigate_bar_visible:
            self.homePage.expand_navigate_button().click()
        self.navigateBar.tools_button().click()
        time.sleep(2)
        title_label_text = self.homePage.title_label().get_text()
        self.assertEqual(title_label_text, 'Software Testing Tool Reviews')

    def test_projects_title(self):
        navigate_bar_visible = self.navigateBar.navigate_bar().is_displayed()
        if not navigate_bar_visible:
            self.homePage.expand_navigate_button().click()
        self.navigateBar.projects_button().click()
        time.sleep(2)
        title_label_text = self.homePage.title_label().get_text()
        self.assertEqual(title_label_text, 'xxxxxxxxxxxxxxxxxxx')
예제 #15
0
 def goto_home(self):
     logging.info("Go to homepage %s" % self.HOMEPAGE)
     self.driver.get(self.get_host_url())
     return HomePage()