Esempio n. 1
0
 def test_create_page_handles_pageobject_with_no_validation(self):
     self.driver = WTF_WEBDRIVER_MANAGER.new_driver(
         "TestPageFactory.test_create_page_handles_pageobject_with_no_validation")
     self.assertRaises(TypeError,
                       PageFactory.create_page,
                       ValidateNotImplementedPageObject,
                       self.driver)
Esempio n. 2
0
 def test_create_page_uses_page_rank(self):
     self.driver = WTF_WEBDRIVER_MANAGER.new_driver(
         "TestPageFactory.test_create_page_uses_page_rank")
     self.driver.get("http://www.google.com")
     google_page = PageFactory.create_page(
         [GoogleSearch, GoogleSearch2], self.driver)
     self.assertTrue(isinstance(google_page, GoogleSearch2))
Esempio n. 3
0
 def test_wait_for_page_loads_times_out_on_bad_page(self):
     self.driver = WTF_WEBDRIVER_MANAGER.new_driver(
         "TestPageUtils.test_wait_for_page_loads_times_out_on_bad_page")
     self.driver.get("http://www.yahoo.com")
     self.assertRaises(PageLoadTimeoutError,
                       page.PageUtils.wait_until_page_loaded, GoogleSearch,
                       self.driver, 1)
Esempio n. 4
0
 def test_create_page_with_list(self):
     self.driver = WTF_WEBDRIVER_MANAGER.new_driver("TestPageFactor.test_create_page_with_list")
     self.driver.get("http://www.google.com")
     google = PageFactory.create_page([GoogleSearch, YahooSearch], self.driver)
     self.assertTrue(type(google) == GoogleSearch)
     self.driver.get("http://www.yahoo.com")
     yahoo = PageFactory.create_page([GoogleSearch, YahooSearch], self.driver)
     self.assertTrue(type(yahoo) == YahooSearch)
Esempio n. 5
0
 def test_create_page_createsPageWhenExists(self):
     self.driver = WTF_WEBDRIVER_MANAGER.new_driver(
         "TestPageFactory.test_create_page_createsPageWhenExists")
     self.driver.get("http://www.google.com")
     google = PageFactory.create_page(SearchPage, self.driver)
     self.assertTrue(type(google) == GoogleSearch)
     self.driver.get("http://www.yahoo.com")
     yahoo = PageFactory.create_page(SearchPage, self.driver)
     self.assertTrue(type(yahoo) == YahooSearch)
Esempio n. 6
0
 def test_create_page_with_list(self):
     self.driver = WTF_WEBDRIVER_MANAGER.new_driver(
         "TestPageFactor.test_create_page_with_list")
     self.driver.get("http://www.google.com")
     google = PageFactory.create_page([GoogleSearch, YahooSearch],
                                      self.driver)
     self.assertTrue(type(google) == GoogleSearch)
     self.driver.get("http://www.yahoo.com")
     yahoo = PageFactory.create_page([GoogleSearch, YahooSearch],
                                     self.driver)
     self.assertTrue(type(yahoo) == YahooSearch)
Esempio n. 7
0
 def test_using_flows(self):
     """
     Demonstrate abstracting out several steps into 1 call into a flow
     
     Let's say we have 2 or 3 steps that are repeated over and over again.
     Then it's a good idea to make it a workflow ('flow'), that can be 
     reused between different tests.
     """
     webdriver = WTF_WEBDRIVER_MANAGER.new_driver()
     search_page = perform_search("hello world", webdriver)
     self.assertTrue(search_page.result_contains("hello world"))
Esempio n. 8
0
 def test_using_flows(self):
     """
     Demonstrate abstracting out several steps into 1 call into a flow
     
     Let's say we have 2 or 3 steps that are repeated over and over again.
     Then it's a good idea to make it a workflow ('flow'), that can be 
     reused between different tests.
     """
     webdriver = WTF_WEBDRIVER_MANAGER.new_driver()
     search_page = perform_search("hello world", webdriver)
     self.assertTrue(search_page.result_contains("hello world"))
Esempio n. 9
0
 def test_createPage_createsPageFromFactory(self):
     # Mock a webdriver that looks like it's viewing yahoo
     config_reader = mock()
     when(config_reader).get("selenium.take_reference_screenshot", False).thenReturn(False)
     
     self.driver = WTF_WEBDRIVER_MANAGER.new_driver("TestPageObject.test_createPage_createsPageFromFactory")
     self.driver.get("http://www.google.com")
     google = SearchPage.create_page(self.driver, config_reader=config_reader)
     self.assertTrue(type(google) == GoogleSearch)
     self.driver.get("http://www.yahoo.com")
     yahoo = SearchPage.create_page(self.driver, config_reader=config_reader)
     self.assertTrue(type(yahoo) == YahooSearch)
Esempio n. 10
0
    def test_example_using_abstract_interfaces(self):
        "Demonstrates creating PageObjects using Abstract Factory pattern."
        webdriver = WTF_WEBDRIVER_MANAGER.new_driver()
        webdriver.get("http://www.google.com")

        # Notice I don't need specify GoogleSearchPage specifically, and
        # able to construct a ISearchPage of the correct type.
        search_page = PageFactory.create_page(ISearchPage, webdriver)
        self.assertEqual(GoogleSearchPage, type(search_page))

        webdriver.get("http://www.yahoo.com")
        search_page = PageFactory.create_page(ISearchPage, webdriver)
        self.assertEqual(YahooSearchPage, type(search_page))
Esempio n. 11
0
    def test_example_using_abstract_interfaces(self):
        "Demonstrates creating PageObjects using Abstract Factory pattern."
        webdriver = WTF_WEBDRIVER_MANAGER.new_driver()
        webdriver.get("http://www.google.com")

        # Notice I don't need specify GoogleSearchPage specifically, and
        # able to construct a ISearchPage of the correct type.
        search_page = PageFactory.create_page(ISearchPage, webdriver)
        self.assertEqual(GoogleSearchPage, type(search_page))

        webdriver.get("http://www.yahoo.com")
        search_page = PageFactory.create_page(ISearchPage, webdriver)
        self.assertEqual(YahooSearchPage, type(search_page))
Esempio n. 12
0
 def test_home_page_basic(self):
     webdriver = WTF_WEBDRIVER_MANAGER.new_driver()
     webdriver.get(ConfigReader('site_credentials').get("default_url"))
     home_page = PageFactory.create_page(HomePage, webdriver)
     home_page.search_for_what(u"Бар")
     home_page.search_for_where(u"Москва")
     home_page.click_search_button()
     webdriver.implicitly_wait(3000)
     results_list_page = PageFactory.create_page(ResultsList, webdriver)
     self.assertEqual(webdriver.title, "Localway")
     category = results_list_page.category_filter_list()
     category_path = PageUtils.get_element_xpath(category)
     print category_path
     print('test ok')
Esempio n. 13
0
 def test_capture_file_created_and_valid_png(self):
     self.driver = WTF_WEBDRIVER_MANAGER.new_driver("TestPageUtils.test_capture_file_created_and_valid_png")
     self.driver.get("http://www.yahoo.com")
     fname = "test"
     prj_root = ProjectUtils.get_project_root()
     fpath = os.path.join(prj_root, WebScreenShotUtil.SCREEN_SHOT_LOCATION, fname + ".png")
     try:
         WebScreenShotUtil.take_screenshot(self.driver, fname)
         self.assertTrue(os.path.isfile(fpath))
         self.assertEquals(imghdr.what(fpath), "png")
     finally:
         try:
             os.remove(fpath)
         except OSError:
             pass
