Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

change user agent in playwright

const {webkit} = require('playwright');
(async () => {
  const browser = await webkit.launch();
  // Create a new incognito browser context with a proper user agent
  const context = await browser.newContext({
    userAgent: 'my-user-agent'
  });
  // Now the page will have the user agent 
  const page = await context.newPage('https://example.com');
  console.log(await page.evaluate(() => navigator.userAgent));
})();
 
PREVIOUS NEXT
Tagged: #change #user #agent #playwright
ADD COMMENT
Topic
Name
5+8 =