Package: holmium.core
holmium.coreIntroductionholmium.core provides utilities for simplifying the creation and maintenance of tests that rely onSelenium.Nothing beats an example. Conventionally automated tests integrating with python-selenium are written
similarly to the following code block (using seleniumhq.org).importselenium.webdriverimportunittestclassSeleniumHQTest(unittest.TestCase):defsetUp(self):self.driver=selenium.webdriver.Firefox()self.url="http://seleniumhq.org"deftest_header_links(self):self.driver.get(self.url)elements=self.driver.find_elements_by_css_selector("div#main_navbar ul li>a")self.assertTrue(len(elements)>0)forelementinelements:self.assertTrue(element.is_displayed())expected_link_list=["About","Blog","Documentation","Downloads","English","Projects","Support",]actual_link_list=[el.textforelinelements]self.assertEqual(sorted(expected_link_list),sorted(actual_link_list))deftest_projects_selenium_heading(self):self.driver.get(self.url)projects_link=self.driver.find_element_by_css_selector("nav>a[href='./projects']")projects_link.click()heading=self.driver.find_element_by_css_selector("p.lead")self.assertEqual(heading.text,"Selenium has many projects that combine to form a versatile testing system.")deftearDown(self):ifself.driver:self.driver.quit()if__name__=="__main__":unittest.main()The above example does what most selenium tests do:initialize a webdriver upon setUpquery for one or more web elements using either class name, id, css_selector or xpathassert on the number of occurrences / value of certain elements.tear down the webdriver after each test caseIt suffers from the typical web development problem of coupling the test case with the HTML plumbing of
the page its testing rather than the functionality its meant to exercise. The concept ofPageObjectsreduces this coupling and allow for test authors to separate the layout of the page under test and the
functional behavior being tested. This separation also results in more maintainable test code
(i.e. if an element name changes - all tests don’t have to be updated, just the PageObject).Lets take the above test case for a spin with holmium. Take note of the following:The initialization and reset of the webdriver is delegated to the TestCase base class
(alternatively the class could subclass unittest.TestCase and be run with the holmium nose plugin).the page elements are accessed in the test only via Element & ElementMap.importunittestfromholmium.coreimportElement,ElementMap,Locators,Page,TestCaseclassSeleniumHQPage(Page):nav_links=ElementMap(Locators.CSS_SELECTOR,"div#main_navbar ul li>a")header_text=Element(Locators.CSS_SELECTOR,"p.lead")classSeleniumHQTest(TestCase):defsetUp(self):self.page=SeleniumHQPage(self.driver,"http://seleniumhq.org")deftest_header_links(self):self.assertTrue(len(self.page.nav_links)>0)self.assertElementsDisplayed(self.page.nav_links)self.assertEqual(sorted(["About","Blog","Documentation","Downloads","English","Projects","Support",]),sorted(self.page.nav_links.keys()),)deftest_projects_selenium_heading(self):self.page.nav_links["Projects"].click()self.assertElementTextEqual(self.page.header_text,"Selenium has many projects that combine to form a versatile testing system.",)if__name__=="__main__":unittest.main()Which can then be executed in a few different ways as shown below.HO_BROWSER=firefoxpythontest_selenium_hq.pyFeature SummaryAutomatic provisioning and configuration of webdriver instances based on
environment variablesShorthand assertions for web pages (TestCase)Declarative model for defining pages, sections, page elements and element collections (Page Objects)Changelogv1.1.0Release Date: 2023-02-28ChoresRemove dependency on six & ordereddictUpgrade syntax to python 3.7+Automate pypi release processv1.0.0Release Date: 2023-02-27Breaking ChangesRemove support for python < 3Remove support for nose pluginRemove support for cucumber testsv0.8.5Release Date: 2016-09-06Extra options for assertConditionWithWait#42v0.8.4Release Date: 2016-09-01Bug fix: assertConditionWithWait#40v0.8.3Release Date: 2016-08-12Bug fix: Fix for IE with remote#38Bug fix: StaleElementReferenceException handling#33v0.8.2Release Date: 2015-12-22New filter_by argument that accepts conditionsv0.8.1Release Date: 2015-10-30Bug fix: Fix setup requirements for python 3.x #30v0.8Release Date: 2015-06-07No functional Changev0.7.9Release Date: 2015-05-30Bug fix: Support for phantom 1.9.x#29v0.7.8Release Date: 2014-11-02Bug fix: AttributeError when comparing with None#26Bug fix: Negative indexing in sections#27v0.7.7Release Date: 2014-09-05Bug fix: IE Driver initialization#24v0.7.6Release Date: 2014-07-14Hot fix: broken installation due to missing requirementsv0.7.5Release Date: 2014-07-14Bug fix forStaleElementReferenceExceptionin WebDriverWaitSupport for usingholmium.core.coniditionsobjects ascontext managersAdditional conditionsANYandALLfor element collections.v0.7.4Release Date: 2014-04-24Bug fix: Sections weren’t working for index > 1#22v0.7.3Release Date: 2014-03-14Add missing timeout from Sectionv0.7.2Release Date: 2014-02-22exclude packaging testsv0.7.1Release Date: 2014-02-18Fix packaging problem with versioneerv0.7Release Date: 2014-02-10Built-inconditionsfor explicit waitsNew assertionassertConditionWithWaitChange behavior ofonly_ifto not checkis_displayedby default.TweaksAllow passing a filename for nose argument--holmium-capabilitiesChange versioning to use versioneerExplicit py3k support with sixMake primitive lists and maps wrapped in pageobjects behave.v0.6.2Release Date: 2014-01-15Bug fixissue 19v0.6.1Release Date: 2013-12-23Bug fixissue 18for facet
clobbering when page inheritance was involvedBug fixissue 17for case of no browser specifiednew assertion for TestCase class :assertElementAttributeEqualv0.6Release Date: 2013-12-14Lazy driver initialization. The webdriver is created
when the test first accesses it.Support for using multiple browsers (drivers) in test cases. The original
self.driver is still available along with a self.drivers list which lazily
initializes new drivers as they are accessed via index. drivers[0] == driver.New environment variable / nose option to force browser(s) to be shutdown and
restarted between tests. (it is disabled by default, but cookies are still
always cleared between tests)New assertions added to the TestCase base classDocumentation cleanupsBug fixes for default timeout/only_if arugment for Element/Elements/ElementMapv0.5.2Release Date: 2013-12-09PyPy supportAllow customization of WebElements by exposingElementEnhancerv0.5.1Release Date: 2013-12-01Re-added python 2.6 supportv0.5.0Release Date: 2013-12-01Python 3.3 now supported and tested.v0.4.2Release Date: 2013-12-01New parameteronly_if(callable that accepts the webelement that was
found) accepted by Element, Elements, ElementMap that allows for waiting
for an element to become valid according to the response ofonly_if. The callable will be checked uptil the timeout parameter set
on the Element.v0.4.1Release Date: 2013-11-29Bug fix for config module being reused between test runs.v0.4Release Date: 2013-11-28Old style class names removed (Deprecated old class names)IntroducedFacetsIntroducedCucumber Featuresintegration withfresher.General refactoring and code cleanup.v0.3.4Release Date: 2013-11-21Added support to ignore ssl certificate errors on chrome, firefox & phantomjscode cleanupimproved test coveragev0.3.3Release Date: 2013-10-29Improved back reference access in Config object by allowing variable references
without requiring a prefix ofdefaultor the environment name. The resolution
order is current environment and then default.For example, the following config will resolvelogin_urlashttp://mysite.com/loginandprofile_urlashttp://mysite.com/profile/prod_userrespectively, whenholmium.environmentis set toproductionconfig={"default":{"login_url":"{{url}}/login","profile_url":"{{url}}/profiles/{{username}}"},"production":{"url":"http://mysite.com","username":"prod_user"}}v0.3.2Release Date: 2013-10-10Fluent response from page objects only when page method returns Nonev0.3.1Release Date: 2013-09-17Allow indexing of Sections objectsv0.3Release Date: 2013-09-16Bug Fix for instantiating multiple instances of the same the Page object
(https://github.com/alisaifee/holmium.core/issues/4)Section objectintroducedv0.2Release Date: 2013-09-11Deprecated old class names(PageObject, PageElement, PageElements, PageElementMap & HolmiumTestCase)Added more tests for holmium.core.TestCaseNewConfig object.v0.1.8.4Release Date: 2013-09-04Bug Fix : installation via pip was failing due to missing HISTORY.rst file.v0.1.8.3Release Date: 2013-08-12Bug fiximproved error handling and logging for missing/malformed config file.v0.1.8Release Date: 2013-03-18Added iphone/android/phantomjs to supported browsersBug fixfixed phantomjs build in travis