From 6d83fee518fbedd5ac6e89506af6bd3cd3fe909e Mon Sep 17 00:00:00 2001 From: Pranav K Date: Fri, 31 Jan 2020 16:09:07 -0800 Subject: [PATCH] Only download chrome driver for selenium (#18676) * Only download chrome driver --- src/Components/test/E2ETest/package.json | 4 ++-- src/Components/test/E2ETest/yarn.lock | 8 ++++---- src/ProjectTemplates/test/package.json | 4 ++-- src/Shared/E2ETesting/E2ETesting.props | 9 ++++++--- src/Shared/E2ETesting/E2ETesting.targets | 8 +++++++- src/Shared/E2ETesting/SeleniumStandaloneServer.cs | 12 +++++++++++- src/Shared/E2ETesting/selenium-config.json | 6 ++++++ 7 files changed, 38 insertions(+), 13 deletions(-) create mode 100644 src/Shared/E2ETesting/selenium-config.json diff --git a/src/Components/test/E2ETest/package.json b/src/Components/test/E2ETest/package.json index a84e769eb4..8f9d6e2a12 100644 --- a/src/Components/test/E2ETest/package.json +++ b/src/Components/test/E2ETest/package.json @@ -6,11 +6,11 @@ "private": true, "scripts": { "selenium-standalone": "selenium-standalone", - "prepare": "selenium-standalone install" + "prepare": "selenium-standalone install --config ../../../Shared/E2ETesting/selenium-config.json" }, "author": "", "license": "Apache-2.0", "dependencies": { - "selenium-standalone": "^6.15.4" + "selenium-standalone": "^6.17.0" } } diff --git a/src/Components/test/E2ETest/yarn.lock b/src/Components/test/E2ETest/yarn.lock index 6f2b1cc3e3..937ef009e7 100644 --- a/src/Components/test/E2ETest/yarn.lock +++ b/src/Components/test/E2ETest/yarn.lock @@ -432,10 +432,10 @@ safer-buffer@^2.0.2, safer-buffer@^2.1.0, safer-buffer@~2.1.0: resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg== -selenium-standalone@^6.15.4: - version "6.16.0" - resolved "https://registry.yarnpkg.com/selenium-standalone/-/selenium-standalone-6.16.0.tgz#ffcf02665c58ff7a7472427ae819ba79c15967ac" - integrity sha512-tl7HFH2FOxJD1is7Pzzsl0pY4vuePSdSWiJdPn+6ETBkpeJDiuzou8hBjvWYWpD+eIVcOrmy3L0R3GzkdHLzDw== +selenium-standalone@^6.17.0: + version "6.17.0" + resolved "https://registry.yarnpkg.com/selenium-standalone/-/selenium-standalone-6.17.0.tgz#0f24b691836205ee9bc3d7a6f207ebcb28170cd9" + integrity sha512-5PSnDHwMiq+OCiAGlhwQ8BM9xuwFfvBOZ7Tfbw+ifkTnOy0PWbZmI1B9gPGuyGHpbQ/3J3CzIK7BYwrQ7EjtWQ== dependencies: async "^2.6.2" commander "^2.19.0" diff --git a/src/ProjectTemplates/test/package.json b/src/ProjectTemplates/test/package.json index 3a1ea190f6..c48c6bd8a4 100644 --- a/src/ProjectTemplates/test/package.json +++ b/src/ProjectTemplates/test/package.json @@ -6,11 +6,11 @@ "private": true, "scripts": { "selenium-standalone": "selenium-standalone", - "prepare": "selenium-standalone install" + "prepare": "selenium-standalone install --config ../../Shared/E2ETesting/selenium-config.json" }, "author": "", "license": "Apache-2.0", "dependencies": { - "selenium-standalone": "^6.15.4" + "selenium-standalone": "^6.17.0" } } diff --git a/src/Shared/E2ETesting/E2ETesting.props b/src/Shared/E2ETesting/E2ETesting.props index e31cbd93ac..64e74c095e 100644 --- a/src/Shared/E2ETesting/E2ETesting.props +++ b/src/Shared/E2ETesting/E2ETesting.props @@ -6,6 +6,9 @@ $([MSBuild]::EnsureTrailingSlash('$(RepoRoot)'))artifacts\tmp\selenium\ true + + $([MSBuild]::NormalizePath($(MSBuildThisFileDirectory)selenium-config.json)) + true @@ -39,12 +42,12 @@ <_Parameter1>Microsoft.AspNetCore.E2ETesting.CI - <_Parameter2>$(ContinuousIntegrationBuild) + <_Parameter2>$(ContinuousIntegrationBuild) - + <_Parameter1>Microsoft.AspNetCore.E2ETesting.ScreenshotsPath - <_Parameter2>$(SeleniumScreenShotsFolderPath) + <_Parameter2>$(SeleniumScreenShotsFolderPath) diff --git a/src/Shared/E2ETesting/E2ETesting.targets b/src/Shared/E2ETesting/E2ETesting.targets index 49b5fbbd07..f3e73276b0 100644 --- a/src/Shared/E2ETesting/E2ETesting.targets +++ b/src/Shared/E2ETesting/E2ETesting.targets @@ -51,7 +51,7 @@ <_PackageJsonLinesContent>@(_PackageJsonLines) - <_PackageJsonSeleniumPackage>"selenium-standalone": "^6.15.4" + <_PackageJsonSeleniumPackage>"selenium-standalone": "^6.17.0" Microsoft.AspNetCore.Testing.Selenium.Supported <_Parameter2>$(_SeleniumE2ETestsSupportedAttributeValue) + + + <_Parameter1>Microsoft.AspNetCore.Testing.SeleniumConfigPath + <_Parameter2>$(SeleniumConfigPath) + diff --git a/src/Shared/E2ETesting/SeleniumStandaloneServer.cs b/src/Shared/E2ETesting/SeleniumStandaloneServer.cs index 91f80afb2b..8ca5654243 100644 --- a/src/Shared/E2ETesting/SeleniumStandaloneServer.cs +++ b/src/Shared/E2ETesting/SeleniumStandaloneServer.cs @@ -86,10 +86,20 @@ namespace Microsoft.AspNetCore.E2ETesting var port = FindAvailablePort(); var uri = new UriBuilder("http", "localhost", port, "/wd/hub").Uri; + var seleniumConfigPath = typeof(SeleniumStandaloneServer).Assembly + .GetCustomAttributes() + .FirstOrDefault(k => k.Key == "Microsoft.AspNetCore.Testing.SeleniumConfigPath") + ?.Value; + + if (seleniumConfigPath == null) + { + throw new InvalidOperationException("Selenium config path not configured. Does this project import the E2ETesting.targets?"); + } + var psi = new ProcessStartInfo { FileName = "npm", - Arguments = $"run selenium-standalone start -- -- -port {port}", + Arguments = $"run selenium-standalone start -- --config \"{seleniumConfigPath}\" -- -port {port}", RedirectStandardOutput = true, RedirectStandardError = true, }; diff --git a/src/Shared/E2ETesting/selenium-config.json b/src/Shared/E2ETesting/selenium-config.json new file mode 100644 index 0000000000..95c078e2c7 --- /dev/null +++ b/src/Shared/E2ETesting/selenium-config.json @@ -0,0 +1,6 @@ +{ + "drivers": { + "chrome": {} + }, + "ignoreExtraDrivers": true +} \ No newline at end of file