How to use the splinter.browser.Browser 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 / tests / unit / test_api_browser.py View on Github external
def test_quit(self):
        "Browser.quit should call driver.quit"
        with Mock() as mock:
            mock.quit()
        with Stub() as browser:
            from splinter.driver import WebDriver
            WebDriver() >> mock
        browser = Browser()
        browser.quit()

        WebDriver.restore_import()
        mock.validate()
github nlhkabu / connect / bdd_tests / features / environment.py View on Github external
def before_all(context):
    context.browser = Browser()
github edx / js-test-tool / js_test_tool / browser.py View on Github external
http://splinter.cobrateam.info/docs/

        `timeout_sec` is the amount of time to wait for the DOM
        to load.  It could take a long time, so default to a high
        value.
        """
        if timeout_sec is None:
            timeout_sec = self.DEFAULT_TIMEOUT

        # Store the browser name
        self._name = browser_name
        self._timeout_sec = timeout_sec

        # Create a browser session
        try:
            self._splinter_browser = SplinterBrowser(browser_name)
        except:
            if browser_name == 'chrome':
                msg = ' '.join(['Could not create a browser instance.',
                                'Make sure you have both ChromeDriver and Chrome installed.',
                                'See http://splinter.cobrateam.info/docs/drivers/chrome.html'])
            else:
                msg = 'Could not create a {} browser instance.  Is this browser installed?'.format(browser_name)
            raise BrowserError(msg)
github nlhkabu / connect / bdd / features / environment.py View on Github external
def before_all(context):

    #Unless specified, set our default browser to PhantomJS
    if context.config.browser:
        context.browser = Browser(context.config.browser)
    else:
        context.browser = Browser('phantomjs')

    # When we're running with PhantomJS we need to specify the window size.
    # This is a workaround for an issue where PhantomJS cannot find elements
    # by text - see: https://github.com/angular/protractor/issues/585
    if context.browser.driver_name == 'PhantomJS':
        context.browser.driver.set_window_size(1280, 1024)
github shootthepoets / Douyin-Watermark-Free-Batch-Downloader / douyin_downloader.py View on Github external
def __init__(self, width=500, height=300):
        """
        抖音App视频下载
        """
        # 无头浏览器
        chrome_options = Options()
        chrome_options.add_argument(
            'user-agent="Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36"'
        )
        self.driver = Browser(
            driver_name="chrome", options=chrome_options, headless=True
        )
github nsi-iff / nsi_site / terrain.py View on Github external
@before.all
def set_browser():
    world.browser = Browser()
github ggozad / behaving / src / behaving / web / steps / browser.py View on Github external
return
    if name not in context.browsers:
        args = context.browser_args.copy()
        if context.remote_webdriver:
            args['driver_name'] = 'remote'
            if context.default_browser:
                args['browser'] = context.default_browser
        elif context.default_browser:
            args['driver_name'] = context.default_browser
        if context.default_browser == 'electron':
            assert context.electron_app, u'You need to set the electron app path'
            args['binary'] = context.electron_app
        browser_attempts = 0
        while browser_attempts < context.max_browser_attempts:
            try:
                context.browsers[name] = Browser(**args)
                break
            except WebDriverException:
                browser_attempts += 1
        else:
            raise WebDriverException("Failed to initialize browser")
    context.browser = context.browsers[name]
    if single_browser:
        context.is_connected = True
    if context.default_browser_size:
        context.browser.driver.set_window_size(*context.default_browser_size)
github TimBest / django-multi-form-view / features / environment.py View on Github external
def before_all(context):
    context.browser = Browser('chrome')
github mollyproject / mollyproject / molly / ui / bootstrap / features / terrain.py View on Github external
def initial_setup():
    world.browser = Browser('webdriver.firefox')
    
    def get_container():
        return world.browser.find_by_id('body').first
    world.container = get_container