예제 #1
0
 def test_add_question(self):
     print("\n" + str(test_cases(2)))
     page = HomePage(self.driver)
     res = page.add_question('How are you doing?', 'It is going great!')
     self.assertEqual(res[len(res) - 1].get_question(),
                      'How are you doing?')
     self.assertEqual(res[len(res) - 1].get_answer(), 'It is going great!')
예제 #2
0
 def test_default_question_on_home_page(self):
     print("\n" + str(test_cases(1)))
     page = HomePage(self.driver)
     _questions_list = page.get_questions_list()
     self.assertEqual(len(_questions_list), 1)
     self.assertEqual(_questions_list[0].get_question(),
                      'How to add a question?')
예제 #3
0
def main():
    config = configparser.ConfigParser()  # создаём объекта парсера
    config.read("settings.ini")  # читаем конфиг
    count_max = int(config['settings']['count'])
    password = config['settings']['password']
    username = config['settings']['username']
    delay = int(config['settings']['delay'])
    with open('list.txt', 'r', encoding='utf-8') as f:
        dic = f.readlines()

    browser = webdriver.Firefox()
    browser.implicitly_wait(delay)

    home_page = HomePage(browser)
    login_page = home_page.go_to_login_page()
    login_page.login(username, password)
    sleep(delay)
    count = 0
    for i in dic:
        browser.get(f'https://www.instagram.com/{i}/')
        soup = BeautifulSoup(browser.page_source, 'lxml')
        for link in soup.find_all('a'):
            if (link.get('href')[1] == 'p') and (link.get('href')[2] == '/'):
                linker = link.get('href')
                break
        browser.get(f'https://www.instagram.com{linker}')
        soup = BeautifulSoup(browser.page_source, 'lxml')
        assa = soup.find_all('svg')[0]
        nrav = assa.get('aria-label')
        if nrav == 'Нравится':
            btn_like = browser.find_element_by_class_name("wpO6b")
            btn_like.click()
            count = count + 1
            if count >= count_max:
                break
예제 #4
0
 def test_payment_error(self):
     '''Search for a book'''
     self.homePage = HomePage(self.driver)
     self.homePage.search()
     self.homePage.filer_books()
     self.homePage.select_book()
     '''Add the book to the cart and proceed paying'''
     self.cartPage = CartPage(self.homePage.driver)
     self.cartPage.add_book()
     self.cartPage.pay_book()
     '''Create an account and add all the data required, except the card details'''
     self.createAccount = CreateAccountAndPay(self.cartPage.driver)
     self.createAccount.credentials()
     self.createAccount.continue_button()
     self.createAccount.address()
     self.createAccount.postcode()
     self.createAccount.phone()
     time.sleep(1)
     self.createAccount.continue_button()
     time.sleep(1)
     self.createAccount.continue_button()
     time.sleep(1)
     self.createAccount.continue_button()
     time.sleep(1)
     self.createAccount.continue_button()
     time.sleep(1)
     self.createAccount.accept_policy()
     self.createAccount.final_pay()
     time.sleep(1)
     self.createAccount.payment_error_message()
예제 #5
0
 def test_filter_sorter(self):
     print("\n" + str(test_cases(4)))
     page = HomePage(self.driver)
     _ = page.filter_company_name('sa')
     res = page.filter_by_industry('technology')
     self.assertEqual(len(res), 1)
     self.assertEqual(res[0].get_name(), 'SAP')
예제 #6
0
 def test_filter_by_industry(self):
     print("\n" + str(test_cases(3)))
     page = HomePage(self.driver)
     res = page.filter_by_industry('technology')
     for el in res:
         print
         self.assertEqual(el.get_industry(), 'technology')
예제 #7
0
def test_table_sort(browser, eyes):
    eyes.open(browser, "Applitools Demo", "Table Sort Test")
    home_page = HomePage(browser)
    LoginPage(browser).login_user("aaa", "aaa")
    eyes.check_window("Before sorting")
    home_page.sort_table_items()
    eyes.check_window("After sorting")
    eyes.close()
