Code Monkey home page Code Monkey logo

Comments (11)

konstunn avatar konstunn commented on May 15, 2024 4

Here is the code for chrome driver

from arsenic import services, browsers

service = services.Chromedriver(binary='chromedriver')

device_metrics = dict(width=1024, height=768, pixelRatio=1.0)

mobile_emulation = dict(deviceMetrics=device_metrics)

kwargs = {'goog:chromeOptions': dict(mobileEmulation=mobile_emulation)}

browser = browsers.Chrome(**kwargs)

async with get_session(service, browser) as session:
    await session.get('/')

from arsenic.

konstunn avatar konstunn commented on May 15, 2024 1

I have managed to do this. I will post here a piece of code demonstrating this soon.

from arsenic.

konstunn avatar konstunn commented on May 15, 2024 1

This is how I managed to succeed to run device emulation and headless mode

from arsenic import services, browsers

service = services.Chromedriver(binary='chromedriver')

device_metrics = dict(width=1024, height=768, pixelRatio=1.0)

mobile_emulation = dict(deviceMetrics=device_metrics)

kwargs = {'goog:chromeOptions': dict(mobileEmulation=mobile_emulation,
                                             args=['--headless', '--disable-gpu']
                                             )
                  }

browser = browsers.Chrome(
            **kwargs
)

async with get_session(service, browser) as session:
    await session.get('/')

from arsenic.

ojii avatar ojii commented on May 15, 2024

I have no experience with this, but a quick glance at the documentation of chromedriver on how to do this, you should be able to pass the emulation mode as desired capabilities when instantiating the browser.

from arsenic.

konstunn avatar konstunn commented on May 15, 2024

I suggest documenting this somewhere: FAQ, documentation, whatever.

Btw, we need such a strange kwarg as 'goog:chromeOptions' because mobileEmulation is considered as experimental capability, as far as I get it.

from arsenic.

konstunn avatar konstunn commented on May 15, 2024

I dont know why but now I can not manage to run chrome in headless mode. This is how I try to do this

from arsenic import services, browsers

service = services.Chromedriver(binary='chromedriver')

device_metrics = dict(width=1024, height=768, pixelRatio=1.0)

mobile_emulation = dict(deviceMetrics=device_metrics)

kwargs = {'goog:chromeOptions': dict(mobileEmulation=mobile_emulation)}

browser = browsers.Chrome(chromeOptions={'args': [
                '--headless',
                '--disable-gpu',
            ]},
            **kwargs
)

async with get_session(service, browser) as session:
    await session.get('/')

from arsenic.

dimaqq avatar dimaqq commented on May 15, 2024

Please add PR to document these recipes! πŸ™

from arsenic.

konstunn avatar konstunn commented on May 15, 2024

Where should we document it? Is README suitable enough for that?

from arsenic.

dimaqq avatar dimaqq commented on May 15, 2024

Documentation source code is here: https://github.com/HDE/arsenic/tree/main/docs
I guess either howto or possibly tutorial?

Docs are ultimately pushed to https://arsenic.readthedocs.io/en/latest/

from arsenic.

konstunn avatar konstunn commented on May 15, 2024

Here is the PR. Please have a look #110

I have added the two recipes to browser-specific section "Supported browsers".

from arsenic.

konstunn avatar konstunn commented on May 15, 2024

The pull request is merged so we might close the issue. Can we?

from arsenic.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.