def test_google_images(driver): search_page = SearchPage(driver).open() results_page = search_page.search_for("python") images_page = results_page.switch_to_images_page() images = images_page.get_elements(ImagesPage.image)[:5] for image in images: assert image.is_displayed()
def test_search_for_category(self): base_page = BasePage(self.driver) search_page = SearchPage(self.driver) #navigate to etsy and search for items by category assert base_page.nav_to_etsy() assert search_page.search_for_category()
def test_search_for_item(self): base_page = BasePage(self.driver) search_page = SearchPage(self.driver) #navigate to etsy and search for an item assert base_page.nav_to_etsy() assert search_page.search_for_item()
def show_search_page(self, search_string, press_return=False): self.category_view.unselect_all() self.press_return = press_return if self.press_return: completion_grab_window.popup_grab_window_focus_out() search_page = SearchPage(self.data_manager) self.show_pkg_view(search_page) search_page.update(map(lambda word: word.encode("utf8"), search_string.split(" ")))
def find_and_delete_existing_video(self, url): """Search for a video by url and delete via django admin ui. url - refers to the videos original url, not local site url. """ search_pg = SearchPage() search_pg.open_search_page() result_pg = search_pg.basic_search(url) if result_pg.search_has_results(): vid_pg = result_pg.click_first_search_result() vid_id = vid_pg.video_id() self.delete_video(vid_id) self.django_admin_logout
def find_and_delete_existing_video(self, url): """Search for a video by url and delete via django admin ui. url - refers to the videos original url, not local site url. """ search_pg = SearchPage() search_pg.open_search_page() result_pg = search_pg.basic_search(url) if result_pg.search_has_results(): vid_pg = result_pg.click_first_search_result() vid_id = vid_pg.video_id() self.delete_video(vid_id) self.django_admin_logout
def show_search_page(self, search_string, press_return=False): if search_string.strip() != "": self.category_view.unselect_all() self.press_return = press_return if self.press_return: completion_grab_window.popup_grab_window_focus_out() search_page = SearchPage(self.data_manager) self.show_pkg_view(search_page) search_page.update(map(lambda word: word.encode("utf8"), search_string.split(" "))) else: global_logger.warn("empty string in search text input")
def test_add_favorite_without_signin(self): base_page = BasePage(self.driver) search_page = SearchPage(self.driver) #navigate to etsy and search for an item assert base_page.nav_to_etsy() assert search_page.search_for_item("BMW E28 Keychain") #retrieve all favorite icons from search results, click the first instance, verify join etsy modal displays fav_buttons = self.driver.find_elements_by_xpath( "//ul[contains(@class, 'responsive-listing-grid')]" + "//li//div[@data-favorite-button-wrapper]//button[contains(@class, 'favorite-listing-button')]" ) fav_buttons[0].click() assert self.driver.find_element_by_xpath( "//div[@data-join-neu-overlay-container]")
def do_search_on_main_search_box(self, search_query): search_box = self.selenium.find_element(*self._main_search_box) search_box.clear() search_box.type_keys(search_query) self.selenium.find_element(*self._search_button).click() from search_page import SearchPage return SearchPage(self.testsetup)
def show_search_page(self, search_string, press_return=False): if search_string.strip() != "": self.category_view.unselect_all() self.press_return = press_return if self.press_return: completion_grab_window.popup_grab_window_focus_out() search_page = SearchPage(self.data_manager) self.show_pkg_view(search_page) search_page.update( map(lambda word: word.encode("utf8"), search_string.split(" "))) else: global_logger.warn("empty string in search text input")
class TestSearch(unittest.TestCase): base_url = "http://www.baidu.com" search = SearchPage() def setUp(self): self.search.driver.get(self.base_url) def test_search(self): #self.search.driver.get(self.base_url) self.search.search("中国") self.search.click_search_button() sleep(3) def tearDown(self): self.search.driver.quit()
def __init__(self, application, package_cache): Gtk.ApplicationWindow.__init__(self, application=application) # I18N This is the name of the application. I pronounce # it “apt-er-iks” (like the word “apt”). self.set_title(_("Apteryx")) header_bar = Gtk.HeaderBar() header_bar.set_show_close_button(True) header_bar.set_title(self.get_title()) self.set_titlebar(header_bar) back_button = Gtk.Button.new_from_icon_name("go-previous", Gtk.IconSize.SMALL_TOOLBAR) header_bar.pack_start(back_button) browse_search_box = Gtk.ButtonBox(Gtk.Orientation.HORIZONTAL) browse_search_box.set_layout(Gtk.ButtonBoxStyle.EXPAND) header_bar.pack_start(browse_search_box) # I18N This is a button to open a view to browse the list # of package categories. browse_button = Gtk.Button.new_with_label(_("Browse")) browse_search_box.add(browse_button) # I18N This is a button that shows a search interface. search_button = Gtk.Button.new_with_label(_("Search")) browse_search_box.add(search_button) # I18N This is a button that allows the user to select # any Recommended or Suggested packages they want before # performing any marked actions (installing, removing, # etc.) finish_button = Gtk.Button.new_with_label(_("Finish")) header_bar.pack_end(finish_button) stack = ViewStack() stack.go_to_new_page(SectionList(package_cache, stack)) back_button.connect('clicked', lambda b: stack.go_back()) browse_button.connect( 'clicked', lambda b: stack.go_to_new_page(SectionList(package_cache, stack))) search_button.connect( 'clicked', lambda b: stack.go_to_new_page(SearchPage(package_cache, stack))) self.add(stack)
def testSearchPageLayout(self): """Test the search page layout contains the elements we expect. This should include elements inherited from the base page, BASE_PAGE_ELEMENTS (defined in layout.py), as well as elements specific to the search page, SEARCH_PAGE_ELEMENTS. Please add to each list as the UI is modified to ensure this test stays up to date. """ search_page = SearchPage(self.driver) search_page.searchForTestItem('foo') for element_by_id in SearchPage.BASE_PAGE_ELEMENTS: base_page_element = search_page.get_element(element_by_id) self.assertIsNotNone(base_page_element) self.assertTrue(base_page_element.is_displayed()) self.assertLogoLinksToLandingPage() for element_by_id in SearchPage.SEARCH_PAGE_ELEMENTS: search_page_element = search_page.get_element(element_by_id) self.assertIsNotNone(search_page_element) self.assertTrue(search_page_element.is_displayed())
def search_for(self, keyword): search_field = self._driver.find_element_by_id("search") search_field.send_keys(keyword) search_field.submit() return SearchPage(self._driver)
def test_google_search(driver, text): search_page = SearchPage(driver).open() results_page = search_page.search_for(text) link_text = results_page.get_result_link_text(1) assert text in link_text
slider, content_page_info, action_bar, module_info, foot_box), lambda: titlebar_backward_cb(module_dict, action_bar, slider, content_page_info, foot_box), lambda: titlebar_forward_cb(module_dict, action_bar, slider, content_page_info, foot_box), lambda: search_cb(action_bar, slider, foot_box)) action_bar.backward_button.set_sensitive(False) action_bar.forward_button.set_sensitive(False) application.window.add_move_event(action_bar.navigate_bar) # Init slider. slider = HSlider(200) # Init search page. search_page = SearchPage(module_infos) # Init navigate page. navigate_page = NavigatePage( module_infos, lambda path, config: start_module_process( slider, content_page_info, path, config)) foot_box.hide() # Init content page info. content_page_info = ContentPageInfo(slider) for module_info_list in module_infos: for module_info in module_info_list: content_page_info.create_content_page(module_info.id)
def __init__(self, driver: webdriver.Chrome): SearchPage.__init__(self, driver)
def setUpClass(cls): driver = BoxDriver('http://127.0.0.1:4723/wd/hub', 'App') cls.page = SearchPage(driver) # 执行前置操作 cls.page.common()