Skip to content

Commit dab6a2f

Browse files
authored
Force english lang for selenium (#26158)
* Force english lang for selenium * Specify culture in server startups * Update Components.TestServer.csproj
1 parent 1a0117e commit dab6a2f

File tree

9 files changed

+42
-1
lines changed

9 files changed

+42
-1
lines changed

src/Components/test/testassets/TestServer/AuthenticationStartup.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Globalization;
23
using Microsoft.AspNetCore.Authentication.Cookies;
34
using Microsoft.AspNetCore.Builder;
45
using Microsoft.AspNetCore.Hosting;
@@ -39,6 +40,10 @@ public void ConfigureServices(IServiceCollection services)
3940
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
4041
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
4142
{
43+
var enUs = new CultureInfo("en-US");
44+
CultureInfo.DefaultThreadCurrentCulture = enUs;
45+
CultureInfo.DefaultThreadCurrentUICulture = enUs;
46+
4247
if (env.IsDevelopment())
4348
{
4449
app.UseDeveloperExceptionPage();

src/Components/test/testassets/TestServer/Components.TestServer.csproj

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22

33
<PropertyGroup>
44
<TargetFramework>$(DefaultNetCoreTargetFramework)</TargetFramework>
5+
6+
<!-- Project supports more than one language -->
7+
<BlazorWebAssemblyLoadAllGlobalizationData>true</BlazorWebAssemblyLoadAllGlobalizationData>
58
</PropertyGroup>
69

7-
<ItemGroup>
10+
<ItemGroup>
811
<Reference Include="Microsoft.AspNetCore" />
912
<Reference Include="Microsoft.AspNetCore.Authentication.Cookies" />
1013
<Reference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" />

src/Components/test/testassets/TestServer/CorsStartup.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System.Globalization;
12
using Microsoft.AspNetCore.Builder;
23
using Microsoft.AspNetCore.Hosting;
34
using Microsoft.Extensions.Configuration;
@@ -38,6 +39,10 @@ public void ConfigureServices(IServiceCollection services)
3839
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
3940
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
4041
{
42+
var enUs = new CultureInfo("en-US");
43+
CultureInfo.DefaultThreadCurrentCulture = enUs;
44+
CultureInfo.DefaultThreadCurrentUICulture = enUs;
45+
4146
if (env.IsDevelopment())
4247
{
4348
app.UseDeveloperExceptionPage();

src/Components/test/testassets/TestServer/MultipleComponents.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System.Globalization;
12
using Microsoft.AspNetCore.Authentication.Cookies;
23
using Microsoft.AspNetCore.Builder;
34
using Microsoft.AspNetCore.Hosting;
@@ -27,6 +28,10 @@ public void ConfigureServices(IServiceCollection services)
2728
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
2829
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
2930
{
31+
var enUs = new CultureInfo("en-US");
32+
CultureInfo.DefaultThreadCurrentCulture = enUs;
33+
CultureInfo.DefaultThreadCurrentUICulture = enUs;
34+
3035
if (env.IsDevelopment())
3136
{
3237
app.UseDeveloperExceptionPage();

src/Components/test/testassets/TestServer/PrerenderedStartup.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using Microsoft.Extensions.DependencyInjection;
66
using Microsoft.Extensions.Hosting;
77
using Microsoft.AspNetCore.Components.WebAssembly.Services;
8+
using System.Globalization;
89

910
namespace TestServer
1011
{
@@ -29,6 +30,10 @@ public void ConfigureServices(IServiceCollection services)
2930
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
3031
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
3132
{
33+
var enUs = new CultureInfo("en-US");
34+
CultureInfo.DefaultThreadCurrentCulture = enUs;
35+
CultureInfo.DefaultThreadCurrentUICulture = enUs;
36+
3237
if (env.IsDevelopment())
3338
{
3439
app.UseDeveloperExceptionPage();

src/Components/test/testassets/TestServer/ServerStartup.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System.Globalization;
12
using Microsoft.AspNetCore.Builder;
23
using Microsoft.AspNetCore.Hosting;
34
using Microsoft.Extensions.Configuration;
@@ -25,6 +26,10 @@ public void ConfigureServices(IServiceCollection services)
2526
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
2627
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
2728
{
29+
var enUs = new CultureInfo("en-US");
30+
CultureInfo.DefaultThreadCurrentCulture = enUs;
31+
CultureInfo.DefaultThreadCurrentUICulture = enUs;
32+
2833
if (env.IsDevelopment())
2934
{
3035
app.UseDeveloperExceptionPage();

src/Components/test/testassets/TestServer/Startup.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System.Globalization;
12
using System.IO;
23
using Microsoft.AspNetCore.Builder;
34
using Microsoft.AspNetCore.Hosting;
@@ -26,6 +27,10 @@ public void ConfigureServices(IServiceCollection services)
2627
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
2728
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
2829
{
30+
var enUs = new CultureInfo("en-US");
31+
CultureInfo.DefaultThreadCurrentCulture = enUs;
32+
CultureInfo.DefaultThreadCurrentUICulture = enUs;
33+
2934
if (env.IsDevelopment())
3035
{
3136
app.UseDeveloperExceptionPage();

src/Components/test/testassets/TestServer/StartupWithMapFallbackToClientSideBlazor.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

4+
using System.Globalization;
45
using Microsoft.AspNetCore.Builder;
56
using Microsoft.AspNetCore.Hosting;
67
using Microsoft.Extensions.Configuration;
@@ -25,6 +26,10 @@ public void ConfigureServices(IServiceCollection services)
2526

2627
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
2728
{
29+
var enUs = new CultureInfo("en-US");
30+
CultureInfo.DefaultThreadCurrentCulture = enUs;
31+
CultureInfo.DefaultThreadCurrentUICulture = enUs;
32+
2833
if (env.IsDevelopment())
2934
{
3035
app.UseDeveloperExceptionPage();

src/Shared/E2ETesting/BrowserFixture.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,9 @@ private async Task DeleteBrowserUserProfileDirectoriesAsync()
138138
{
139139
var opts = new ChromeOptions();
140140

141+
// Force language to english for tests
142+
opts.AddUserProfilePreference("intl.accept_languages", "en");
143+
141144
// Comment this out if you want to watch or interact with the browser (e.g., for debugging)
142145
if (!Debugger.IsAttached)
143146
{

0 commit comments

Comments
 (0)