Path: blob/trunk/py/test/selenium/webdriver/common/google_one_box.py
1865 views
# Licensed to the Software Freedom Conservancy (SFC) under one1# or more contributor license agreements. See the NOTICE file2# distributed with this work for additional information3# regarding copyright ownership. The SFC licenses this file4# to you under the Apache License, Version 2.0 (the5# "License"); you may not use this file except in compliance6# with the License. You may obtain a copy of the License at7#8# http://www.apache.org/licenses/LICENSE-2.09#10# Unless required by applicable law or agreed to in writing,11# software distributed under the License is distributed on an12# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY13# KIND, either express or implied. See the License for the14# specific language governing permissions and limitations15# under the License.1617from page_loader import require_loaded18from results_page import ResultsPage1920from selenium.common.exceptions import NoSuchElementException21from selenium.webdriver.common.by import By222324class GoogleOneBox:25"""This class models a page that has a google search bar."""2627def __init__(self, driver, url):28self._driver = driver29self._url = url3031def is_loaded(self):32try:33self._driver.find_elemen(By.NAME, "q")34return True35except NoSuchElementException:36return False3738def load(self):39self._driver.get(self._url)4041@require_loaded42def search_for(self, search_term):43element = self._driver.find_element(By.NAME, "q")44element.send_keys(search_term)45element.submit()46return ResultsPage(self._driver)474849