예제 #8
0
 def test_sorf_by_name(self):
     print("\n" + str(test_cases(3)))
     page = HomePage(self.driver)
     res = page.sort_by_name()
     config = Config()
     company_names = [company['name'] for company in config['companies']]
     company_names_sorted = sort(company_names)        
     first_by_name = company_names_sorted[0]
     self.assertEqual(res[0].get_name(), first_by_name)
예제 #9
0
 def test_show_answer(self):
     print("\n" + str(test_cases(3)))
     page = HomePage(self.driver)
     questions = page.get_questions_list()
     for question in questions:
         self.assertTrue(question.is_answer_hiden())
     res = page.show_answers()
     for question in res:
         self.assertFalse(question.is_answer_hiden())
예제 #10
0
def test_canvas_chart(browser, eyes):
    eyes.open(browser, "Applitools Demo", "Canvas Chart Test")
    home_page = HomePage(browser)
    expenses_page = ExpensesPage(browser)
    LoginPage(browser).login_user("aaa", "aaa")
    home_page.compare_expenses()
    eyes.check_window("Data for one year")
    expenses_page.show_data_for_next_year()
    eyes.check_window("Data for two years")
    eyes.close()
예제 #11
0
def step_impl(context):
    home_page = HomePage(context)
    home_page.visit(get_from_config('url'))
    navigation_page = NavigationPage(context)
    navigation_page.open_login_page()
    login_page = LoginPage(context)
    login_page.enter_username(get_from_config('username'))
    login_page.enter_password(get_from_config('password'))
    login_page.click_login_button()
    camps_page = CampsPage(context)
    assert camps_page.camps_page_is_displayed()
예제 #12
0
    def test_product_info(self):
        home_page = HomePage(self.driver)
        category_page = home_page.navigate_to_wearables()
        sub_category_page = category_page.navigate_to_smart_watch_category()
        name_1 = sub_category_page.get_product_name()
        price_1 = sub_category_page.get_product_price()

        product_page = sub_category_page.open_product_page()
        name_2 = product_page.get_product_name()
        price_2 = product_page.get_product_price()

        self.assertEqual(name_1, name_2, "Name is not equal")
        self.assertEqual(price_1, price_2, "Price is not equal")
예제 #13
0
 def test_shopping_experience(self):
     home_page = HomePage(self._browser)
     home_page.go_home_v1()
     home_page.filter_shoes_by_black_color_v1()
     self.soft_assert(self.assertTrue, home_page.report(2, "Filter results' count is 2",
                                                        home_page.result_item,
                                                        home_page.get_filter_results_count() == 2))
     self.assert_all()
예제 #14
0
def main():
    init()
    props = Properties.from_env()
    LoginPage().login(props.agency, props.account)
    KeypadPage().enter_password(props.password)
    HomePage().dismiss_popup().view_transactions()
    TransactionPage().filter_by_date(date(2020, 3, 1))
예제 #15
0
def test_dynamic_content(browser, url, eyes):
    eyes.open(browser, "Applitools Demo", "Dynamic Content Test")
    new_url = url + "?showAd=true"
    HomePage(browser).go_to_page(new_url)
    LoginPage(browser).login_user("aaa", "aaa")
    eyes.check_window("Two gifs")
    eyes.close()
def step_impl(context):
    context.home_page = HomePage(context.browser)
    context.poll_page = PollPage(context.browser)

    context.home_page.get(context.get_url(reverse('polls:index')))

    context.home_page.link_to_poll.click()

    context.poll_page.btn_vote.click()
예제 #17
0
 def test_sorf_by_name(self):
     print("\n" + str(test_cases(4)))
     page = HomePage(self.driver)
     page.add_question('A question', 'An answer')
     page.add_question('Z question', 'Z answer')
     page.add_question('K question', 'K answer')
     res = page.sort_questions_by_name()
     questions = [question.get_question() for question in res]
     self.assertEqual(questions, sorted(questions))
