Playwright C# Can’t get .runsettings to run multiple browsers in Visual Studio (2022)


Short background – I am a full stack dev, so I’m used to VS. I also head the QA team at my work and have created Selenium automation for our legacy enterprise software. However, with the company in planning phase of a new enterprise software to sunset our current software, I thought it was time to research if Selenium was best or if there would be a better automation software for the next iteration. I landed on Playwright, so now I am digging in to learn it. Most tutorials and how-to guides show using VSCode with TS. With being used to VS/C# and knowing Playwright supports it, I am attempting to do a side by side comparison deep dive into both to see which will be better for QA usability as well as for the company in general.

That said I am having issues configuring VS2022 to run multiple browsers simultaneously for testing using the IDE vs powershell script (I know this one is possible). VSCode/TS uses a settings file (playwright.config.ts) that is configurable for multiple browsers so I am trying to set up a .runsettings file to do the same to continue side by side comparison. But I am finding that no matter what I do I can’t seem to get it to run multiple browsers. I have found how to make it work with a single browser and manually change the settings every time which does partially defeat the purpose of using Playwright. So from my searching of google, the Playwright website, and just playing around, here’s a couple things I have attempted to make work and just can’t.

1)

<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
  <Playwright>
    <BrowserName>chromium</BrowserName>
    <LaunchOptions>
      <Headless>false</Headless>
    </LaunchOptions>
  </Playwright>
</RunSettings>

<RunSettings>
  <Playwright>
    <BrowserName>firefox</BrowserName>
    <LaunchOptions>
      <Headless>false</Headless>
    </LaunchOptions>
  </Playwright>
</RunSettings>

<RunSettings>
  <Playwright>
    <BrowserName>webkit</BrowserName>
    <LaunchOptions>
      <Headless>false</Headless>
    </LaunchOptions>
  </Playwright>
</RunSettings>
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
  <Playwright>
    <BrowserName>firefox</BrowserName>
    <ExpectTimeout>5000</ExpectTimeout>
    <LaunchOptions>
      <Headless>false</Headless>
      <Channel>firefox</Channel>
    </LaunchOptions>
    <BrowserName>chromium</BrowserName>
    <ExpectTimeout>5000</ExpectTimeout>
    <LaunchOptions>
      <Headless>false</Headless>
      <Channel>chrome</Channel>
    </LaunchOptions>
    <BrowserName>chromium</BrowserName>
    <ExpectTimeout>5000</ExpectTimeout>
    <LaunchOptions>
      <Headless>false</Headless>
      <Channel>msedge</Channel>
    </LaunchOptions>
  </Playwright>
</RunSettings>

I have also read somewhere that I should use multiple .runsettings files for each browser, though it had no examples and I am not sure any program can run multiple ‘config’ files for a single project. Any insight, help, point in the right direction would be insanely helpful! Thank you.

Leave a Reply

Your email address will not be published. Required fields are marked *