示例#1
0
文件: driver.py 项目: tkachoff/pypeak
def get_driver():
    global _driver_instance
    if not _driver_instance:
        _driver_instance = Settings.driver_cls()
        _driver_instance.implicitly_wait(Settings.implicit_timeout)
    return _driver_instance
示例#2
0

class GooglePage(BasePage):
    url = "http://www.google.com"

    text_field = TextInput(Name('q'))
    button = Button(Name('btnK'))


class ResultItem(HtmlElement):
    header = Link(XPath('.//h3/a'))
    link = Link(XPath(''))


class ResultsPage(object):
    stat = Text(ID('resultStats'))
    results = All(ResultItem, XPath("//div[@class='srg']/div"))


if __name__ == '__main__':
    Settings.set_driver_class(Firefox)
    home_page = GooglePage()
    home_page.open()
    home_page.text_field.send_keys('Page Object')
    home_page.button.click()
    results_page = ResultsPage()
    print('Results summary: {0}'.format(results_page.stat.text))
    for item in results_page.results:
        print(item.header.text)
    close_driver()
示例#3
0
文件: logger.py 项目: tkachoff/pypeak
def get_logger():
    global _logger_instance
    if not _logger_instance:
        _logger_instance = Settings.logger_cls()
    return _logger_instance