Skip to content

[5.0.0-rc2] Backport Fix chrome/selenium tests (#25330) #25840

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

Merged
merged 4 commits into from
Sep 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -270,10 +270,10 @@
<NewtonsoftJsonBsonPackageVersion>1.0.2</NewtonsoftJsonBsonPackageVersion>
<NewtonsoftJsonPackageVersion>12.0.2</NewtonsoftJsonPackageVersion>
<NSwagApiDescriptionClientPackageVersion>13.0.4</NSwagApiDescriptionClientPackageVersion>
<SeleniumSupportPackageVersion>3.12.1</SeleniumSupportPackageVersion>
<SeleniumSupportPackageVersion>4.0.0-alpha05</SeleniumSupportPackageVersion>
<SeleniumWebDriverMicrosoftDriverPackageVersion>17.17134.0</SeleniumWebDriverMicrosoftDriverPackageVersion>
<SeleniumWebDriverChromeDriverPackageVersion>2.43.0</SeleniumWebDriverChromeDriverPackageVersion>
<SeleniumWebDriverPackageVersion>3.12.1</SeleniumWebDriverPackageVersion>
<SeleniumWebDriverChromeDriverPackageVersion>85.0.4183.8300</SeleniumWebDriverChromeDriverPackageVersion>
<SeleniumWebDriverPackageVersion>4.0.0-alpha05</SeleniumWebDriverPackageVersion>
<SerilogExtensionsLoggingPackageVersion>1.4.0</SerilogExtensionsLoggingPackageVersion>
<SerilogSinksFilePackageVersion>4.0.0</SerilogSinksFilePackageVersion>
<StackExchangeRedisPackageVersion>2.0.593</StackExchangeRedisPackageVersion>
Expand Down
9 changes: 7 additions & 2 deletions eng/targets/CSharp.Common.props
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@
<PackageReference Include="MicroBuild.Core" Version="0.3.0" PrivateAssets="All" AllowExplicitReference="true" ExcludeAssets="All" />
</ItemGroup>

<ItemGroup Condition="'$(UsingMicrosoftNETSdkWeb)' == 'true' OR '$(UsingMicrosoftNETSdkBlazorWebAssembly)' == 'true' OR '$(RazorSdkCurrentVersionProps)' != ''">
<PropertyGroup>
<_ReferenceLocalRazorSDK
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SteveSandersonMS this should fix the issue with you were seeing. I ran in to when debugging the tests in VS and really had to fix this to make any progression.

Condition="'$(UsingMicrosoftNETSdkWeb)' == 'true' OR '$(UsingMicrosoftNETSdkBlazorWebAssembly)' == 'true' OR '$(RazorSdkCurrentVersionProps)' != '' OR '$(_RazorSdkImportsMicrosoftNetSdk)' == 'true'">true</_ReferenceLocalRazorSDK>
</PropertyGroup>

<ItemGroup Condition="'$(_ReferenceLocalRazorSDK)' == 'true'">
<!--
Use the Razor SDK as a project reference. The version of the .NET Core SDK we build with often contains a version of the Razor SDK
several versions older than latest. We reference the project to ensure it's built before the other projects that use it. Since this
Expand All @@ -25,7 +30,7 @@
UndefineProperties="TargetFramework;TargetFrameworks" />
</ItemGroup>

<ImportGroup Condition="'$(UsingMicrosoftNETSdkWeb)' == 'true' OR '$(UsingMicrosoftNETSdkBlazorWebAssembly)' == 'true' OR '$(RazorSdkCurrentVersionProps)' != ''">
<ImportGroup Condition="'$(_ReferenceLocalRazorSDK)' == 'true'">
<Import Project="$(RepoRoot)eng\targets\GetRazorSDKDirectory.props" />
<Import Project="$(RepoRoot)src\Razor\Microsoft.NET.Sdk.Razor\src\build\netstandard2.0\Microsoft.NET.Sdk.Razor.props" />
</ImportGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
<SkipTests Condition="'$(SeleniumE2ETestsSupported)' != 'true'">true</SkipTests>
<SkipTests Condition="'$(SeleniumE2ETestsSupported)' == 'true'">false</SkipTests>

<!-- Tests are disabled due to https://github.com/dotnet/aspnetcore/issues/25322 -->
<SkipTests>true</SkipTests>

<!-- Tests do not work on Helix or when bin/ directory is not in project directory due to undeclared dependency on test content. -->
<BaseOutputPath />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public override async Task InitializeAsync()
}
}

