robotframework-browser icon indicating copy to clipboard operation
robotframework-browser copied to clipboard

"useragent" passed is not honored when using "webkit" browser.

Open srajendran123 opened this issue 1 year ago • 10 comments

Describe the bug user-agent passed file is not honored when using WebKit. Rather, the system config where the test runs is passed as the user agent.

To Reproduce Steps to reproduce the behavior:

  1. Through automation load any url using "New Persistent Context" or with a combination of New Browser/New Context/New Page) keyword with the following parameters: 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}"

Actual behavior Observe that user-agent passed is not honored when using WebKit. Rather, the system config where the test runs is passed as the user agent.

Screenshots chromium.webm.zip webkit.webm.zip

Desktop (please complete the following information): OS: Windows Browser: Webkit through automation Version: Playwright version 1.0 [1]

Additional context When loading a webpage using chromium or firefox without user agent, none is passed to user agent as expected. However, same issue as described exists when using webkit, system config where the test runs is passed as the user agent.

srajendran123 avatar Jan 19 '24 20:01 srajendran123

@aaltat - Just wondering, if there any update on this ticket? Thanks.

srajendran123 avatar Jan 25 '24 19:01 srajendran123

Not yet, https://robocon.io/ is near and it’s eating all available time

aaltat avatar Jan 26 '24 09:01 aaltat

I do not quite follow what you did expect to happen, but you can change user agent as you want in New Context keyword userAgent argument. I did check code and we should not set user agent inside of our code. So either it is done by Playwright or by the browser binaries itself. But in any case user agent is easy to change as you want.

aaltat avatar Feb 16 '24 22:02 aaltat

@aaltat When "webkit" is used, user agent provided in the script is not used when loading the application. Please refer to the attached webkit zip file above.

image

In the screenshot, mac useragent is provided in the script "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" . However, 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 refer to the attached windows zip file above.

Please let me know, if additional info is needed.

srajendran123 avatar Feb 16 '24 23:02 srajendran123

Here is the code, we are using to invoke the app

New Persistent Context url=${url} browser=${execution_browser} headless=${headless} 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}"

srajendran123 avatar Feb 16 '24 23:02 srajendran123

Browser library doesn’t not alter the parameter, we pass it as is in the Playwright side. This is a bug in the upstream side, meaning Playwright or Apple. Also we can’t fix this in the Browser library side.

You need to raise the issue with Playwright and in the worst case to Apple. But because we can’t fix this, I am going to close this issue.

aaltat avatar Feb 17 '24 13:02 aaltat

Hi Rene,

Can we please get an update on this ticket?

Thanks,

Sharmila

srajendran123 avatar Mar 19 '24 16:03 srajendran123

No updates, no-one has not looked at the problem. If have a need, easiest way is to debug the issue by you and provide the fix.

aaltat avatar Mar 19 '24 17:03 aaltat

Hello @aaltat @Snooz82 - We don't have the expertise to contribute to the fix for this issue. Would be great, if this could be looked into by the RF team. Thanks.

srajendran123 avatar Apr 25 '24 21:04 srajendran123

We understand, but we can’t give you a timeline or estimate when this could be fixed. Most likely answer is later than sooner.

aaltat avatar Apr 26 '24 05:04 aaltat

That works with current version.

New Persistent Context    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.1
  5     viewport={'width': 810, 'height': 1010}    headless=False    url=https://www.whatsmyua.info/

Snooz82 avatar Nov 30 '24 16:11 Snooz82

thanks for checking, Renee.

It looks like the network tab on the webkit displays the useragent of the system where the scripts are running. However, loading displays the user agent passed in the script.

srajendran123 avatar Jan 03 '25 19:01 srajendran123