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

[Question] Trying to add user-agent setting on runSettings file #2717

Closed
ZhouZhengCarlos opened this issue Oct 4, 2023 · 1 comment
Closed

Comments

@ZhouZhengCarlos
Copy link

Hi I want to add user agent to my playwright .net solution as I did in my playwright nodejs solution

Playwright.config.js:

  projects: [
    {
      name: 'chromium',
      use: { ...devices['Desktop Chrome'], userAgent: 'Chrome-Playwright-Automation' },
    }

I've seen that on .Net there is a .runSettings file and I wanted to add it there instead of this solution #2080

Tried this approach but doesnt look to work, I might be missing something

.runSettings:

<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
  <!-- NUnit adapter -->  
  <NUnit>
    <NumberOfTestWorkers>24</NumberOfTestWorkers>
  </NUnit>
  <!-- General run configuration -->
  <RunConfiguration>
    <EnvironmentVariables>
      <!-- For debugging selectors, it's recommend to set the following environment variable -->
      <DEBUG>pw:api</DEBUG>
    </EnvironmentVariables>
  </RunConfiguration>
  <!-- Playwright -->  
  <Playwright>
    <BrowserName>chromium</BrowserName>
    <ExpectTimeout>5000</ExpectTimeout>
    <LaunchOptions>
      <Headless>false</Headless>
		<UserAgent>Chrome-Playwright-Automation</UserAgent>
		<!-- <Channel>msedge</Channel> -->
    </LaunchOptions>
  </Playwright>
</RunSettings>

Thank you!

@mxschmitt
Copy link
Member

UserAgent is a Context options rather than a Launch options. Context options can't be set in the runsettings file, only inside the class its supported as per #2555.

Folding into #2555.

@mxschmitt mxschmitt closed this as not planned Won't fix, can't repro, duplicate, stale Oct 9, 2023
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