Exemplo n.º 1
0
async def open_driver(proxy=None):
    chromeOptions = {
        "args": [
            "enable-automation",
            "--headless",
            "--disable-gpu",
            "--no-sandbox",
            "--disable-infobars",
            "--disable-dev-shm-usage",
            "--disable-browser-side-navigation",
        ]
    }
    if proxy and False:
        # TODO arsenic proxy?
        prox = Proxy()
        prox.proxy_type = ProxyType.MANUAL
        prox.http_proxy = proxy
        prox.socks_proxy = proxy
        prox.ssl_proxy = proxy

        prox.add_to_capabilities(capabilities)

    if "SELENIUM_URL" in os.environ:
        driver = await start_session(
            services.Remote(os.getenv("SELENIUM_URL")),
            browsers.Chrome(chromeOptions=chromeOptions),
        )
    else:
        driver = await start_session(
            services.Chromedriver(),
            browsers.Chrome(chromeOptions=chromeOptions))
    return driver
Exemplo n.º 2
0
async def get_remote_session(root_url: str):
    if "REMOTE_BROWSER" not in os.environ:
        raise pytest.skip("No remote browser configured (REMOTE_BROWSER)")
    if "REMOTE_SERVICE" not in os.environ:
        raise pytest.skip("No remote service configured (REMOTE_SERVICE)")
    if "BROWSERSTACK_API_KEY" not in os.environ:
        raise pytest.skip(
            "No browserstack api key configured (BROWSERSTACK_API_KEY)")
    remote_browser = json.loads(os.environ["REMOTE_BROWSER"])
    browser_cls = getattr(browsers, remote_browser["browserName"])
    with bsl_context():
        async with get_session(
                services.Remote(url=os.environ["REMOTE_SERVICE"]),
                browser_cls(**remote_browser),
                root_url,
        ) as session:
            yield session
Exemplo n.º 3
0
async def get_remote_session(root_url: str):
    if "REMOTE_BROWSER" not in os.environ:
        raise pytest.skip("No remote browser configured (REMOTE_BROWSER)")
    if "REMOTE_SERVICE" not in os.environ:
        raise pytest.skip("No remote service configured (REMOTE_SERVICE)")
    if "BROWSERSTACK_API_KEY" in os.environ:
        context = bsl_context
    else:
        context = null_context
    remote_browser = json.loads(os.environ["REMOTE_BROWSER"])
    browser_cls = getattr(browsers, remote_browser.pop("type"))
    with context():
        async with get_session(
                services.Remote(url=os.environ["REMOTE_SERVICE"]),
                browser_cls(**remote_browser),
                root_url,
        ) as session:
            yield session