Skip to main content

A lightweight wrapper around Selenium python repo.

Project description

A lightweight wrapper around Selenium Python.
It's a simple extension to standard Selenium. The Philosophy is "don't reinvent a wheel and use standard Selenium, when it works and fix it, when Selenium annoys, mainly with waits and NoSuchElement exception".

Short Features Overview:

  • It is easy integrated with your existing Selenium code and
  • It is compatible with any standard Selenium methods.
    For instance:
# Your Selenium code
browser = webdriver.Chrome()
browser.get("https://www.seleniumhq.org/")

# with `selen-kaa`
from se_wrapper.browser_driver import BrowserDriver

browser = BrowserDriver(webdriver.Chrome())
browser.get("https://www.seleniumhq.org/")
  • Besides standard Selenium, selen-kaa introduces more convenient way to interact with a web page and web elements through init_web_element() and init_web_elements(): you can freely create the web element in __init__(), as the WebDriver would search this element only at the time of interaction with it:
browser = BrowserDriver(webdriver.Chrome())

class MyPage:

    def __init__():
        # lazy creation of a web element
        self.element1 = browser.init_web_element("#test")
    
page = MyPage()
# even if `self.element1` has not been rendered yet on the web page, 
# it's safe, you would have no NoSuchElementException
page.element1.click() # only here the WebDriver would `find_element`

init_web_element() returns a wrapper around Selenium WebElement, what has all standard WebElement's methods, but have two main advantages:

  1. Wrapped WebElement is going to be searched only when any method is called on it (as shown above).
  2. It has its own waits methods:
element1 = browser.init_web_element("#test")
element1.should.be_visible(timeout=4) # wait 4 seconds for element to be visible
  • selen-kaa is basically about next logic:
  1. It has BrowserDriver, which allows to use all standard Selenium methods and attributes to the WebDriver, but has additional logic for init_web_element() and init_web_element().
  2. init_web_element returns SeWebElement object, which has attributes of standard WebElement but with additional logic of lazy initialization, custom waits and conditions.
  3. init_web_element() returns SeElementsArray - a collection of SeWebElement objects with the same lazy initialization logic.
  • This library is highly customisable for extensions:
class MyElementWrapper(SeWebElement):
    pass
    
class MyElementsArray(SeElementsArray):
    pass

class Config(WebDriverConfig):

    WrappedElementType = MyElementWrapper
    WrappedElementArrayType = MyElementsArray
    DEFAULT_TIMEOUT = DEFAULT_TIMEOUT


class MyDriverWrapper(BrowserDriver):

    def __init__(self, webdriver):
        super().__init__(webdriver)
        self.config = Config()

So, you can add your own methods to selen-kaa main classes.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

selen-kaa-0.0.2.tar.gz (10.6 kB view details)

Uploaded Source

File details

Details for the file selen-kaa-0.0.2.tar.gz.

File metadata

  • Download URL: selen-kaa-0.0.2.tar.gz
  • Upload date:
  • Size: 10.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/2.7.15+

File hashes

Hashes for selen-kaa-0.0.2.tar.gz
Algorithm Hash digest
SHA256 331774402b1df72e3d0d356f3b5ece940b04c91cc54e013853cbcf6da4648395
MD5 20daef4d5dfe24c357da5a70d34c9a3d
BLAKE2b-256 ab74c96915833719532c25d9fccb8874b35b8ffe15050faf083e52345f012ec7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page