Esempio n. 14
0
    def test_wait_for_page_to_load(self):
        self.driver = WTF_WEBDRIVER_MANAGER.new_driver("TestPageUtils.test_wait_for_page_to_load")
        start_time = datetime.now()
        
        # create a separate thread to load yahoo 10 seconds later.
        t = threading.Thread(target=self.__load_google_later)
        t.start()

        self.page_obj = page.PageUtils.wait_until_page_loaded(GoogleSearch, self.driver, 60, sleep=5)
        t.join()
        end_time = datetime.now()
        
        # check we get a page object pack.
        self.assertTrue(isinstance(self.page_obj, GoogleSearch))
        # check that the instantiation happened later when the page was loaded.
        self.assertGreater(end_time - start_time, timedelta(seconds=10))
Esempio n. 15
0
    def test_createPage_createsPageFromFactory(self):
        # Mock a webdriver that looks like it's viewing yahoo
        config_reader = mock()
        when(config_reader).get("selenium.take_reference_screenshot",
                                False).thenReturn(False)

        self.driver = WTF_WEBDRIVER_MANAGER.new_driver(
            "TestPageObject.test_createPage_createsPageFromFactory")
        self.driver.get("http://www.google.com")
        google = SearchPage.create_page(self.driver,
                                        config_reader=config_reader)
        self.assertTrue(type(google) == GoogleSearch)
        self.driver.get("http://www.yahoo.com")
        yahoo = SearchPage.create_page(self.driver,
                                       config_reader=config_reader)
        self.assertTrue(type(yahoo) == YahooSearch)
Esempio n. 16
0
 def test_capture_file_created_and_valid_png(self):
     self.driver = WTF_WEBDRIVER_MANAGER.new_driver(
         "TestPageUtils.test_capture_file_created_and_valid_png")
     self.driver.get("http://www.yahoo.com")
     fname = "test"
     prj_root = ProjectUtils.get_project_root()
     fpath = os.path.join(
         prj_root, WebScreenShotUtil.SCREEN_SHOT_LOCATION, fname + ".png")
     try:
         WebScreenShotUtil.take_screenshot(self.driver, fname)
         self.assertTrue(os.path.isfile(fpath))
         self.assertEquals(imghdr.what(fpath), "png")
     finally:
         try:
             os.remove(fpath)
         except OSError:
             pass
Esempio n. 17
0
    def test_basic_example(self):
        "Displays a simple PageObject instantiation example."

        # WTF_WEBDRIVER_MANAGER provides a easy to access to
        # the webdriver.  A web browser will be instantiated
        # according to your config settings.
        # - see 'selenium' settings in 'configs/default.yaml'
        webdriver = WTF_WEBDRIVER_MANAGER.new_driver()

        # Simple navigation
        webdriver.get("http://www.google.com")

        # Use the PageFactory class to instantiate your page.
        google_page = PageFactory.create_page(GoogleSearchPage, webdriver)

        # With your PageObject instantiated, you can call it's methods.
        google_page.search("hello world")

        self.assertTrue(google_page.result_contains("hello world"))
Esempio n. 18
0
    def test_basic_example(self):
        "Displays a simple PageObject instantiation example."
        
        # WTF_WEBDRIVER_MANAGER provides a easy to access to 
        # the webdriver.  A web browser will be instantiated 
        # according to your config settings. 
        # - see 'selenium' settings in 'configs/default.yaml'
        webdriver = WTF_WEBDRIVER_MANAGER.new_driver()

        # Simple navigation
        webdriver.get("http://www.google.com")
        
        # Use the PageFactory class to instantiate your page.
        google_page = PageFactory.create_page(GoogleSearchPage, webdriver)
        
        # With your PageObject instantiated, you can call it's methods.
        google_page.search("hello world")
        
        self.assertTrue(google_page.result_contains("hello world"))
