* Restore support for logs in E2E tests. Fixes #25803 * Revert earlier workaround * Update message in assertion * Remove redundant script references
This commit is contained in:
parent
efa72d92c3
commit
5b4f3003af
|
|
@ -6,7 +6,6 @@
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<app>Loading...</app>
|
<app>Loading...</app>
|
||||||
<script src="seleniumworkaround.js"></script>
|
|
||||||
<script src="customJsFileForTests.js"></script>
|
<script src="customJsFileForTests.js"></script>
|
||||||
<script src="_framework/blazor.webassembly.js" autostart="false"></script>
|
<script src="_framework/blazor.webassembly.js" autostart="false"></script>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,26 +0,0 @@
|
||||||
(function () {
|
|
||||||
// Note: there are multiple copies of this file throughout the repo. If you're editing it, please look for
|
|
||||||
// other seleniumworkaround.js files and keep them all in sync.
|
|
||||||
const logs = [];
|
|
||||||
|
|
||||||
const defaultLog = console.log;
|
|
||||||
console.log = function () {
|
|
||||||
defaultLog.apply(console, arguments);
|
|
||||||
logs.push(Array.from(arguments).join(' '));
|
|
||||||
}
|
|
||||||
|
|
||||||
const defaultError = console.error;
|
|
||||||
console.error = function () {
|
|
||||||
defaultError.apply(console, arguments);
|
|
||||||
logs.push(Array.from(arguments).join(' '));
|
|
||||||
}
|
|
||||||
|
|
||||||
const defaultWarn = console.warn;
|
|
||||||
console.warn = function () {
|
|
||||||
defaultWarn.apply(console, arguments);
|
|
||||||
logs.push(Array.from(arguments).join(' '));
|
|
||||||
}
|
|
||||||
|
|
||||||
window.getBrowserLogs = () => logs;
|
|
||||||
})();
|
|
||||||
|
|
||||||
|
|
@ -18,7 +18,6 @@
|
||||||
<a class="dismiss">🗙</a>
|
<a class="dismiss">🗙</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="seleniumworkaround.js"></script>
|
|
||||||
<script src="_content/Microsoft.AspNetCore.Components.WebAssembly.Authentication/AuthenticationService.js"></script>
|
<script src="_content/Microsoft.AspNetCore.Components.WebAssembly.Authentication/AuthenticationService.js"></script>
|
||||||
<script src="_framework/blazor.webassembly.js"></script>
|
<script src="_framework/blazor.webassembly.js"></script>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
||||||
|
|
@ -1,26 +0,0 @@
|
||||||
(function () {
|
|
||||||
// Note: there are multiple copies of this file throughout the repo. If you're editing it, please look for
|
|
||||||
// other seleniumworkaround.js files and keep them all in sync.
|
|
||||||
const logs = [];
|
|
||||||
|
|
||||||
const defaultLog = console.log;
|
|
||||||
console.log = function () {
|
|
||||||
defaultLog.apply(console, arguments);
|
|
||||||
logs.push(Array.from(arguments).join(' '));
|
|
||||||
}
|
|
||||||
|
|
||||||
const defaultError = console.error;
|
|
||||||
console.error = function () {
|
|
||||||
defaultError.apply(console, arguments);
|
|
||||||
logs.push(Array.from(arguments).join(' '));
|
|
||||||
}
|
|
||||||
|
|
||||||
const defaultWarn = console.warn;
|
|
||||||
console.warn = function () {
|
|
||||||
defaultWarn.apply(console, arguments);
|
|
||||||
logs.push(Array.from(arguments).join(' '));
|
|
||||||
}
|
|
||||||
|
|
||||||
window.getBrowserLogs = () => logs;
|
|
||||||
})();
|
|
||||||
|
|
||||||
|
|
@ -43,7 +43,7 @@ namespace Microsoft.AspNetCore.Components.E2ETest.ServerExecutionTests
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact(Skip = "Browser logs cannot be retrieved: https://github.com/dotnet/aspnetcore/issues/25803")]
|
[Fact]
|
||||||
public void DoesNotStartMultipleConnections()
|
public void DoesNotStartMultipleConnections()
|
||||||
{
|
{
|
||||||
Navigate("/multiple-components");
|
Navigate("/multiple-components");
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,7 @@ namespace Microsoft.AspNetCore.Components.E2ETest.ServerExecutionTests
|
||||||
Browser.False(() => Browser.Exists(selector).Text == currentValue);
|
Browser.False(() => Browser.Exists(selector).Text == currentValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact(Skip = "Browser logs cannot be retrieved: https://github.com/dotnet/aspnetcore/issues/25803")]
|
[Fact]
|
||||||
public void ErrorsStopTheRenderingProcess()
|
public void ErrorsStopTheRenderingProcess()
|
||||||
{
|
{
|
||||||
Browser.Exists(By.Id("cause-error")).Click();
|
Browser.Exists(By.Id("cause-error")).Click();
|
||||||
|
|
|
||||||
|
|
@ -306,7 +306,7 @@ namespace Microsoft.AspNetCore.Components.E2ETest.Tests
|
||||||
ValidateLoggedIn(userName);
|
ValidateLoggedIn(userName);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact(Skip = "Browser logs cannot be retrieved: https://github.com/dotnet/aspnetcore/issues/25803")]
|
[Fact]
|
||||||
public void CanNotRedirect_To_External_ReturnUrl()
|
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);
|
Browser.Navigate().GoToUrl(new Uri(new Uri(Browser.Url), "/authentication/login?returnUrl=https%3A%2F%2Fwww.bing.com").AbsoluteUri);
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// 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.
|
// 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.Globalization;
|
||||||
|
using System.Linq;
|
||||||
using GlobalizationWasmApp;
|
using GlobalizationWasmApp;
|
||||||
using Microsoft.AspNetCore.Components.E2ETest.Infrastructure;
|
using Microsoft.AspNetCore.Components.E2ETest.Infrastructure;
|
||||||
using Microsoft.AspNetCore.Components.E2ETest.Infrastructure.ServerFixtures;
|
using Microsoft.AspNetCore.Components.E2ETest.Infrastructure.ServerFixtures;
|
||||||
|
|
@ -107,11 +109,10 @@ namespace Microsoft.AspNetCore.Components.E2ETest.Tests
|
||||||
var errorUi = Browser.Exists(By.Id("blazor-error-ui"));
|
var errorUi = Browser.Exists(By.Id("blazor-error-ui"));
|
||||||
Browser.Equal("block", () => errorUi.GetCssValue("display"));
|
Browser.Equal("block", () => errorUi.GetCssValue("display"));
|
||||||
|
|
||||||
// Browser logs cannot be retrieved: https://github.com/dotnet/aspnetcore/issues/25803"
|
var expected = "Blazor detected a change in the application's culture that is not supported with the current project configuration.";
|
||||||
// var expected = "This application's globalization settings requires using the combined globalization data file.";
|
var logs = Browser.GetBrowserLogs(LogLevel.Severe).Select(l => l.Message);
|
||||||
// var logs = Browser.GetBrowserLogs(LogLevel.Severe).Select(l => l.Message);
|
Assert.True(logs.Any(l => l.Contains(expected)),
|
||||||
// Assert.True(logs.Any(l => l.Contains(expected)),
|
$"Expected to see globalization error message in the browser logs: {string.Join(Environment.NewLine, logs)}.");
|
||||||
// $"Expected to see globalization error message in the browser logs: {string.Join(Environment.NewLine, logs)}.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Initialize(CultureInfo culture)
|
private void Initialize(CultureInfo culture)
|
||||||
|
|
|
||||||
|
|
@ -108,7 +108,7 @@ namespace Microsoft.AspNetCore.Components.E2ETest.Tests
|
||||||
Assert.True(renderedElement.Displayed);
|
Assert.True(renderedElement.Displayed);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact(Skip = "Browser logs cannot be retrieved: https://github.com/dotnet/aspnetcore/issues/25803")]
|
[Fact]
|
||||||
public void ThrowsErrorForUnavailableAssemblies()
|
public void ThrowsErrorForUnavailableAssemblies()
|
||||||
{
|
{
|
||||||
// Navigate to a page with lazy loaded assemblies for the first time
|
// Navigate to a page with lazy loaded assemblies for the first time
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ namespace Microsoft.AspNetCore.Components.E2ETest.Tests
|
||||||
Assert.Equal("none", errorUi.GetCssValue("display"));
|
Assert.Equal("none", errorUi.GetCssValue("display"));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact(Skip = "Browser logs cannot be retrieved: https://github.com/dotnet/aspnetcore/issues/25803")]
|
[Fact]
|
||||||
public void LogsSimpleExceptionsUsingLogger()
|
public void LogsSimpleExceptionsUsingLogger()
|
||||||
{
|
{
|
||||||
Browser.Exists(By.Id("throw-simple-exception")).Click();
|
Browser.Exists(By.Id("throw-simple-exception")).Click();
|
||||||
|
|
@ -44,7 +44,7 @@ namespace Microsoft.AspNetCore.Components.E2ETest.Tests
|
||||||
"at BasicTestApp.ErrorComponent.ThrowSimple");
|
"at BasicTestApp.ErrorComponent.ThrowSimple");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact(Skip = "Browser logs cannot be retrieved: https://github.com/dotnet/aspnetcore/issues/25803")]
|
[Fact]
|
||||||
public void LogsInnerExceptionsUsingLogger()
|
public void LogsInnerExceptionsUsingLogger()
|
||||||
{
|
{
|
||||||
Browser.Exists(By.Id("throw-inner-exception")).Click();
|
Browser.Exists(By.Id("throw-inner-exception")).Click();
|
||||||
|
|
@ -57,7 +57,7 @@ namespace Microsoft.AspNetCore.Components.E2ETest.Tests
|
||||||
"at BasicTestApp.ErrorComponent.ThrowInner");
|
"at BasicTestApp.ErrorComponent.ThrowInner");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact(Skip = "Browser logs cannot be retrieved: https://github.com/dotnet/aspnetcore/issues/25803")]
|
[Fact]
|
||||||
public void LogsAggregateExceptionsUsingLogger()
|
public void LogsAggregateExceptionsUsingLogger()
|
||||||
{
|
{
|
||||||
Browser.Exists(By.Id("throw-aggregate-exception")).Click();
|
Browser.Exists(By.Id("throw-aggregate-exception")).Click();
|
||||||
|
|
@ -72,7 +72,7 @@ namespace Microsoft.AspNetCore.Components.E2ETest.Tests
|
||||||
"System.InvalidTimeZoneException: Aggregate exception 3");
|
"System.InvalidTimeZoneException: Aggregate exception 3");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact(Skip = "Browser logs cannot be retrieved: https://github.com/dotnet/aspnetcore/issues/25803")]
|
[Fact]
|
||||||
public void LogsUsingCustomLogger()
|
public void LogsUsingCustomLogger()
|
||||||
{
|
{
|
||||||
Browser.MountTestComponent<LoggingComponent>();
|
Browser.MountTestComponent<LoggingComponent>();
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,6 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Used for specific test cases -->
|
<!-- Used for specific test cases -->
|
||||||
<script src="js/seleniumworkaround.js"></script>
|
|
||||||
<script src="js/jsinteroptests.js"></script>
|
<script src="js/jsinteroptests.js"></script>
|
||||||
<script src="js/renderattributestest.js"></script>
|
<script src="js/renderattributestest.js"></script>
|
||||||
<script src="js/webComponentPerformingJsInterop.js"></script>
|
<script src="js/webComponentPerformingJsInterop.js"></script>
|
||||||
|
|
@ -49,8 +48,6 @@
|
||||||
</script>
|
</script>
|
||||||
<script src="_framework/blazor.webassembly.js"></script>
|
<script src="_framework/blazor.webassembly.js"></script>
|
||||||
|
|
||||||
<script src="_content/Microsoft.AspNetCore.Components.Web.Extensions/headManager.js"></script>
|
|
||||||
|
|
||||||
<!-- Used by ExternalContentPackage -->
|
<!-- Used by ExternalContentPackage -->
|
||||||
<script src="_content/TestContentPackage/prompt.js"></script>
|
<script src="_content/TestContentPackage/prompt.js"></script>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
||||||
|
|
@ -1,26 +0,0 @@
|
||||||
(function () {
|
|
||||||
// Note: there are multiple copies of this file throughout the repo. If you're editing it, please look for
|
|
||||||
// other seleniumworkaround.js files and keep them all in sync.
|
|
||||||
const logs = [];
|
|
||||||
|
|
||||||
const defaultLog = console.log;
|
|
||||||
console.log = function () {
|
|
||||||
defaultLog.apply(console, arguments);
|
|
||||||
logs.push(Array.from(arguments).join(' '));
|
|
||||||
}
|
|
||||||
|
|
||||||
const defaultError = console.error;
|
|
||||||
console.error = function () {
|
|
||||||
defaultError.apply(console, arguments);
|
|
||||||
logs.push(Array.from(arguments).join(' '));
|
|
||||||
}
|
|
||||||
|
|
||||||
const defaultWarn = console.warn;
|
|
||||||
console.warn = function () {
|
|
||||||
defaultWarn.apply(console, arguments);
|
|
||||||
logs.push(Array.from(arguments).join(' '));
|
|
||||||
}
|
|
||||||
|
|
||||||
window.getBrowserLogs = () => logs;
|
|
||||||
})();
|
|
||||||
|
|
||||||
|
|
@ -20,8 +20,6 @@
|
||||||
|
|
||||||
<script src="_framework/blazor.server.js" autostart="false"></script>
|
<script src="_framework/blazor.server.js" autostart="false"></script>
|
||||||
|
|
||||||
<script src="_content/Microsoft.AspNetCore.Components.Web.Extensions/headManager.js"></script>
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
// Used by InteropOnInitializationComponent
|
// Used by InteropOnInitializationComponent
|
||||||
function setElementValue(element, newValue) {
|
function setElementValue(element, newValue) {
|
||||||
|
|
|
||||||
|
|
@ -42,8 +42,6 @@
|
||||||
|
|
||||||
<script src="_framework/blazor.server.js"></script>
|
<script src="_framework/blazor.server.js"></script>
|
||||||
|
|
||||||
<script src="_content/Microsoft.AspNetCore.Components.Web.Extensions/headManager.js"></script>
|
|
||||||
|
|
||||||
<!-- Used by ExternalContentPackage -->
|
<!-- Used by ExternalContentPackage -->
|
||||||
<script src="_content/TestContentPackage/prompt.js"></script>
|
<script src="_content/TestContentPackage/prompt.js"></script>
|
||||||
<script>
|
<script>
|
||||||
|
|
|
||||||
|
|
@ -183,7 +183,7 @@ namespace Microsoft.AspNetCore.E2ETesting
|
||||||
// Additionally, if we think the selenium server has become irresponsive, we could spin up
|
// Additionally, if we think the selenium server has become irresponsive, we could spin up
|
||||||
// replace the current selenium server instance and let a new instance take over for the
|
// replace the current selenium server instance and let a new instance take over for the
|
||||||
// remaining tests.
|
// remaining tests.
|
||||||
var driver = new RemoteWebDriver(
|
var driver = new RemoteWebDriverWithLogs(
|
||||||
instance.Uri,
|
instance.Uri,
|
||||||
opts.ToCapabilities(),
|
opts.ToCapabilities(),
|
||||||
TimeSpan.FromSeconds(60).Add(TimeSpan.FromSeconds(attempt * 60)));
|
TimeSpan.FromSeconds(60).Add(TimeSpan.FromSeconds(attempt * 60)));
|
||||||
|
|
@ -336,5 +336,14 @@ namespace Microsoft.AspNetCore.E2ETesting
|
||||||
|
|
||||||
throw new InvalidOperationException("Couldn't create a SauceLabs remote driver client.");
|
throw new InvalidOperationException("Couldn't create a SauceLabs remote driver client.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This is a workaround for https://github.com/SeleniumHQ/selenium/issues/8229
|
||||||
|
private class RemoteWebDriverWithLogs : RemoteWebDriver, ISupportsLogs
|
||||||
|
{
|
||||||
|
public RemoteWebDriverWithLogs(Uri remoteAddress, ICapabilities desiredCapabilities, TimeSpan commandTimeout)
|
||||||
|
: base(remoteAddress, desiredCapabilities, commandTimeout)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -121,16 +121,6 @@ namespace Microsoft.AspNetCore.E2ETesting
|
||||||
var fileId = $"{Guid.NewGuid():N}.png";
|
var fileId = $"{Guid.NewGuid():N}.png";
|
||||||
var screenShotPath = Path.Combine(Path.GetFullPath(E2ETestOptions.Instance.ScreenShotsPath), fileId);
|
var screenShotPath = Path.Combine(Path.GetFullPath(E2ETestOptions.Instance.ScreenShotsPath), fileId);
|
||||||
var errors = driver.GetBrowserLogs(LogLevel.All).Select(c => c.ToString()).ToList();
|
var errors = driver.GetBrowserLogs(LogLevel.All).Select(c => c.ToString()).ToList();
|
||||||
if (errors.Count == 0)
|
|
||||||
{
|
|
||||||
// Workaround for selenium bug https://github.com/SeleniumHQ/selenium/issues/8229. Getting log does
|
|
||||||
// not work. However some of our test apps provide a mechnanism to read the logs. Try that.
|
|
||||||
|
|
||||||
var logs = (IReadOnlyCollection<object>)((IJavaScriptExecutor)driver).ExecuteScript(
|
|
||||||
"return window.getBrowserLogs && window.getBrowserLogs() || []");
|
|
||||||
|
|
||||||
errors = logs.Select(l => l.ToString()).ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
TakeScreenShot(driver, screenShotPath);
|
TakeScreenShot(driver, screenShotPath);
|
||||||
var exceptionInfo = lastException != null ? ExceptionDispatchInfo.Capture(lastException) :
|
var exceptionInfo = lastException != null ? ExceptionDispatchInfo.Capture(lastException) :
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue