Comments (5)
@paulirish @pavelfeldman guys, guys. WDYT?
from puppeteer.
Not sure if this makes things any better. Today, device is a pair or {viewport, userAgent}. It seems that the only change that you suggest is merging them into a single device entity and introducing a new emulateDevice
method? Although that is fine with me, it makes UA emulation redundant (you already have specific methods for UA emulation). Looks like super-minor sugar overall. Today you can do:
// If needed, a hand-made device could be done
let device = {
width: 100,
height: 100,
deviceScaleFactor: 2
});
page.setViewport(device);
// When I want UA,
page.setUserAgent(deviceUserAgent);
from puppeteer.
It seems that the only change that you suggest is merging them into a single device entity and introducing a new emulateDevice method?
That's right. Here's a summary of the changes:
- make
page.emulateDevice(deviceConfig)
instead ofpage.emulate(deviceName)
so that there's a single entry point for device emulation - make
page.setOrientation
method so that orientation is not a part of a viewport - expose pre-built devices as structs in the top-level require to make it simple to inspect devices and their emulation configs
Although that is fine with me, it makes UA emulation redundant (you already have specific methods for UA emulation).
It's still nice to have both setUserAgent
and setViewport
methods - they might come handy at times. However, I think that a lot of times those who use page.setUserAgent
or page.setViewport
would rather emulate some device.
from puppeteer.
const samsungDevices = requires(./sd);
const devices = require(puppeteer/DeviceDescriptors);
await page.emulateDevice(samsungDevices['GSIII_landscape']);
await page.setViewport(device.viewport);
await page.setUserAgent(device.ua));
from puppeteer.
With the last patch, everything we've discussed is done. There's no page.emulateDevice
for now, instead it's suggested to use setViewport
/ setUserAgent
methods explicitly.
I've updated the doc to explain about emulation: emulation
from puppeteer.
Related Issues (20)
- [Feature]: Puppeteer detection HOT 1
- How can I capture event in browser (include web page and browser UI (close/open tab, click extension, click setting ...) HOT 2
- Console does not work on addEventListener
- [Bug]: x1.5 CPU usage increase using Puppeteer between 20.8.3 to 20.9.0+ HOT 12
- [Bug]: image is cutting during screenshot HOT 2
- [Bug]: smoke tests fail
- [Bug]: Download PDF example not working HOT 2
- [Bug]: Not able to download pdf in the live/dev environment, works in local HOT 2
- Disregard HOT 1
- [Bug]: Whenever puppeteer is started, chrome takes up a lot of memory HOT 4
- [Docs]: Emphasize standard usage vs deprecated in documentation + Usage examples
- [Bug]: Chromium latest build seem to be broken on Mac with Intel processors HOT 5
- Unauthorized script addition HOT 1
- [Bug]: exposedFunction called multiple times (per frame), instead of once HOT 1
- Set up benchmark tests in CI
- [Bug]: New XPath error on new latest v22.10.1 HOT 4
- [Question]: Can we call start/stop recorder in Chrome-Devtools by puppeteer? And how to make it. HOT 2
- [Bug]: on Almalinux 8 (Namecheap) missing libatk-bridge-2.0.so.0 libdrm.so.2 libgbm.so.1libasound.so.2 even if they have been installed! HOT 3
- [Bug]: Breaking change v22.11.0 require GLIBC2.25 HOT 2
- [Bug]: remove request listener and then the page can do nothing HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from puppeteer.