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)
- [Bug]: Last version 22.6.2 is not published on npm registry HOT 2
- [Bug]: Browser.close does not shutdown the process immediately HOT 16
- [Bug]: MaxListenersExceededWarning caused by process.on('exit') HOT 4
- [Feature]: ability to check and possibly installed missing system dependencies
- [Bug]: Alpine ProtocolError after Chrome 123.0.6312.86 Update HOT 16
- Locator API errors should include the stack trace pointing to the locator constructor
- [Bug]: Browser crashes when a navigational request is aborted using --single-process flag HOT 14
- [Bug]: Header/Footer placeholders stopped working HOT 3
- [Bug]: insecure download warning when downloading from pdf generator HOT 5
- [Bug]: the click() method does not navigate HOT 3
- [Bug]: --base-url option seems to be non-working
- "[cookies.spec] Cookie specs Page.setCookie should set secure same-site cookies from a frame" fails with enabled field testing trial
- [Bug]: build failure after deps update HOT 3
- [Bug]: Lost connection is not detected if no messages are being sent over WebSocket HOT 6
- [Bug]: Puppeteer click don't fail when actual element is overlapped HOT 5
- [Feature]: `@puppeteer/ng-schematics:builder` should support setting tsconfig.json, using path aliases, replacing environment.ts and not starting the dev-server HOT 2
- [Bug]: Request Interceptor weird behaviour HOT 4
- [Bug]: Unable to bundle puppeteer script with wepack HOT 2
- [Feature]: Inserting a Audio and video Stream HOT 2
- PDF export error for chart and HTM amchart5 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.