atata-framework / atata-webdriversetup Goto Github PK
View Code? Open in Web Editor NEWSets up browser drivers for Selenium WebDriver
License: Apache License 2.0
Sets up browser drivers for Selenium WebDriver
License: Apache License 2.0
Architecture
enum with values: Auto
, X32
, X64
.DriverSetupOptions
:
public Architecture Architecture { get; set; }
DriverSetupOptionsBuilder<TBuilder, TContext>
:
public TBuilder WithX32Architecture();
public TBuilder WithX64Architecture();
public TBuilder WithArchitecture(Architecture architecture);
Atata.Cli
should be used to detect installed browser version thru CLI.
Hello,
So I've recently upgraded my Atata project from 1.x to 2.x (currently using Atata.WebDriverSetup 2.5.0) and everything builds properly, but I can't run my tests yet, as in my test setup logic, I am using AtataContext.GlobalConfiguration.AutoSetUpConfiguredDriversAsync()
and it keeps throwing an exception at this point:
at System.Net.Http.ConnectHelper.<EstablishSslConnectionAsyncCore>d__4.MoveNext()
at System.Threading.Tasks.ValueTask`1.get_Result()
at System.Runtime.CompilerServices.ConfiguredValueTaskAwaitable`1.ConfiguredValueTaskAwaiter.GetResult()
at System.Net.Http.HttpConnectionPool.<ConnectAsync>d__52.MoveNext()
at System.Threading.Tasks.ValueTask`1.get_Result()
at System.Runtime.CompilerServices.ConfiguredValueTaskAwaitable`1.ConfiguredValueTaskAwaiter.GetResult()
at System.Net.Http.HttpConnectionPool.<CreateHttp11ConnectionAsync>d__53.MoveNext()
at System.Threading.Tasks.ValueTask`1.get_Result()
at System.Runtime.CompilerServices.ConfiguredValueTaskAwaitable`1.ConfiguredValueTaskAwaiter.GetResult()
at System.Net.Http.HttpConnectionPool.<GetHttpConnectionAsync>d__45.MoveNext()
at System.Threading.Tasks.ValueTask`1.get_Result()
at System.Runtime.CompilerServices.ConfiguredValueTaskAwaitable`1.ConfiguredValueTaskAwaiter.GetResult()
at System.Net.Http.HttpConnectionPool.<SendWithRetryAsync>d__47.MoveNext()
at System.Net.Http.RedirectHandler.<SendAsync>d__4.MoveNext()
at System.Net.Http.HttpClient.<FinishSendAsyncUnbuffered>d__71.MoveNext()
at System.Net.Http.HttpClient.<GetStringAsyncCore>d__35.MoveNext()
at Atata.WebDriverSetup.HttpRequestExecutor.DownloadString(String url)
at Atata.WebDriverSetup.ReliableHttpRequestExecutor.<>c__DisplayClass5_0.<DownloadString>b__0()
at Atata.WebDriverSetup.ReliableHttpRequestExecutor.ExecuteWithRetries[TResult](Func`1 operation)
at Atata.WebDriverSetup.ReliableHttpRequestExecutor.DownloadString(String url)
at Atata.WebDriverSetup.ChromeDriverSetupStrategy.GetDriverVersionCorrespondingToBrowserVersion(String browserVersion)
at Atata.WebDriverSetup.XmlFileDriverVersionCache.GetOrAdd(String browserVersion, DateTime minimumAcceptableTimestamp, Func`2 versionResolveFunction)
at Atata.WebDriverSetup.CachedDriverVersionCorrespondingToBrowserVersionResolver.GetDriverVersionCorrespondingToBrowserVersion(String browserVersion)
at Atata.WebDriverSetup.DriverVersionResolver.ResolveByBrowserVersion(String version)
at Atata.WebDriverSetup.DriverVersionResolver.ResolveCorrespondingVersion()
at Atata.WebDriverSetup.DriverVersionResolver.ResolveCorrespondingOrLatestVersion()
at Atata.WebDriverSetup.DriverSetupConfigurationBuilder.ResolveDriverVersion(IDriverSetupStrategy setupStrategy, String version)
at Atata.WebDriverSetup.DriverSetupConfigurationBuilder.ExecuteSetUp()
at Atata.WebDriverSetup.DriverSetupConfigurationBuilder.SetUp()
at System.Threading.Tasks.Task`1.InnerInvoke()
at System.Threading.Tasks.Task.<>c.<.cctor>b__274_0(Object obj)
at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
--- End of stack trace from previous location ---
at Atata.WebDriverSetup.DriverSetupConfigurationBuilder.<SetUpAsync>d__13.MoveNext()
at Atata.WebDriverSetup.DriverSetup.<AutoSetUpAsync>d__27.MoveNext()
at Atata.WebDriverSetup.DriverSetup.<AutoSetUpAsync>d__29.MoveNext()
at Atata.WebDriverSetup.DriverSetup.<AutoSetUpSafelyAsync>d__31.MoveNext()
at Atata.WebDriverSetup.DriverSetup.AutoSetUpSafely(IEnumerable`1 browserNames)
at Atata.MethodInfoExtensions.InvokeStaticAsLambda(MethodInfo method, Object[] args)
at Atata.AtataContextBuilder.InvokeAutoSetUpSafelyMethodOfDriverSetup(IEnumerable`1 browserNames)
at Atata.AtataContextBuilder.AutoSetUpDriverToUse()
at OurClientMatters.UiTests.SetUpFixture.GlobalSetUp() in C:\Users\mmiftah\source\repos\OCM\OCM.UiTests\SetUpFixture.cs:line 23
I know what the cause of the issue is: my work network has MITM-HTTPS decryption, so all the HTTPS certificates resolve to a top-level CA that is self-signed, so it will always been invalid. Is there any way to configure the call to AutoSetUpConfiguredDriversAsync()
to ignore HTTPS certificate errors?
I note that it calls Atata.WebDriverSetup.DriverSetup.AutoSetUpSafely(IEnumerable``1 browserNames)
, which is why I posted the issue here.
The issue is emerged after Chrome update to version 121.0.6167.185 (Official Build) (64-bit)
The following error is displayed when test is launched:
"System.IO.InvalidDataException : End of Central Directory record could not be found."
Stack Trace:โ
ZipArchive.ReadEndOfCentralDirectory()
ZipArchive.ctor(Stream stream, ZipArchiveMode mode, Boolean leaveOpen, Encoding entryNameEncoding)
ZipFile.Open(String archiveFileName, ZipArchiveMode mode, Encoding entryNameEncoding)
DriverSetupExecutor.ExtractFromZip(String archiveFilePath, String destinationFilePath)
DriverSetupExecutor.ExtractDownloadedFile(String sourceFilePath, String destinationFilePath)
DriverSetupExecutor.DownloadDriverIfMissing(String version, String driverDestinationDirectoryPath, String driverDestinationFileName)
DriverSetupExecutor.SetUp(String version)
DriverSetupConfigurationBuilder.ExecuteSetUp()
DriverSetupConfigurationBuilder.SetUp()
Task1.InnerInvoke() ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state) --- End of stack trace from previous location --- ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state) Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread) --- End of stack trace from previous location --- DriverSetupConfigurationBuilder.SetUpAsync() DriverSetup.AutoSetUpAsync(String browserName) DriverSetup.AutoSetUpAsync(IEnumerable
1 browserNames)
DriverSetup.AutoSetUpSafelyAsync(IEnumerable1 browserNames) lambda_method393(Closure) MethodInfoExtensions.InvokeStaticAsLambda(MethodInfo method, Object[] args) AtataContextBuilder.InvokeAutoSetUpSafelyMethodOfDriverSetup(IEnumerable
1 browserNames)
AtataContextBuilder.AutoSetUpDriverToUse()
Starting today, we get the following exception when calling DriverSetup.AutoSetUp("Edge")
:
OpenQA.Selenium.WebDriverException : Creating the web driver failed with the message "End of Central Directory record could not be found.". This can mean that there is a leftover web driver process that you have to kill manually. Full exception: System.IO.InvalidDataException: End of Central Directory record could not be found.
at System.IO.Compression.ZipArchive.ReadEndOfCentralDirectory()
at System.IO.Compression.ZipArchive..ctor(Stream stream, ZipArchiveMode mode, Boolean leaveOpen, Encoding entryNameEncoding)
at System.IO.Compression.ZipFile.Open(String archiveFileName, ZipArchiveMode mode, Encoding entryNameEncoding)
at Atata.WebDriverSetup.DriverSetupExecutor.ExtractFromZip(String archiveFilePath, String destinationFilePath)
at Atata.WebDriverSetup.DriverSetupExecutor.ExtractDownloadedFile(String sourceFilePath, String destinationFilePath)
at Atata.WebDriverSetup.DriverSetupExecutor.DownloadDriverIfMissing(String version, String driverDestinationDirectoryPath, String driverDestinationFileName)
at Atata.WebDriverSetup.DriverSetupExecutor.SetUp(String version)
at Atata.WebDriverSetup.DriverSetupConfigurationBuilder.ExecuteSetUp()
at Atata.WebDriverSetup.DriverSetupConfigurationBuilder.SetUp()
at Atata.WebDriverSetup.DriverSetup.AutoSetUp(String browserName)
This only seems to be happening under GitHub-hosted Ubuntu runners of GitHub Actions. It doesn't happen on Ubuntu runners hosted by WarpBuild, or under GitHub-hosted Windows runners (nor can I reproduce it on my Windows machine).
I suppose something recently changed in how the Edge web driver is made available. This run on the 22nd succeeded, and this other one failed today, without any changes made to the affected code. Running the previously succeeding older run again also fails, confirming that this is something with the driver's download URL.
The following exception is raised when launching tests:
"OneTimeSetUp: System.Net.Http.HttpRequestException : Response status code does not indicate success: 404 (Not Found)."
The AutoSetUpDriverToUse() is called on the OneTimeSetUp step.
The most possible reason is that starting from version 115 Google changed the URLs for webdriver downloading:
https://chromedriver.chromium.org/downloads
https://googlechromelabs.github.io/chrome-for-testing/
My Selenium-based .NET Windows desktop program will be automating some specific laborous operations with a website that doesn't have a web API.
As such, it will be installed on user machines which may have any combination of browsers installed.
In the README, I see how to install driver(s) for specific installed browsers -- but there seems to be no information on how to detect which browsers are installed on the system in the first place.
I'd like to be able to:
WebDriver
class for whatever was detected, optionally with specific parameters that I prepare beforehand (e.g. for some browsers, I need to install addons to be able to work with the site).Can I do this with Atata.WebDriverSetup?
Add method to DriverSetup
:
/// <summary>
/// Gets the default driver setup configuration builder.
/// </summary>
/// <param name="browserName">Name of the browser.</param>
/// <example>
/// Can be used to set, for example, default x32 architecture for Internet Explorer driver.
/// <code>
/// DriverSetup.GetDefaultConfiguration(BrowserNames.InternetExplorer)
/// .WithX32Architecture();
/// </code>
/// </example>
/// <returns>The <see cref="DriverSetupOptionsBuilder"/> instance.</returns>
public static DriverSetupOptionsBuilder GetDefaultConfiguration(string browserName);
Tell DriverSetup
to use x32 architecture for Internet Explorer driver by default:
DriverSetup.GetDefaultConfiguration(BrowserNames.InternetExplorer)
.WithX32Architecture();
Add method to DriverSetupConfigurationBuilder
:
public async Task<DriverSetupResult> SetUpAsync();
Add methods to DriverSetup
:
public static async Task<DriverSetupResult> AutoSetUpAsync(string browserName);
public static async Task<DriverSetupResult[]> AutoSetUpAsync(params string[] browserNames);
public static async Task<DriverSetupResult[]> AutoSetUpAsync(IEnumerable<string> browserNames);
public static async Task<DriverSetupResult[]> AutoSetUpSafelyAsync(IEnumerable<string> browserNames);
public static async Task<DriverSetupResult[]> SetUpPendingConfigurationsAsync();
The bug was reported as StackOverflow question: https://stackoverflow.com/questions/69667812/autosetupconfigureddrivers-occasionally-throws-an-index-out-of-range-exception
The problem is with DriverSetup.PendingConfigurations
property that is used simultaneously by parallel threads.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.