How to use the splinter.driver.webdriver.WebDriverElement 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 gratipay / gratipay.com / gratipay / testing / browser.py View on Github external
_browser = None


class NeverLeft(Exception): pass
class NeverShowedUp(Exception): pass


# Monkey-patch .click to work around stackoverflow.com/q/11908249
def monkey_click(self):
    try:
        self._element.click()                   # Firefox 55
    except WebDriverException as exc:
        if not exc.msg.startswith('unknown error: Element is not clickable'):
            raise
        self._element.send_keys(Keys.RETURN)    # Chrome 60
WebDriverElement.click = monkey_click


class BrowserHarness(Harness):
    """This is a harness for through-the-web (TTW) testing. It passes
    everything through to an underlying `Splinter`_ browser, with the following
    exceptions:

    .. _Splinter: http://splinter.readthedocs.io/en/latest/

    """

    _browser = None
    use_VCR = False  # without this we get fixture spam from communication with PhantomJS
    base_url = os.environ['WEBDRIVER_BASE_URL']

    @classmethod
github okfn-brasil / open-jus / justa / crawler / justa / spiders / __init__.py View on Github external
def __init__(self, *args, **kwargs):
        super(RemoteWebDriver, self).__init__(*args, **kwargs)
        self.element_class = WebDriverElement  # overrides the element class
github ggozad / behaving / src / behaving / web / chrome.py View on Github external
options.add_argument("--user-agent=" + user_agent)

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

        prefs = {"download": {
            "default_directory": _DOWNLOAD_PATH,
            "directory_upgrade": True,
            "extensions_to_open": ""
        }}

        options.add_experimental_option("prefs", prefs)

        self.driver = Chrome(chrome_options=options, **kwargs)

        self.element_class = WebDriverElement

        self._cookie_manager = CookieManager(self.driver)

        super(WebDriver, self).__init__(wait_time)
github cobrateam / splinter / splinter / driver / webdriver / firefox.py View on Github external
if incognito:
            firefox_options.add_argument("-private")

        self.driver = Firefox(
            firefox_profile,
            capabilities=firefox_capabilities,
            options=firefox_options,
            timeout=timeout,
            **kwargs
        )

        if fullscreen:
            ActionChains(self.driver).send_keys(Keys.F11).perform()

        self.element_class = WebDriverElement

        self._cookie_manager = CookieManager(self.driver)

        super(WebDriver, self).__init__(wait_time)
github omaciel / websmith / websmith / ui.py View on Github external
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)
github ggozad / behaving / src / behaving / web / cordova.py View on Github external
if fullscreen:
            options.add_argument('--kiosk')

        options.add_argument('-F')
        options.add_argument('--args')
        options.add_argument('--disable-web-security')
        if persistent_session:
            options.add_argument('--user-data-dir=/tmp/temp_chrome_user_data_dir_for_cordova_browser')
        else:
            options.add_argument('--incognito')

        dc = DesiredCapabilities.CHROME
        dc['loggingPrefs'] = {'browser': 'ALL'}

        self.driver = Chrome(chrome_options=options, desired_capabilities=dc, **kwargs)
        self.element_class = WebDriverElement

        self._cookie_manager = CookieManager(self.driver)

        super(CordovaWebDriver, self).__init__(wait_time)
github cobrateam / splinter / splinter / driver / webdriver / phantomjs.py View on Github external
from selenium.webdriver import PhantomJS, DesiredCapabilities
from splinter.driver.webdriver import (BaseWebDriver,
                                       WebDriverElement as BaseWebDriverElement)
from splinter.driver.webdriver.cookie_manager import CookieManager


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
github cobrateam / splinter / splinter / driver / webdriver / remote.py View on Github external
browser_name = browser.upper()
        # Handle case where user specifies IE with a space in it
        if browser_name == "INTERNET EXPLORER":
            browser_name = "INTERNETEXPLORER"

        # If no desired capabilities specified, add default ones
        caps = getattr(DesiredCapabilities, browser_name, {})
        if kwargs.get('desired_capabilities'):
            # Combine user's desired capabilities with default
            caps.update(kwargs['desired_capabilities'])

        kwargs['desired_capabilities'] = caps

        self.driver = Remote(command_executor, **kwargs)

        self.element_class = WebDriverElement

        self._cookie_manager = CookieManager(self.driver)

        super(WebDriver, self).__init__(wait_time)
github ggozad / behaving / src / behaving / web / firefox.py View on Github external
user_agent)

        if profile_preferences:
            for key, value in profile_preferences.items():
                firefox_profile.set_preference(key, value)

        if extensions:
            for extension in extensions:
                firefox_profile.add_extension(extension)

        self.driver = Firefox(firefox_profile)

        if fullscreen:
            ActionChains(self.driver).send_keys(Keys.F11).perform()

        self.element_class = WebDriverElement

        self._cookie_manager = CookieManager(self.driver)

        super(WebDriver, self).__init__(wait_time)
github cobrateam / splinter / splinter / driver / webdriver / chrome.py View on Github external
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)

        self.element_class = WebDriverElement

        self._cookie_manager = CookieManager(self.driver)

        super(WebDriver, self).__init__(wait_time)