예제 #18
0
    def main(self):
        # Setup the driver and url
        self.setup()

        # Home Page
        homepage = HomePage(self.driver)
        homepage.click_button()

        # Select Make Page
        makepage = SelectMakePage(self.driver)
        makepage.select_random_make()

        # Select Model Page
        modelpage = SelectModelsPage(self.driver)
        modelpage.select_random_model()
        modelpage.use_location()

        # Check for flow type
        if (self.inventory_exists()):
            carpage = SelectCarPage(self.driver)
            carpage.select_random_car()
        else:
            self.inventoryflow = False
            trimpage = SelectTrim(self.driver)
            trimpage.select_random_trim()

        if (self.inventoryflow):
            reviewvehicle = ReviewVehiclePage(self.driver)
            reviewvehicle.click_next_button()

        # Review Details Page
        reviewdetails = ReviewDetailsPage(self.driver)
        reviewdetails.click_next_button()

        if (not self.inventoryflow):
            dealerpage = SelectDealerPage(self.driver)
            dealerpage.select_dealer()

        # Close driver
        self.teardown()
예제 #19
0
def test_add_featured_product_to_cart_from_home_page(browser):
    home_page = HomePage(browser)
    home_page.open_page()

    product_name = home_page.get_featured_product_name_by_index(0)
    home_page.add_to_cart_featured_product(0)

    top_menu = TopMenu(browser)
    top_menu.click_to_cart()
    added_product_name = top_menu.get_added_product_name()

    assert product_name in added_product_name
예제 #20
0
def InitPageFunc(dsn):
    for x in range(0, 2):
        playerTable = players.Players(dsn)
        playerTable.create_table()
        playerTable.close_con()
        userTable = users.Users(dsn)
        userTable.create_table()
        userTable.close_con()
        sponsorTable = sponsors.Sponsors(dsn)
        sponsorTable.create_table()
        sponsorTable.close_con()
        natTable = nats.Nats(dsn)
        natTable.create_table()
        natTable.close_con()
        statTable = stats.Stats(dsn)
        statTable.create_table()
        statTable.close_con()
        teamTable = teams.Teams(dsn)
        teamTable.create_table()
        teamTable.close_con()
        leagueTable = leagues.Leagues(dsn)
        leagueTable.create_table()
        leagueTable.close_con()
        coachTable = coaches.Coaches(dsn)
        coachTable.create_table()
        coachTable.close_con()
        stadiumTable = stadiums.Stadiums(dsn)
        stadiumTable.create_table()
        stadiumTable.close_con()
        matchTable = matches.Matches(dsn)
        matchTable.create_table()
        matchTable.close_con()
        betrateTable = betrates.Betrates(dsn)
        betrateTable.create_table()
        betrateTable.close_con()
        commentTable = comments.Comments(dsn)
        commentTable.create_table()
        commentTable.close_con()
        playerHis = playerHistory.playerHistory(dsn)
        playerHis.create_table()
        playerHis.close_con()
        outfittable = outfitTable.outfits(dsn)
        outfittable.create_table()
        outfittable.close_con()
        likeTable = likes.Likes(dsn)
        likeTable.create_table()
        likeTable.close_con()

    return HomePage.HomePageFunc()
예제 #21
0
    def test_elements(self):
        home_page = HomePage(self._browser)
        home_page.go_home_v1()
        self.soft_assert(self.assertTrue, home_page.report(1, "Profile icon is displayed",
                                                           home_page.profile_icon,
                                                           home_page.is_profile_icon_visible()))
        self.soft_assert(self.assertTrue, home_page.report(1, "Cart icon is displayed",
                                                           home_page.cart_icon, home_page.is_cart_icon_visible()))

        if home_page.get_device_name() == "Laptop":
            self.soft_assert(self.assertTrue, home_page.report(1, "Wishlist icon is displayed",
                                                               home_page.wishlist_icon,
                                                               home_page.is_wishlist_icon_visible()))
            self.soft_assert(self.assertTrue, home_page.report(1, "Grid view icon is displayed",
                                                               home_page.grid_view_icon_v1,
                                                               home_page.is_grid_view_icon_v1_visible()))
            self.soft_assert(self.assertTrue, home_page.report(1, "List view icon is displayed",
                                                               home_page.list_view_icon_v1,
                                                               home_page.is_list_view_icon_v1_visible()))
            self.soft_assert(self.assertTrue, home_page.report(1, "Search field is displayed",
                                                               home_page.search_field,
                                                               home_page.is_search_field_visible()))
            self.soft_assert(self.assertTrue, home_page.report(1, "Filter sidebar is displayed",
                                                               home_page.filter_sidebar,
                                                               home_page.is_filter_sidebar_visible()))
            self.soft_assert(self.assertTrue, home_page.report(1, "Filters icon is not displayed",
                                                               home_page.open_filters_icon_v1,
                                                               home_page.is_filters_icon_v1_visible() is False))
            self.assert_all()

        elif home_page.get_device_name() == "Tablet":
            self.soft_assert(self.assertTrue, home_page.report(1, "Wishlist icon is not displayed",
                                                               home_page.wishlist_icon,
                                                               home_page.is_wishlist_icon_visible() is False),
                             "Wishlist icon is displayed")
            self.soft_assert(self.assertTrue, home_page.report(1, "Grid view icon is not displayed",
                                                               home_page.grid_view_icon_v1,
                                                               home_page.is_grid_view_icon_v1_visible() is False))
            self.soft_assert(self.assertTrue, home_page.report(1, "List view icon is not displayed",
                                                               home_page.list_view_icon_v1,
                                                               home_page.is_list_view_icon_v1_visible() is False))
            self.soft_assert(self.assertTrue, home_page.report(1, "Search field is displayed",
                                                               home_page.search_field,
                                                               home_page.is_search_field_visible()))
            self.soft_assert(self.assertTrue, home_page.report(1, "Filter sidebar is not displayed",
                                                               home_page.filter_sidebar,
                                                               home_page.is_filter_sidebar_visible() is False))
            self.soft_assert(self.assertTrue, home_page.report(1, "Filters icon is displayed",
                                                               home_page.filter_sidebar,
                                                               home_page.is_filters_icon_v1_visible()))
            self.assert_all()

        elif home_page.get_device_name() == "Mobile":
            self.soft_assert(self.assertTrue, home_page.report(1, "Wishlist icon is not displayed",
                                                               home_page.wishlist_icon,
                                                               home_page.is_wishlist_icon_visible() is False))
            self.soft_assert(self.assertTrue, home_page.report(1, "Grid view icon is not displayed",
                                                               home_page.grid_view_icon_v1,
                                                               home_page.is_grid_view_icon_v1_visible() is False))
            self.soft_assert(self.assertTrue, home_page.report(1, "List view icon is not displayed",
                                                               home_page.list_view_icon_v1,
                                                               home_page.is_list_view_icon_v1_visible() is False))
            self.soft_assert(self.assertTrue, home_page.report(1, "Search field is not displayed",
                                                               home_page.search_field,
                                                               home_page.is_search_field_visible() is False))
            self.soft_assert(self.assertTrue, home_page.report(1, "Filter sidebar is not displayed",
                                                               home_page.filter_sidebar,
                                                               home_page.is_filter_sidebar_visible() is False))
            self.soft_assert(self.assertTrue, home_page.report(1, "Filters icon is displayed",
                                                               home_page.filter_sidebar,
                                                               home_page.is_filters_icon_v1_visible()))
            self.assert_all()
예제 #22
0
    def test_redirect_page_success(self):
        """
        Test case untuk memastikan bahwa semua fungsi redirect ke semua halaman berfungsi
        """
        # --- Subtest 1 - Redirect to home page ---

        # membuat objek homepage
        self.homepage = HomePage(self.driver)

        # Step 1 - click slider home page
        self.homepage.redirect_home_page_success()

        # Step 2 - Assertion
        with self.subTest(msg="Home"):
            element_text = self.homepage.get_text(Locators.HOME_PAGE_TITLE)
            self.assertEqual("Transaksi Mudah Tanpa Gundah", element_text)

        # --- Subtest 2 - Redirect to Welcome page ---

        # membuat objek welcome page
        self.welcomepage = WelcomePage(self.driver)

        # Step 3 - click slider welcome page
        self.welcomepage.redirect_welcome_page_success()

        # Step 4 - Assertion
        with self.subTest(msg="Welcome"):
            element_text1 = self.welcomepage.get_text(
                Locators.WELCOME_PAGE_TITLE)
            self.assertEqual("Selamat Datang di MoneySave", element_text1)

        # --- Subtest 3 - Redirect to Advantage page ---

        # membuat objek advantage page
        self.advantagespage = AdvantagesPage(self.driver)

        # Step 5 - click slider advantages page
        self.advantagespage.redirect_advantages_page_success()

        # Step 6 - Assertion
        with self.subTest(msg="Advantages"):
            element_text2 = self.advantagespage.get_text(
                Locators.ADVANTAGES_PAGE_TITLE)
            self.assertEqual("Keuntungan menggunakan MoneySave", element_text2)

        # --- Subtest 4 - Redirect to Main feature page ---

        # membuat objek main feature page
        self.mainfeaturepage = MainFeaturePage(self.driver)

        # Step 7 - Click slider main feature page
        self.mainfeaturepage.redirect_main_feature_page_success()

        # Step 8 - Assertion
        with self.subTest(msg="MainFeature"):
            element_text3 = self.mainfeaturepage.get_text(
                Locators.MAIN_FEATURE_PAGE_TITLE)
            self.assertEqual("Fitur Utama MoneySave", element_text3)

        # --- Subtest 5 - Redirect to security page ---

        # membuat objek security page
        self.securitypage = SecurityPage(self.driver)

        # Step 9 - Click Slider security page
        self.securitypage.redirect_security_page_success()

        # Step 10 - Assertion
        with self.subTest(msg="Security"):
            element_text4 = self.securitypage.get_text(
                Locators.SECURITY_PAGE_TITLE)
            self.assertEqual("Keamanan kita menggunakan yang terbaik",
                             element_text4)

        # --- Subtest 6 - Redirect to Download page ---

        # membuat objek download page
        self.downloadpage = DownloadPage(self.driver)

        # Step 11 - Click Slider Download Page
        self.downloadpage.redirect_download_page()

        # Step 12 - Assertion
        with self.subTest(msg="Download"):
            element_text5 = self.downloadpage.get_text(
                Locators.DOWNLOAD_PAGE_TITLE)
            self.assertEqual("Dapatkan Sekarang", element_text5)
예제 #23
0
 def setUp(self):
     self.driver = webdriver.Chrome()
     self.driver.get("http://localhost/rsvp/index.html")
     self.home_page = HomePage(self.driver)
예제 #24
0
class TreehouseRSVPTest(unittest.TestCase):
    def setUp(self):
        self.driver = webdriver.Chrome()
        self.driver.get("http://localhost/rsvp/index.html")
        self.home_page = HomePage(self.driver)

    def test_home_add_invitee(self):
        name = "Anne"
        self.home_page.add_invitee(name)
        invitee = self.home_page.find_invitee_by_name(name)
        self.assertIn(f"<span>{name}</span>",
                      invitee.element.get_attribute('innerHTML'))

    def test_home_hide_non_responders_after_add(self):
        name = "Teddy"
        self.home_page.add_invitee(name)
        invitee = self.home_page.find_invitee_by_name(name)
        invitee.toggle_confirmation()
        self.home_page.toggle_non_responders_visibility()
        self.assertTrue(invitee.element.is_displayed())

    def test_home_hide_non_responders_before_add(self):
        name_1 = "Ozzy"
        self.home_page.add_invitee(name_1)
        invitee_1 = self.home_page.find_invitee_by_name(name_1)
        self.home_page.toggle_non_responders_visibility()
        #add another invitee after toggled non-responders visibility checkbox
        name_2 = "Bubbles"
        self.home_page.add_invitee(name_2)
        invitee_2 = self.home_page.find_invitee_by_name(name_2)
        self.assertFalse(invitee_2.element.is_displayed()
                         )  #Here come's the bug. Yay! Joy of testers.

    def test_invitee_confirm(self):
        name = "Huckleberry Finn"
        self.home_page.add_invitee(name)
        invitee = self.home_page.find_invitee_by_name(name)
        invitee.toggle_confirmation()
        self.assertEqual("responded", invitee.element.get_attribute('class'))

    def test_invitee_rename(self):
        wrong_name = "Tmiber"
        correct_name = "Timber"
        self.home_page.add_invitee(wrong_name)
        invitee = self.home_page.find_invitee_by_name(wrong_name)
        invitee.rename(correct_name)
        self.assertIn(f"<span>{correct_name}</span>",
                      invitee.element.get_attribute('innerHTML'))

    def test_invitee_remove(self):
        names = ["Mr. Wonka", "Milka", "Dolly", "Kenny"]
        for name in names:
            self.home_page.add_invitee(name)
        kenny = self.home_page.find_invitee_by_name(names[3])
        kenny.remove()
        invitee_count = self.home_page.get_invitee_count()
        self.assertEqual(invitee_count, len(names) - 1)

    def tearDown(self):
        self.driver.close()