[Fact]
[Fact(Skip = "Browser logs cannot be retrieved: https://github.com/dotnet/aspnetcore/issues/25803")]
public void DoesNotStartMultipleConnections()
{
Navigate("/multiple-components");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public void RendersContinueAfterReconnect()
Browser.False(() => Browser.FindElement(selector).Text == currentValue);
}

[Fact]
[Fact(Skip = "Browser logs cannot be retrieved: https://github.com/dotnet/aspnetcore/issues/25803")]
public void ErrorsStopTheRenderingProcess()
{
Browser.FindElement(By.Id("cause-error")).Click();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ public void LoggedInUser_OnTheIdP_CanLogInSilently()
ValidateLoggedIn(userName);
}

[Fact]
[Fact(Skip = "Browser logs cannot be retrieved: https://github.com/dotnet/aspnetcore/issues/25803")]
public void CanNotRedirect_To_External_ReturnUrl()
{
Browser.Navigate().GoToUrl(new Uri(new Uri(Browser.Url), "/authentication/login?returnUrl=https%3A%2F%2Fwww.bing.com").AbsoluteUri);
Expand Down
20 changes: 9 additions & 11 deletions src/Components/test/E2ETest/Tests/WebAssemblyICUShardingTest.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
using System.Globalization;
using System.Linq;
using GlobalizationWasmApp;
using Microsoft.AspNetCore.Components.E2ETest.Infrastructure;
using Microsoft.AspNetCore.Components.E2ETest.Infrastructure.ServerFixtures;
Expand All @@ -18,7 +16,6 @@ namespace Microsoft.AspNetCore.Components.E2ETest.Tests
// This app covers testing this along with verifying the behavior for fallback culture for localized resources.
public class WebAssemblyICUShardingTest : ServerTestBase<ToggleExecutionModeServerFixture<Program>>
{
private readonly DateTime DisplayTime = new DateTime(2020, 09, 02);
public WebAssemblyICUShardingTest(
BrowserFixture browserFixture,
ToggleExecutionModeServerFixture<Program> serverFixture,
Expand All @@ -39,7 +36,7 @@ public void LoadingApp_FrenchLanguage_Works()
Assert.Equal(culture.ToString(), cultureDisplay.Text);

var dateDisplay = Browser.Exists(By.Id("dateTime"));
Assert.Equal(DisplayTime.ToString(culture), dateDisplay.Text);
Assert.Equal("02/09/2020 00:00:00", dateDisplay.Text);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ICU data on the server depends on the OS. On my machine, it's up to date with WASM but not so on the build machines. Using hardcoded strings seems like the best way to proceed: dotnet/runtime#42136


var localizedDisplay = Browser.Exists(By.Id("localizedString"));
Assert.Equal("Bonjour!", localizedDisplay.Text);
Expand All @@ -57,7 +54,7 @@ public void LoadingApp_KoreanLanguage_Works()
Assert.Equal(culture.ToString(), cultureDisplay.Text);

var dateDisplay = Browser.Exists(By.Id("dateTime"));
Assert.Equal(DisplayTime.ToString(culture), dateDisplay.Text);
Assert.Equal("2020. 9. 2. 오전 12:00:00", dateDisplay.Text);

var localizedDisplay = Browser.Exists(By.Id("localizedString"));
// The app has a "ko" resx file. This test verifies that we can walk up the culture hierarchy correctly.
Expand All @@ -76,7 +73,7 @@ public void LoadingApp_RussianLanguage_Works()
Assert.Equal(culture.ToString(), cultureDisplay.Text);

var dateDisplay = Browser.Exists(By.Id("dateTime"));
Assert.Equal(DisplayTime.ToString(culture), dateDisplay.Text);
Assert.Equal("02.09.2020 00:00:00", dateDisplay.Text);

var localizedDisplay = Browser.Exists(By.Id("localizedString"));
Assert.Equal("Hello", localizedDisplay.Text); // No localized resources for this culture.
Expand All @@ -94,7 +91,7 @@ public void LoadingApp_KannadaLanguage_Works()
Assert.Equal(culture.ToString(), cultureDisplay.Text);

var dateDisplay = Browser.Exists(By.Id("dateTime"));
Assert.Equal(DisplayTime.ToString(culture), dateDisplay.Text);
Assert.Equal("2/9/2020 12:00:00 ಪೂರ್ವಾಹ್ನ", dateDisplay.Text);

var localizedDisplay = Browser.Exists(By.Id("localizedString"));
Assert.Equal("ಹಲೋ", localizedDisplay.Text);
Expand All @@ -105,15 +102,16 @@ public void LoadingApp_DynamicallySetLanguageThrows()
{
// Arrange
// This verifies that we complain if the app programtically configures a language.
var expected = "This application's globalization settings requires using the combined globalization data file.";
Navigate($"{ServerPathBase}/?culture=fr&dotNetCulture=es", noReload: false);

var errorUi = Browser.Exists(By.Id("blazor-error-ui"));
Browser.Equal("block", () => errorUi.GetCssValue("display"));

var logs = Browser.GetBrowserLogs(LogLevel.Severe).Select(l => l.Message);
Assert.True(logs.Any(l => l.Contains(expected)),
$"Expected to see globalization error message in the browser logs: {string.Join(Environment.NewLine, logs)}.");
// Browser logs cannot be retrieved: https://github.com/dotnet/aspnetcore/issues/25803"
// var expected = "This application's globalization settings requires using the combined globalization data file.";
// var logs = Browser.GetBrowserLogs(LogLevel.Severe).Select(l => l.Message);
// Assert.True(logs.Any(l => l.Contains(expected)),
// $"Expected to see globalization error message in the browser logs: {string.Join(Environment.NewLine, logs)}.");
}

private void Initialize(CultureInfo culture)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public void CanLazyLoadAssemblyWithRoutes()
Assert.True(renderedElement.Displayed);
}

[Fact]
[Fact(Skip = "Browser logs cannot be retrieved: https://github.com/dotnet/aspnetcore/issues/25803")]
public void ThrowsErrorForUnavailableAssemblies()
{
// Navigate to a page with lazy loaded assemblies for the first time
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using BasicTestApp;
using Microsoft.AspNetCore.Components.E2ETest;
using Microsoft.AspNetCore.Components.E2ETest.Infrastructure;
using Microsoft.AspNetCore.Components.E2ETest.Infrastructure.ServerFixtures;
using Microsoft.AspNetCore.E2ETesting;
Expand Down
8 changes: 4 additions & 4 deletions src/Components/test/E2ETest/Tests/WebAssemblyLoggingTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ protected override void InitializeAsyncCore()
Assert.Equal("none", errorUi.GetCssValue("display"));
}

[Fact]
[Fact(Skip = "Browser logs cannot be retrieved: https://github.com/dotnet/aspnetcore/issues/25803")]
public void LogsSimpleExceptionsUsingLogger()
{
Browser.FindElement(By.Id("throw-simple-exception")).Click();
Expand All @@ -44,7 +44,7 @@ public void LogsSimpleExceptionsUsingLogger()
"at BasicTestApp.ErrorComponent.ThrowSimple");
}

[Fact]
[Fact(Skip = "Browser logs cannot be retrieved: https://github.com/dotnet/aspnetcore/issues/25803")]
public void LogsInnerExceptionsUsingLogger()
{
Browser.FindElement(By.Id("throw-inner-exception")).Click();
Expand All @@ -57,7 +57,7 @@ public void LogsInnerExceptionsUsingLogger()
"at BasicTestApp.ErrorComponent.ThrowInner");
}

[Fact]
[Fact(Skip = "Browser logs cannot be retrieved: https://github.com/dotnet/aspnetcore/issues/25803")]
public void LogsAggregateExceptionsUsingLogger()
{
Browser.FindElement(By.Id("throw-aggregate-exception")).Click();
Expand All @@ -72,7 +72,7 @@ public void LogsAggregateExceptionsUsingLogger()
"System.InvalidTimeZoneException: Aggregate exception 3");
}

[Fact]
[Fact(Skip = "Browser logs cannot be retrieved: https://github.com/dotnet/aspnetcore/issues/25803")]
public void LogsUsingCustomLogger()
{
Browser.MountTestComponent<LoggingComponent>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

<!-- Resx generation on Resources.resx only -->
<GenerateResxSource>false</GenerateResxSource>

<!-- Project supports more than one language -->
<BlazorWebAssemblyLoadAllGlobalizationData>true</BlazorWebAssemblyLoadAllGlobalizationData>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Components/test/testassets/TestServer/ServerStartup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public ServerStartup(IConfiguration configuration)
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
services.AddServerSideBlazor(options => options.DetailedErrors = true);
services.AddServerSideBlazor();
}

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@

<RunTemplateTests Condition="'$(RunTemplateTests)' == ''" >true</RunTemplateTests>
<SkipTests Condition="'$(RunTemplateTests)' != 'true'">true</SkipTests>

<!-- Tests are disabled due to https://github.com/dotnet/aspnetcore/issues/25322 -->
<SkipTests>true</SkipTests>

<!--Do not run this test project on Helix.-->
<BuildHelixPayload>false</BuildHelixPayload>
<SkipHelixArm>true</SkipHelixArm>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public override Task InitializeAsync()
return InitializeAsync(isolationContext: Guid.NewGuid().ToString());
}