Esempio n. 19
0
    def test_wait_for_page_to_load(self):
        self.driver = WTF_WEBDRIVER_MANAGER.new_driver(
            "TestPageUtils.test_wait_for_page_to_load")
        start_time = datetime.now()

        # create a separate thread to load yahoo 10 seconds later.
        t = threading.Thread(target=self.__load_google_later)
        t.start()

        self.page_obj = page.PageUtils.wait_until_page_loaded(GoogleSearch,
                                                              self.driver,
                                                              60,
                                                              sleep=5)
        t.join()
        end_time = datetime.now()

        # check we get a page object pack.
        self.assertTrue(isinstance(self.page_obj, GoogleSearch))
        # check that the instantiation happened later when the page was loaded.
        self.assertGreater(end_time - start_time, timedelta(seconds=10))
Esempio n. 20
0
 def test_using_the_testdata(self):
     """
     Demonstrates getting a setting via testdata package, and WTF_CONFIG_READER
     
     By default it'll use google.com, but you can add this line in the config file 
     (by default it's default.yaml) You can override this setting.
     
     Insert the line below and run again to see this same test run in Yahoo.
     
         search_provider: http://www.yahoo.com
     
     By creating  testdata functions to abstract directly accessing WTF_CONFIG_READER, 
     we can reduce the number of hard coded strings that needs to be refactored if 
     configuration settings need to be refactored.
     """
     search_url = get_search_provider()
     webdriver = WTF_WEBDRIVER_MANAGER.new_driver()
     webdriver.get(search_url)
     search_page = PageFactory.create_page(ISearchPage, webdriver)
     search_page.search("hello world")
     self.assertTrue(search_page.result_contains("hello world"))
Esempio n. 21
0
 def test_using_the_testdata(self):
     """
     Demonstrates getting a setting via testdata package, and WTF_CONFIG_READER
     
     By default it'll use google.com, but you can add this line in the config file 
     (by default it's default.yaml) You can override this setting.
     
     Insert the line below and run again to see this same test run in Yahoo.
     
         search_provider: http://www.yahoo.com
     
     By creating  testdata functions to abstract directly accessing WTF_CONFIG_READER, 
     we can reduce the number of hard coded strings that needs to be refactored if 
     configuration settings need to be refactored.
     """
     search_url = get_search_provider()
     webdriver = WTF_WEBDRIVER_MANAGER.new_driver()
     webdriver.get(search_url)
     search_page = PageFactory.create_page(ISearchPage, webdriver)
     search_page.search("hello world")
     self.assertTrue(search_page.result_contains("hello world"))
	def test_10_goto_item_from_view_result(self):
		webdriver = WTF_WEBDRIVER_MANAGER.new_driver()
		webdriver.get(self.tryon_url)
		tryon_page = PageFactory.create_page(TryonPage)
		self.assertTrue(tryon_page.goto_item_from_view_result())
	def test_forgot_password(self):
		webdriver = WTF_WEBDRIVER_MANAGER.new_driver()
		webdriver.get(self.signin_url)
		signin_page = PageFactory.create_page(SignInPage)
		self.assertTrue(signin_page.forgot_password())
	def test_send_reset_password_email_with_bad_email(self):
		webdriver = WTF_WEBDRIVER_MANAGER.new_driver()
		webdriver.get(self.signin_url)
		signin_page = PageFactory.create_page(SignInPage)
		self.assertTrue(signin_page.send_reset_password_email_with_bad_email())
	def test_11signin(self):
		webdriver = WTF_WEBDRIVER_MANAGER.new_driver()
		webdriver.get(self.base_url+'modules/index.php?pkg=account&contr=account')
		signin_page = PageFactory.create_page(SignInPage)
		self.assertTrue(signin_page.signin())
	def test_signup_with_existing_email(self):
		webdriver = WTF_WEBDRIVER_MANAGER.new_driver()
		webdriver.get(self.signin_url)
		signin_page = PageFactory.create_page(SignInPage)
		self.assertTrue(signin_page.signup_with_existing_email())
