예제 #1
0
 def test_hotels_aid_browser_rich_pp(self, button_locator, main,
                                     download_moscow_map, b_steps,
                                     return_back_to_mapsme,
                                     switch_to_native):
     b_steps.search_booking_hotel(LocalizedButtons.AEROPOLIS_NAME.get())
     b_steps.scroll_down(from_el=b_steps.try_get(Locator.PP_ANCHOR.get()))
     button = b_steps.find_booking_button_on_pp(button_locator)
     assert button
     button.click()
     WebDriverWait(b_steps.driver, 20).until(EC2.web_view_context_enabled())
     contexts = b_steps.driver.contexts
     cons = [x.split("_")[-1] for x in contexts if x != "NATIVE_APP"]
     b_steps.driver.switch_to.context("WEBVIEW_{}".format(cons[-1]))
     WebDriverWait(b_steps.driver, 20).until(EC.url_contains("booking.com"))
     url = b_steps.driver.current_url
     url_params = dict(parse.parse_qsl(parse.urlsplit(url).query))
     logging.info(str(url_params))
     aid = url_params["aid"]
     if get_settings("System", "Platform") == "Android":
         assert aid == "1595466"
     else:
         assert aid == "1595464"
     b_steps.switch_to_native()
     b_steps.close_first_time_frame()
     b_steps.press_back_until_main_page()
예제 #2
0
 def test_browser_booking_rich_pp(self, button_locator, find_booking_hotels, main, download_moscow_map, steps,
                                  b_steps, testitem_booking):
     hotel = None
     result = False
     while not result:
         while True:
             try:
                 hotel = find_booking_hotels.pop()
                 b_steps.search_booking_hotel(hotel)
                 break
             except (TimeoutException, AssertionError):
                 b_steps.press_back_until_main_page()
         sleep(2)
         b_steps.scroll_down(from_el=steps.try_get(Locator.PP_ANCHOR.get()))
         button = b_steps.find_booking_button_on_pp(button_locator)
         assert button
         button.click()
         WebDriverWait(main, 20).until(EC2.web_view_context_enabled())
         contexts = main.contexts
         cons = [x.split("_")[-1] for x in contexts if x != "NATIVE_APP"]
         main.switch_to.context("WEBVIEW_{}".format(cons[-1]))
         WebDriverWait(main, 20).until(EC.url_contains("booking.com"))
         url = main.current_url
         booking = Booking(testitem_booking.id)
         booking.create(hotel, url)
         result = self.browser_steps(booking, hotel)
         booking.result("Booked" if result else "Failure")
         b_steps.switch_to_native()
         b_steps.close_first_time_frame()
         b_steps.press_back_until_main_page()
예제 #3
0
 def test_browser_booking_poor_button(self, main, download_moscow_map, steps, b_steps, testitem_booking,
                                      find_osm_hotels):
     result = False
     while not result:
         hotel = None
         while True:
             try:
                 hotel = find_osm_hotels.pop()
                 b_steps.search_osm_hotel(hotel)
                 break
             except (TimeoutException, AssertionError):
                 b_steps.press_back_until_main_page()
         BottomPanel().book().click()
         WebDriverWait(main, 20).until(EC2.web_view_context_enabled())
         contexts = main.contexts
         cons = [x.split("_")[-1] for x in contexts if x != "NATIVE_APP"]
         main.switch_to.context("WEBVIEW_{}".format(cons[-1]))
         WebDriverWait(main, 20).until(EC.url_contains("booking.com"))
         url = main.current_url
         hotel = "SkyPoint"
         booking = Booking(testitem_booking.id)
         booking.create(hotel, url)
         result = self.browser_steps(booking, hotel)
         booking.result("Booked" if result else "Failure")
         b_steps.switch_to_native()
         b_steps.close_first_time_frame()
         b_steps.press_back_until_main_page()
예제 #4
0
 def test_hotels_aid_browser_poor_button(self, main, download_moscow_map,
                                         b_steps, return_back_to_mapsme,
                                         switch_to_native):
     b_steps.search_osm_hotel("Аэрополис")
     BottomPanel().book().click()
     WebDriverWait(b_steps.driver, 20).until(EC2.web_view_context_enabled())
     contexts = b_steps.driver.contexts
     cons = [x.split("_")[-1] for x in contexts if x != "NATIVE_APP"]
     b_steps.driver.switch_to.context("WEBVIEW_{}".format(cons[-1]))
     WebDriverWait(b_steps.driver, 20).until(EC.url_contains("booking.com"))
     url = b_steps.driver.current_url
     url_params = dict(parse.parse_qsl(parse.urlsplit(url).query))
     logging.info(str(url_params))
     aid = url_params["aid"]
     if get_settings("System", "Platform") == "Android":
         assert aid == "1595466"
     else:
         assert aid == "1595464"
     b_steps.switch_to_native()
     b_steps.close_first_time_frame()
     b_steps.press_back_until_main_page()
예제 #5
0
        def wrapper(*args, **kwargs):
            if context_type == "native":
                driver = WebDriverManager.get_instance().driver
                if driver.context != "NATIVE_APP":
                    driver.switch_to.context("NATIVE_APP")
            else:
                driver = WebDriverManager.get_instance().driver
                if driver.context == "NATIVE_APP":
                    try:
                        WebDriverWait(driver,
                                      20).until(EC2.web_view_context_enabled())
                        contexts = driver.contexts
                        cons = [
                            x.split("_")[-1] for x in contexts
                            if x != "NATIVE_APP" and "chrome" not in x
                        ]
                        if len(cons) > 0:
                            driver.switch_to.context("WEBVIEW_{}".format(
                                cons[-1]))
                    except TimeoutException:
                        pass

            return func(*args, **kwargs)
예제 #6
0
 def switch_to_webview(self):
     WebDriverWait(self.driver, 20).until(EC2.web_view_context_enabled())
     contexts = self.driver.contexts
     cons = [x.split("_")[-1] for x in contexts if x != "NATIVE_APP"]
     self.driver.switch_to.context("WEBVIEW_{}".format(cons[-1]))