예제 #25
0
    def test_product_details(self):
        product_description = "These boots are comfortable enough to wear all day. Well made. I love the “look”. " \
                              "Best Used For Casual Everyday Walk fearlessly into the cooler months in the Sorel " \
                              "Joan Of Arctic Wedge II Chelsea Boot. Boasting the iconic wedge platform that's as " \
                              "comfortable as it is stylish, this boot features a waterproof upper"

        home_page = HomePage(self._browser)
        home_page.go_home_v1()
        home_page.filter_shoes_by_black_color_v1()
        details_page = home_page.click_result_item(1)
        self.soft_assert(self.assertTrue, home_page.report(3, "Product name is correct",
                                                           details_page.product_name,
                                                           details_page.get_product_name() == "Appli Air x Night"))
        self.soft_assert(self.assertTrue, home_page.report(3, "Product old price is correct",
                                                           details_page.product_old_price,
                                                           details_page.get_product_old_price() == "$48.00"))
        self.soft_assert(self.assertTrue, home_page.report(3, "Product new price is correct",
                                                           details_page.product_new_price,
                                                           details_page.get_product_new_price() == "$33.00"))
        self.soft_assert(self.assertTrue, home_page.report(3, "Product discount is correct",
                                                           details_page.product_discount,
                                                           details_page.get_product_discount() == "-30% discount"))
        self.soft_assert(self.assertTrue, home_page.report(3, "Product description is correct",
                                                           details_page.product_description,
                                                           product_description in details_page.get_product_description()))
        self.assert_all()
예제 #26
0
def step_logged_in(context):
    page = HomePage(context)
    assert page.home_page_loaded(), "Page did not load correctly."
예제 #27
0
invitees = [
    "Harry Potter", "Hermione Granger", "Ron Weasley", "Lord Voldemort",
    "Draco Malfoy", "Severus Snape", "Albus Dumbledore", "Neville Longbottom",
    "Luna Lovegood", "Rubeus Hagrid", "Ginny Weasley", "Minerva McGonagall",
    "Peeves the Rude Ghost", "Dobby the House Elf", "Moaning Myrtle",
    "Fred Weasley", "George Weasley", "Nagini the Snake", "Nymphadora Lupin",
    "Dudley Dursley", "Seamus Finnigan", "Oliver Wood"
]

# def add_invitee(name):
#     invite_form = driver.find_element_by_id('registrar')
#     invitee_name_field = driver.find_element_by_css_selector("#registrar input[name='name']")
#     invitee_name_field.send_keys(name)
#     invite_form.submit()

home_page = HomePage(driver, treehouse_rsvp_url)

home_page.open()
# home_page.add_invitee("Teddy")
# home_page.add_invitee("Lala")
# home_page.add_invitee("Pooh")
# # home_page.toggle_non_responders_visibility()

# teddy = home_page.find_invitee_by_name("Teddy")
# print(home_page.get_invitee_count())
# teddy.toggle_confirmation()
# print(teddy.element.get_attribute('class'))
# print(teddy.element.get_attribute('innerHTML'))
# home_page.add_invitee("Twitwi")
# elements = driver.find_elements_by_css_selector("#invitedList li")
# print("Number of elements: {}".format(len(elements)))
예제 #28
0
from pages import HomePage
from pages import SearchPage

from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager

driver = webdriver.Chrome(ChromeDriverManager().install())
driver.get("https://en.wikipedia.org/wiki/Main_Page")
driver.maximize_window()

home_page = HomePage(driver)
home_page.set_search_query("Design pattern")
home_page.search()
result = SearchPage(driver)
print(result.heading_text() == "Design pattern")

driver.quit()
예제 #29
0
def home_page(driver):
    return HomePage(driver)
예제 #30
0
def home():
    return HomePage.HomePageFunc()