Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: When using robotframework browserlibrary, "useragent" passed is not honored when using "webkit" browser #29629

Closed
srajendran123 opened this issue Feb 22, 2024 · 5 comments

Comments

@srajendran123
Copy link

Version

NodeJS version: v18.17.1

Steps to reproduce

Desktop (please complete the following information):
robotframework==6.1.1
robotframework-browser: 17.3.0
Browser: Webkit
NodeJS version: v18.17.1
npm version: 9.6.7

Steps to reproduce:
Invoke any url using browserlibrary from robotframework. Used the following code to invoke the app

New Persistent Context url=${url} browser=${execution_browser} userAgent=${userAgent} viewport=${viewport}

url - "https://pwa-br-us-a.qa.tillster.com/"
browser - "webkit"
user agent - Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.0 Safari/605.1.15
viewport - "{'width': 810, 'height': 1010}"

Issue:

When "webkit" is used, user agent provided in the script is not used when loading the application.

image

In the screenshot, mac useragent "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.0 Safari/605.1.15" is provided in the script . However, the application is loaded with Windows user agent, as the test is run on windows machine.

This is not an issue when using "chromium" browser. App is loaded with whatever useragent passed in the automation script.

Please let me know, if additional info is needed.

chromium.webm.zip
webkit.webm.zip

Expected behavior

In the screenshot above, mac useragent "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.0 Safari/605.1.15" is provided in the script . Expected to see the same useragent for loading the app.

Actual behavior

In the screenshot, mac useragent "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.0 Safari/605.1.15" is provided in the script . However, the application is loaded with Windows user agent, as the test is run on windows machine.

Additional context

I opened a bug to Robotframework-browser support team and they suggested to open a ticket to playwright, as browser library passes that value to playwright without altering it.

MarketSquare/robotframework-browser#3383

Environment

System:
    OS: macOS 12.6.2
    CPU: (10) arm64 Apple M1 Max
    Memory: 143.58 MB / 32.00 GB
  Binaries:
    Node: 18.17.1 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 9.6.7 - /usr/local/bin/npm
  Languages:
    Bash: 3.2.57 - /bin/bash
@yury-s
Copy link
Member

yury-s commented Feb 23, 2024

I opened a bug to Robotframework-browser support team and they suggested to open a ticket to playwright, as browser library passes that value to playwright without altering it.

Can you / they provide a playwright example that we could run locally to reproduce the issue?

@srajendran123
Copy link
Author

srajendran123 commented Feb 23, 2024

@yury-s I wish I could help, but I am unfamiliar with using playwright. By passing a user agent, loading any url on webkit browser should reproduce the issue.

I am using the following code on the robotframework to reproduce the issue:

*** Settings ***
Library Browser

*** Keywords ***
load_the_application_on_non_incognito_mode
New Persistent Context url=https://pwa-br-us-a.qa.tillster.com/ browser=webkit useragent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.0 Safari/605.1.15

load_the_application_on_incognito_mode
new browser browser=webkit headless=False
new context userAgent='Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.0 Safari/605.1.15'
New Page url=https://pwa-br-us-a.qa.tillster.com/

In playwright, I think we could try the following code:

const { webkit } = require('playwright');
 
(async () => {
  // Launch the Webkit browser
  const browser = await webkit.launch();
 
  const context = await browser.newContext({
    userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.0 Safari/605.1.15',
  });
  
  // Create a new page in the browser context and navigate to target URL
  const page = await context.newPage();
  await page.goto('https://httpbin.io/user-agent');    
  
  // Get the entire page content
  const pageContent = await page.content();
  console.log(pageContent);
 
  // Close the browser
  await browser.close();
})();

Please let me know, if any other info is needed. Thanks.

@yury-s
Copy link
Member

yury-s commented Feb 26, 2024

I cannot reproduce it with the example you provided, so there must be something else. Make sure the framework is running latest playwright (1.41.2 currently). Unfortunately, we cannot act on this without a reproduction.

@srajendran123
Copy link
Author

Hello @yury-s

We just install NodeJs and don’t install playwright explicitly to use BrowserLibrary in our test automation framework.

Yury/Tato – Any advice on how to proceed with MarketSquare/robotframework-browser#3383
and #29629?

@yury-s
Copy link
Member

yury-s commented Feb 26, 2024

Yury/Tato – Any advice on how to proceed with MarketSquare/robotframework-browser#3383
and #29629?

As I mentioned above we'll need a reproduction example with playwright that we could run locally. The basic example you pasted above works just fine. So I'd assume that it might be a bug in some old version of playwright or something on the way those parameters are passed to playwright, but this is all speculation. I'm closing this bug as we cannot act on it, but feel free to open a new one and attach a playwright example where the problem appears.

@yury-s yury-s closed this as completed Feb 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants