How to use the splinter.driver.webdriver.BaseWebDriver 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 omaciel / websmith / websmith / ui.py View on Github external
"""Browser and UI Elements."""
from splinter.driver.webdriver import BaseWebDriver, WebDriverElement
from splinter.driver.webdriver.cookie_manager import CookieManager

from websmith.actions import Action


class WebDriver(BaseWebDriver):
    """Wrapper for Splinter BaseWebDriver that accepts a real Selenium
    webdriver instance.
    """
    def __init__(self, browser, wait_time=2):
        self.driver = browser
        self.element_class = WebDriverElement
        self._cookie_manager = CookieManager(self.driver)
        super(WebDriver, self).__init__(wait_time)


class Session(object):
    """A convenient object for working with Web UI elements."""

    def __init__(self, browser):
        """Base client for handling web ui elements."""
        self.browser = WebDriver(browser)
github ggozad / behaving / src / behaving / mobile / android.py View on Github external
import time
import os
import xml.dom.minidom

from appium import webdriver
from splinter.driver.webdriver import BaseWebDriver
from splinter.element_list import ElementList
from selenium.common.exceptions import WebDriverException, StaleElementReferenceException
from splinter.browser import _DRIVERS


class AndroidWebDriver(BaseWebDriver):

    driver_name = "android"

    def __init__(self,
                 app_path,
                 appium_url='http://127.0.0.1:4723/wd/hub',
                 wait_time=2,
                 caps={},
                 **kwargs):

        self.app_path = app_path
        desired_capabilities = {
            'app': os.path.expanduser(app_path),
            'platformName': 'Android',
            'automationName': 'appium',
            'noReset': True,
github ggozad / behaving / src / behaving / web / cordova.py View on Github external
from selenium.webdriver import Chrome
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from splinter.driver.webdriver import BaseWebDriver, WebDriverElement
from splinter.driver.webdriver.cookie_manager import CookieManager


class CordovaWebDriver(BaseWebDriver):

    driver_name = "Cordova"

    def __init__(self, user_agent=None,
                 wait_time=2,
                 fullscreen=False,
                 persistent_session=False,
                 **kwargs):
        options = Options()

        if user_agent is not None:
            options.add_argument("--user-agent=" + user_agent)

        if fullscreen:
            options.add_argument('--kiosk')
github cobrateam / splinter / splinter / driver / webdriver / remote.py View on Github external
from selenium.webdriver import Remote
from selenium.webdriver.remote import remote_connection
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from splinter.driver.webdriver import (
    BaseWebDriver,
    WebDriverElement,
)
from splinter.driver.webdriver.cookie_manager import CookieManager
from splinter.driver.webdriver.remote_connection import patch_request

# MonkeyPatch RemoteConnection
remote_connection.RemoteConnection._request = patch_request


class WebDriver(BaseWebDriver):

    driver_name = "remote"
    # TODO: This constant belongs in selenium.webdriver.Remote
    DEFAULT_URL = "http://127.0.0.1:4444/wd/hub"

    def __init__(
        self,
        browser="firefox",
        wait_time=2,
        command_executor=DEFAULT_URL,
        **kwargs
    ):
        browser_name = browser.upper()
        # Handle case where user specifies IE with a space in it
        if browser_name == "INTERNET EXPLORER":
            browser_name = "INTERNETEXPLORER"
github cobrateam / splinter / splinter / driver / webdriver / chrome.py View on Github external
# -*- coding: utf-8 -*-

# Copyright 2012 splinter authors. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.

from selenium.webdriver import Chrome
from selenium.webdriver.chrome.options import Options
from splinter.driver.webdriver import BaseWebDriver, WebDriverElement
from splinter.driver.webdriver.cookie_manager import CookieManager


class WebDriver(BaseWebDriver):

    driver_name = "Chrome"

    def __init__(self, user_agent=None, wait_time=2, fullscreen=False,
                 **kwargs):

        options = Options()

        if user_agent is not None:
            options.add_argument("--user-agent=" + user_agent)

        if fullscreen:
            options.add_argument('--kiosk')

        self.driver = Chrome(chrome_options=options, **kwargs)
github cobrateam / splinter / splinter / driver / webdriver / phantomjs.py View on Github external
class WebDriverElement(BaseWebDriverElement):
    def mouse_out(self):
        raise NotImplementedError('Not supported by phantomjs webdriver.')

    def mouse_over(self):
        raise NotImplementedError('Not supported by phantomjs webdriver.')

    def right_click(self):
        raise NotImplementedError('Not supported by webdriver.')

    def double_click(self):
        raise NotImplementedError('Not supported by webdriver.')


class WebDriver(BaseWebDriver):
    driver_name = "PhantomJS"
    element_class = WebDriverElement

    def __init__(self, user_agent=None, load_images=True,
                 desired_capabilities=None, wait_time=2,
                 custom_headers={}, **kwargs):
        capabilities = DesiredCapabilities.PHANTOMJS.copy()
        if user_agent is not None:
            capabilities['phantomjs.page.settings.userAgent'] = user_agent
        capabilities['phantomjs.page.settings.loadImages'] = load_images
        if isinstance(custom_headers, dict):
            for name, value in custom_headers.items():
                capabilities['phantomjs.page.customHeaders.%s' % name] = value
        if desired_capabilities:
            capabilities.update(desired_capabilities)
github ggozad / behaving / src / behaving / mobile / ios.py View on Github external
import time
import os
import xml.dom.minidom

from appium import webdriver
from splinter.driver.webdriver import BaseWebDriver
from splinter.element_list import ElementList
from selenium.common.exceptions import WebDriverException
from splinter.browser import _DRIVERS


class IOSWebDriver(BaseWebDriver):

    driver_name = "ios"

    def __init__(self,
                 app_path,
                 appium_url='http://127.0.0.1:4723/wd/hub',
                 wait_time=2,
                 caps={},
                 **kwargs):

        self.app_path = app_path
        desired_capabilities = {
            'app': os.path.expanduser(app_path),
            'platformName': 'iOS',
            'platformVersion': '13.2',
            'deviceName': 'iPhone SE',
github ggozad / behaving / src / behaving / web / chrome.py View on Github external
# -*- coding: utf-8 -*-

from selenium.webdriver import Chrome
from selenium.webdriver.chrome.options import Options
from splinter.driver.webdriver import BaseWebDriver, WebDriverElement
from splinter.driver.webdriver.cookie_manager import CookieManager

_DOWNLOAD_PATH = '/tmp'


class WebDriver(BaseWebDriver):

    driver_name = "Chrome"

    def __init__(self, user_agent=None, wait_time=2, fullscreen=False,
                 options=None, **kwargs):

        options = Options() if options is None else options

        if user_agent is not None:
            options.add_argument("--user-agent=" + user_agent)

        if fullscreen:
            options.add_argument('--kiosk')

        prefs = {"download": {
            "default_directory": _DOWNLOAD_PATH,
github cobrateam / splinter / splinter / driver / webdriver / firefox.py View on Github external
import six

from selenium.webdriver import DesiredCapabilities, Firefox
from selenium.webdriver.firefox.firefox_profile import FirefoxProfile
from splinter.driver.webdriver import (
    BaseWebDriver,
    WebDriverElement as WebDriverElement,
)
from splinter.driver.webdriver.cookie_manager import CookieManager
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
from selenium.webdriver.firefox.options import Options


class WebDriver(BaseWebDriver):

    driver_name = "Firefox"

    def __init__(
        self,
        profile=None,
        extensions=None,
        user_agent=None,
        profile_preferences=None,
        fullscreen=False,
        wait_time=2,
        timeout=90,
        capabilities=None,
        headless=False,
        incognito=False,
        **kwargs
github ggozad / behaving / src / behaving / web / firefox.py View on Github external
import mimetypes

from selenium.webdriver import Firefox
from selenium.webdriver.firefox.firefox_profile import FirefoxProfile
from splinter.driver.webdriver import (BaseWebDriver, WebDriverElement as
                                       WebDriverElement)
from splinter.driver.webdriver.cookie_manager import CookieManager
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains

_DOWNLOAD_PATH = '/tmp'
_ALL_MIME_TYPES = ','.join(mimetypes.types_map.values())


class WebDriver(BaseWebDriver):

    driver_name = "Firefox"

    def __init__(self,
                 profile=None,
                 extensions=None,
                 user_agent=None,
                 profile_preferences=None,
                 fullscreen=False,
                 wait_time=2):

        firefox_profile = FirefoxProfile(profile)
        firefox_profile.set_preference('extensions.logging.enabled', False)
        firefox_profile.set_preference('network.dns.disableIPv6', False)

        firefox_profile.set_preference("browser.download.folderList", 2)