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

Artillery is not passing the customer header values to redirect URL #2632

Open
sruthii38 opened this issue Apr 10, 2024 · 3 comments
Open

Artillery is not passing the customer header values to redirect URL #2632

sruthii38 opened this issue Apr 10, 2024 · 3 comments

Comments

@sruthii38
Copy link

Hi, I used extraHTTPHeaders to give custom value for User-Agent which I can see getting passed to initial URL load but the user on our website will get redirected by generating 302 status and authorize through headers but the default headers specified in Playwright are not being picked by artillery(Spec file in playwright is doing expected). So here are two problems

The headers that Playwright passes from Playwright.config.ts to spec file execution are not being entirely honored by artillery(Spec file passes on Playwright test spec.js and Artillery is failing the same spec as unauthorized.)

The user have to specify the same headers in Playwright again in Artillery yml file as extraHTTPHeaders but still the test fails because Artillery is not carrying the extraHTTPHeaders to redirect Urls and the tests are failing.

To give you more context on the issue I found, the header that is not getting passed to redirect URL is "User-Agent". I can see it is still being the default on redirect URL when extraHTTPHeaders is passing a custom value. On the other hand Playwright spec file is passing the right header(User-Agent) for the entire test and passing the test. But Artillery run is failing. If I add userAgent header to extraHTTPHeaders along with User-Agent like below, the website is getting both headers while User-Agent is still default and userAgent is the custom value but we only need User-Agent for authorization and artillery is not taking custom value for a default header on redirect URL.

playwright:
userAgent: '***'

yml:
extraHTTPHeaders:
User-Agent: ''
userAgent: ''

I still have an open issue about this that did not get addressed so creating a new for attention. Thanks

@bernardobridge
Copy link
Contributor

bernardobridge commented Apr 11, 2024

Hi @sruthii38

I believe Playwright overrides the User-Agent header you're setting in extraHTTPHeaders. When using Playwright directly, how are you setting the user agent?

Can you please try to pass the userAgent in the contextOptions configuration instead? For example:

config:
  target: "https://www.artillery.io"
  phases:
    - arrivalRate: 1
      duration: 10
  engines:
    playwright:
      contextOptions:
        userAgent: 'abc123'

Also, please use Github Code Blocks when displaying code - it helps us understand how the indentation in the yml looks like. Thank you!

@sruthii38
Copy link
Author

sruthii38 commented Apr 12, 2024

So in Playwright, the playwright config has the header values and playwright test takes care of it throughout the test.

import { defineConfig, devices } from '@playwright/test';
export default defineConfig({
    use: {
        userAgent: 'xxx',
    },
}); 

the same spec file when run with Artillery failed because the custom header value of this default header did not get passed for Artillery test. I used extraHTTPHeaders in conextOptions but that did not hold the custom value on redirect URL and the tests failed. If playwright overrides the extraHTTPHeaders then I believe it should override with playwright config values which has the custom value but in my case it is going back to the browser's default header value.

@bernardobridge
Copy link
Contributor

bernardobridge commented Apr 12, 2024

So in Playwright, the playwright config has the header values and playwright test takes care of it throughout the test.

import { defineConfig, devices } from '@playwright/test'; export default defineConfig({ use: { userAgent: 'xxx', }, });

the same spec file when run with Artillery failed because the custom header value of this default header did not get passed for Artillery test. I used extraHTTPHeaders in conextOptions but that did not hold the custom value on redirect URL and the tests failed. If playwright overrides the extraHTTPHeaders then I believe it should override with playwright config values which has the custom value but in my case it is going back to the browser's default header value.

@sruthii38 I think you must have missed my suggestion. Have you tried setting it in engines.playwright.contextOptions.userAgent instead of extraHTTPHeaders ? extraHTTPHeaders is not the right way to do it - playwright's defineConfig uses contextOptions.userAgent under the hood as well.

Also, once again, please try to use Github Code Blocks when displaying code, as it helps everyone with readability. Thank you!

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