How to use the splinter.driver.DriverAPI function in splinter

To help you get started, we’ve selected a few splinter examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cobrateam / splinter / splinter / driver / zopetestbrowser.py View on Github external
cookies[key] = value
        return cookies

    def __getitem__(self, item):
        return self.driver.cookies[item]

    def __contains__(self, key):
        return key in self.driver.cookies

    def __eq__(self, other_object):
        if isinstance(other_object, dict):
            return dict(self.driver.cookies) == other_object
        return False


class ZopeTestBrowser(ElementPresentMixIn, DriverAPI):

    driver_name = "zope.testbrowser"

    def __init__(self, wait_time=2):
        self.wait_time = wait_time
        self._browser = Browser()

        self._cookie_manager = CookieManager(self._browser)
        self._last_urls = []

    def __enter__(self):
        return self

    def __exit__(self, exc_type, exc_value, traceback):
        pass
github pytest-dev / pytest-splinter / tests / test_plugin.py View on Github external
def test_session_browser(session_browser):
    """Check the browser fixture."""
    assert isinstance(session_browser, DriverAPI)
github pytest-dev / pytest-splinter / tests / test_plugin.py View on Github external
def test_browser(browser):
    """Check the browser fixture."""
    assert isinstance(browser, DriverAPI)
github cobrateam / splinter / splinter / driver / webdriver / __init__.py View on Github external
if wait_time == 0:
        elem_list = _find(self, finder, selector)
    else:
        wait_time = wait_time or self.wait_time
        end_time = time.time() + wait_time

        while time.time() < end_time:
            elem_list = _find(self, finder, selector)

            if elem_list:
                break

    return ElementList(elem_list, find_by=find_by, query=query)


class BaseWebDriver(DriverAPI):
    driver = None
    find_by = find_by

    def __init__(self, wait_time=2):
        self.wait_time = wait_time
        self.ori_window_size = None

        self.links = FindLinks(self)

    def __enter__(self):
        return self

    def __exit__(self, exc_type, exc_value, traceback):
        self.quit()

    @property
github cobrateam / splinter / splinter / driver / spynner.py View on Github external
from splinter.driver import DriverAPI

class Spynner(DriverAPI):
    pass
github cobrateam / splinter / splinter / driver / chrome.py View on Github external
from selenium.chrome.webdriver import WebDriver as chrome_driver
from selenium.remote.errorhandler import InvalidElementStateException
from lxml.cssselect import CSSSelector
from splinter.driver import DriverAPI, ElementAPI


class WebDriver(DriverAPI):
    
    def __init__(self):
        self.driver = chrome_driver()

    @property
    def title(self):
        return self.driver.get_title()

    @property
    def html(self):
        return self.driver.get_page_source()

    @property
    def url(self):
        return self.driver.get_current_url()
github cobrateam / splinter / splinter / driver / lxmldriver.py View on Github external
import os.path
import re
import time
import sys

import lxml.etree
import lxml.html
from lxml.cssselect import CSSSelector
from splinter.driver import DriverAPI, ElementAPI
from splinter.driver.element_present import ElementPresentMixIn
from splinter.driver.xpath_utils import _concat_xpath_from_str
from splinter.element_list import ElementList
from splinter.exceptions import ElementDoesNotExist


class LxmlDriver(ElementPresentMixIn, DriverAPI):
    _response = ""
    _url = ""

    def __init__(self, user_agent=None, wait_time=2):
        self.wait_time = wait_time
        self._history = []
        self._last_urls = []
        self._forms = {}

    def __enter__(self):
        return self

    def __exit__(self, exc_type, exc_value, traceback):
        pass

    def _do_method(self, action, url, data=None):
github cobrateam / splinter / splinter / driver / webdriver / __init__.py View on Github external
# -*- coding: utf-8 -*-
import logging
import subprocess
import time
from contextlib import contextmanager

from lxml.cssselect import CSSSelector
from selenium.common.exceptions import NoSuchElementException

from splinter.driver import DriverAPI, ElementAPI
from splinter.element_list import ElementList
from splinter.utils import warn_deprecated
from tempfile import TemporaryFile


class BaseWebDriver(DriverAPI):
    old_popen = subprocess.Popen

    def __init__(self, wait_time=2):
        self.wait_time = wait_time

    def _patch_subprocess(self):
        loggers_to_silence = [
            'selenium.webdriver.firefox.extension_connection',
            'selenium.webdriver.remote.remote_connection',
            'selenium.webdriver.remote.utils',
        ]

        class MutedHandler(logging.Handler):
            pass

        for name in loggers_to_silence: