This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

selenium-smart-locator

Class encapsulating generating of the Selenium locators.

It is designed to be simple and intuitive to use. It provides you various ways how to generate a Selenium-compatible locators. The class is usable in Selenium element queries.

loc = Locator(By.XPATH, '//foo/bar/baz')    # Old selenium way of doing it
element = s.find_element(*loc)              # Expand the tuple. That's how to use the class.

This is a basic sample of how does it work. Now come the usage samples of simplified locators:

# When you use this simple format of CSS consisting of tag name, ids and classes, it gets
# detected automatically and the result is a CSS selector. IDs and classes are optional.
Locator('div#foo.bar.baz')  # => Locator(by='css selector', locator='div#foo.bar.baz')
# When you specify a plain string and it does not get matched be the preceeding CSS detector
# it is assumed it is an XPath expression
Locator('//h1') # => Locator(by='xpath', locator='//h1')
# If you pass a Locator instance, it just goes straight through
Locator(Locator('//h1')) # => Locator(by='xpath', locator='//h1')
# If you have your own object, that implements __locator__(), then it can also be resolved
# by the class. The __locator__() must either return Locator instance or
# anything that Locator can process.
Locator(my_obj)
# You can leverage kwargs to say strategy=locator
Locator(xpath='//h1')   # => Locator(by='xpath', locator='//h1')
Locator(css='#something')   # => Locator(by='css selector', locator='#something')
Locator(by='xpath', locator='//h1')   # => Locator(by='xpath', locator='//h1')
# For your comfort, you can pass a dictionary, like it was kwargs
Locator({'by': 'xpath', 'locator': '//h1'})   # => Locator(by='xpath', locator='//h1')
# You can also use Locator's classmethods, like this:
Locator.by_css('#foo')   # => Locator(by='css selector', locator='#foo')
# Always in format Locator.by_<strategy_name>

When you have locators, you can avoid using * by using convenience methods:

l = Locator('#foo')
browser = Firefox()
element = l.find_element(browser)
elements = l.find_elements(browser)

As you can see, the number of ways how to specify the input parameters offer you a great freedom on how do you want to structure your locators. You can store them in YAML and you can use Locator to parse the entries. Or anything else.

Available selector strategies:

  • class_name
  • css
  • id
  • link_text
  • name
  • partial_link_text
  • tag
  • xpath

License

Licensed under GPLv3

Release History

Release History

0.1.1

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
selenium-smart-locator-0.1.1.tar.gz (19.0 kB) Copy SHA256 Checksum SHA256 Source May 20, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting