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
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()
def get_logger(): global _logger_instance if not _logger_instance: _logger_instance = Settings.logger_cls() return _logger_instance