Esempio n. 27
0
 def setUp(self):
     self.driver = WTF_WEBDRIVER_MANAGER.new_driver()
     self.driver.get(url_with_credentials())
Esempio n. 28
0
 def setUp(self):
     self.webdriver = WTF_WEBDRIVER_MANAGER.new_driver("TestWebUtils")
 def setUp(self):
     self.driver = WTF_WEBDRIVER_MANAGER.new_driver("TestWebElementSelector")
	def test_00_post_without_signin(self):
		webdriver = WTF_WEBDRIVER_MANAGER.new_driver()
		webdriver.get(self.emshare_url)
		emshare_page = PageFactory.create_page(EmSharePage)
		self.assertTrue(emshare_page.post_without_signin())
Esempio n. 31
0
 def test_wait_for_page_loads_times_out_on_bad_page_list(self):
     self.driver = WTF_WEBDRIVER_MANAGER.new_driver(
         "TestPageUtils.test_wait_for_page_loads_times_out_on_bad_page_list")
     self.driver.get("http://www.yahoo.com")
     self.assertRaises(PageLoadTimeoutError, page.PageUtils.wait_until_page_loaded,
                       [GoogleSearch], self.driver, 1)
Esempio n. 32
0
 def test_create_page_raiseExceptionWhenNoMatch(self):
     self.driver = WTF_WEBDRIVER_MANAGER.new_driver(
         "TestPageFactory.test_create_page_raiseExceptionWhenNoMatch")
     self.driver.get("http://the-internet.herokuapp.com")
     self.assertRaises(
         NoMatchingPageError, PageFactory.create_page, SearchPage, self.driver)
Esempio n. 33
0
 def test_fail(self):
     driver = WTF_WEBDRIVER_MANAGER.new_driver()
     driver.get('http://www.google.com')
     self.fail()
Esempio n. 34
0
 def test_assert(self):
     driver = WTF_WEBDRIVER_MANAGER.new_driver()
     driver.get('http://www.google.com')
     self.assertEqual(1, 2)
Esempio n. 35
0
 def testName(self):
     driver = WTF_WEBDRIVER_MANAGER.new_driver()
     print("hello")
Esempio n. 36
0
 def set_up(self):
     webdriver = WTF_WEBDRIVER_MANAGER.new_driver()
     webdriver.get(ConfigReader('site_credentials').get("default_url"))
     return webdriver
Esempio n. 37
0
 def set_up_with_suffix(self, suffix):
     webdriver = WTF_WEBDRIVER_MANAGER.new_driver()
     webdriver.get(ConfigReader('site_credentials').get("default_url") + suffix)
     return webdriver
	def test_06_take_snapshot_without_signin(self):
		webdriver = WTF_WEBDRIVER_MANAGER.new_driver()
		webdriver.get(self.tryon_url)
		tryon_page = PageFactory.create_page(TryonPage)
		self.assertTrue(tryon_page.take_snapshot_without_signin())
	def test_filter_brand_macy(self):
		webdriver = WTF_WEBDRIVER_MANAGER.new_driver()
		webdriver.get(self.shop_url)
		shop_page = PageFactory.create_page(ShopPage)
		self.assertTrue(shop_page.filter_brand_macy())
 def setUp(self):
     self.driver = WTF_WEBDRIVER_MANAGER.new_driver()
     self.base_url = WTF_CONFIG_READER.get("selenium.baseurl")
Esempio n. 41
0
 def test_error(self):
     driver = WTF_WEBDRIVER_MANAGER.new_driver()
     driver.get('http://www.google.com')
     raise RuntimeError()
Esempio n. 42
0
 def setUp(self):
     self.driver = WTF_WEBDRIVER_MANAGER.new_driver()
     self.driver.get(data.url_address())
Esempio n. 43
0
 def setUp(self):
     self.webdriver = WTF_WEBDRIVER_MANAGER.new_driver("TestWebUtils")