[Fact]
[Fact(Skip = "Certificate issue: https://github.com/dotnet/aspnetcore/issues/25826")]
public async Task BlazorWasmStandaloneTemplate_Works()
{
// Additional arguments are needed. See: https://github.com/dotnet/aspnetcore/issues/24278
Expand Down Expand Up @@ -178,7 +178,7 @@ public async Task BlazorWasmStandalonePwaTemplate_Works()
}
}

[Fact]
[Fact(Skip = "Certificate issue: https://github.com/dotnet/aspnetcore/issues/25826")]
public async Task BlazorWasmHostedPwaTemplate_Works()
{
// Additional arguments are needed. See: https://github.com/dotnet/aspnetcore/issues/24278
Expand Down
51 changes: 37 additions & 14 deletions src/Shared/E2ETesting/BrowserFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
using System.Threading.Tasks;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Edge;
using OpenQA.Selenium.IE;
using OpenQA.Selenium.Remote;
using OpenQA.Selenium.Safari;
using Xunit;
using Xunit.Abstractions;

Expand Down Expand Up @@ -234,55 +237,75 @@ private string UserProfileDirectory(string context)
name = $"{name} - {context}";
}

var capabilities = new DesiredCapabilities();
DriverOptions options;

switch (sauce.BrowserName.ToLower())
{
case "chrome":
options = new ChromeOptions();
break;
case "safari":
options = new SafariOptions();
break;
case "internet explorer":
options = new InternetExplorerOptions();
break;
case "microsoftedge":
options = new EdgeOptions();
break;
default:
throw new InvalidOperationException($"Browser name {sauce.BrowserName} not recognized");
}

// Required config
capabilities.SetCapability("username", sauce.Username);
capabilities.SetCapability("accessKey", sauce.AccessKey);
capabilities.SetCapability("tunnelIdentifier", sauce.TunnelIdentifier);
capabilities.SetCapability("name", name);
options.AddAdditionalOption("username", sauce.Username);
options.AddAdditionalOption("accessKey", sauce.AccessKey);
options.AddAdditionalOption("tunnelIdentifier", sauce.TunnelIdentifier);
options.AddAdditionalOption("name", name);

if (!string.IsNullOrEmpty(sauce.BrowserName))
{
capabilities.SetCapability("browserName", sauce.BrowserName);
options.AddAdditionalOption("browserName", sauce.BrowserName);
}

if (!string.IsNullOrEmpty(sauce.PlatformVersion))
{
capabilities.SetCapability("platformName", sauce.PlatformName);
capabilities.SetCapability("platformVersion", sauce.PlatformVersion);
options.PlatformName = sauce.PlatformName;
options.AddAdditionalOption("platformVersion", sauce.PlatformVersion);
}
else
{
// In some cases (like macOS), SauceLabs expects us to set "platform" instead of "platformName".
capabilities.SetCapability("platform", sauce.PlatformName);
options.AddAdditionalOption("platform", sauce.PlatformName);
}

if (!string.IsNullOrEmpty(sauce.BrowserVersion))
{
capabilities.SetCapability("browserVersion", sauce.BrowserVersion);
options.BrowserVersion = sauce.BrowserVersion;
}

if (!string.IsNullOrEmpty(sauce.DeviceName))
{
capabilities.SetCapability("deviceName", sauce.DeviceName);
options.AddAdditionalOption("deviceName", sauce.DeviceName);
}

if (!string.IsNullOrEmpty(sauce.DeviceOrientation))
{
capabilities.SetCapability("deviceOrientation", sauce.DeviceOrientation);
options.AddAdditionalOption("deviceOrientation", sauce.DeviceOrientation);
}

if (!string.IsNullOrEmpty(sauce.AppiumVersion))
{
capabilities.SetCapability("appiumVersion", sauce.AppiumVersion);
options.AddAdditionalOption("appiumVersion", sauce.AppiumVersion);
}

if (!string.IsNullOrEmpty(sauce.SeleniumVersion))
{
capabilities.SetCapability("seleniumVersion", sauce.SeleniumVersion);
options.AddAdditionalOption("seleniumVersion", sauce.SeleniumVersion);
}

var capabilities = options.ToCapabilities();

await SauceConnectServer.StartAsync(output);

var attempt = 0;
Expand Down
6 changes: 4 additions & 2 deletions src/Shared/E2ETesting/selenium-config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"drivers": {
"chrome": {}
"chrome": {
"version" : "85.0.4183.87"
}
},
"ignoreExtraDrivers": true
"ignoreExtraDrivers": true
}