-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[dotnet] test Selenium Manager #16775
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
Open
titusfortner
wants to merge
6
commits into
trunk
Choose a base branch
from
sm_tests_dotnet
base: trunk
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+161
−26
Open
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
5049e23
[dotnet] run selenium manager tests on CI
titusfortner 4f4e296
skip safari
titusfortner 66a72a4
use the right .NET code
titusfortner 07e191d
fix assertion
titusfortner 3f09a1a
always use Selenium Manager when pinned browsers are false
titusfortner 8f05f81
fix subdirectory resolution
titusfortner File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| // <copyright file="SeleniumManagerTest.cs" company="Selenium Committers"> | ||
| // Licensed to the Software Freedom Conservancy (SFC) under one | ||
| // or more contributor license agreements. See the NOTICE file | ||
| // distributed with this work for additional information | ||
| // regarding copyright ownership. The SFC licenses this file | ||
| // to you under the Apache License, Version 2.0 (the | ||
| // "License"); you may not use this file except in compliance | ||
| // with the License. You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, | ||
| // software distributed under the License is distributed on an | ||
| // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| // KIND, either express or implied. See the License for the | ||
| // specific language governing permissions and limitations | ||
| // under the License. | ||
| // </copyright> | ||
|
|
||
| using NUnit.Framework; | ||
| using OpenQA.Selenium.Chrome; | ||
| using OpenQA.Selenium.Edge; | ||
| using OpenQA.Selenium.Environment; | ||
| using OpenQA.Selenium.Firefox; | ||
| using OpenQA.Selenium.Safari; | ||
| using System; | ||
| using System.IO; | ||
|
|
||
| namespace OpenQA.Selenium; | ||
|
|
||
| [TestFixture] | ||
| [Category("SeleniumManager")] | ||
| [IgnoreBrowser(Browser.IE, "IE does not use Selenium Manager")] | ||
| [IgnoreBrowser(Browser.Safari, "Safari does not need Selenium Manager")] | ||
| [IgnoreBrowser(Browser.Remote, "Remote does not use Selenium Manager directly")] | ||
| public class SeleniumManagerTest | ||
| { | ||
| private static readonly string CacheDirectory = System.Environment.GetEnvironmentVariable("SE_CACHE") ?? Path.Combine(".cache", "selenium"); | ||
|
|
||
| private DriverOptions CreateOptionsForCurrentBrowser() | ||
| { | ||
| return EnvironmentManager.Instance.Browser switch | ||
| { | ||
| Browser.Chrome => new ChromeOptions(), | ||
| Browser.Firefox => new FirefoxOptions(), | ||
| Browser.Edge => new EdgeOptions(), | ||
| _ => throw new NotSupportedException($"Browser {EnvironmentManager.Instance.Browser} is not supported for Selenium Manager tests") | ||
| }; | ||
| } | ||
|
|
||
| private DriverService CreateServiceForCurrentBrowser(string driverPath) | ||
| { | ||
| return EnvironmentManager.Instance.Browser switch | ||
| { | ||
| Browser.Chrome => ChromeDriverService.CreateDefaultService(driverPath), | ||
| Browser.Firefox => FirefoxDriverService.CreateDefaultService(driverPath), | ||
| Browser.Edge => EdgeDriverService.CreateDefaultService(driverPath), | ||
| _ => throw new NotSupportedException($"Browser {EnvironmentManager.Instance.Browser} is not supported for Selenium Manager tests") | ||
| }; | ||
| } | ||
|
|
||
| [Test] | ||
| public void ShouldGetDriverAndBrowserPaths() | ||
| { | ||
| var options = CreateOptionsForCurrentBrowser(); | ||
| var driverFinder = new DriverFinder(options); | ||
|
|
||
| string driverPath = driverFinder.GetDriverPath(); | ||
| string browserPath = driverFinder.GetBrowserPath(); | ||
|
|
||
| Assert.That(File.Exists(driverPath), Is.True, $"Driver path should exist: {driverPath}"); | ||
| Assert.That(File.Exists(browserPath), Is.True, $"Browser path should exist: {browserPath}"); | ||
| Assert.That(driverPath, Does.Contain(CacheDirectory), $"Driver path should contain cache directory: {driverPath}"); | ||
| Assert.That(browserPath, Does.Contain(CacheDirectory), $"Browser path should contain cache directory: {browserPath}"); | ||
titusfortner marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| [Test] | ||
| public void ShouldStartDriverService() | ||
| { | ||
| var options = CreateOptionsForCurrentBrowser(); | ||
| var driverFinder = new DriverFinder(options); | ||
|
|
||
| string driverPath = driverFinder.GetDriverPath(); | ||
| var service = CreateServiceForCurrentBrowser(driverPath); | ||
|
|
||
| try | ||
| { | ||
| service.Start(); | ||
| Assert.That(service.ServiceUrl, Is.Not.Null); | ||
| Assert.That(service.ServiceUrl.IsAbsoluteUri, Is.True); | ||
| } | ||
| finally | ||
| { | ||
| service.Dispose(); | ||
| } | ||
|
Comment on lines
+106
to
+117
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.