Coder Social home page Coder Social logo

atata-framework / atata-webdriversetup Goto Github PK

View Code? Open in Web Editor NEW
3.0 4.0 0.0 264 KB

Sets up browser drivers for Selenium WebDriver

License: Apache License 2.0

C# 100.00%
atata webdriver browser-drivers chromedriver selenium operadriver edgedriver internetexplorerdriver geckodriver

atata-webdriversetup's People

Contributors

yevgeniyshunevych avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

atata-webdriversetup's Issues

Add configuration to specify x32/x64 architecture

  • Add Architecture enum with values: Auto, X32, X64.
  • Add property to DriverSetupOptions:
    public Architecture Architecture { get; set; }
  • Add methods to DriverSetupOptionsBuilder<TBuilder, TContext>:
    public TBuilder WithX32Architecture();
    
    public TBuilder WithX64Architecture();
    
    public TBuilder WithArchitecture(Architecture architecture);
  • Update driver setup strategies to rely on architecture provided.

How to ignore HTTPS certificate errors when using AtataContext.GlobalConfiguration.AutoSetUpConfiguredDriversAsync()

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.

AtataContextBuilder.AutoSetUpDriverToUse() throws exception when used with the new Chrome version 121.0.6167.185

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(IEnumerable1 browserNames)
DriverSetup.AutoSetUpSafelyAsync(IEnumerable1 browserNames) lambda_method393(Closure) MethodInfoExtensions.InvokeStaticAsLambda(MethodInfo method, Object[] args) AtataContextBuilder.InvokeAutoSetUpSafelyMethodOfDriverSetup(IEnumerable1 browserNames)
AtataContextBuilder.AutoSetUpDriverToUse()

Edge web driver creation fails with "End of Central Directory record could not be found."

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.

Webdriver can't be downloaded for new chrome ver. 115 and higher.

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/

  1. New base url is https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/115.0.5790.98/linux64/chrome-linux64.zip
    But Atata.WebDriverSetup tries to get appropriate driver version using old url: https://chromedriver.storage.googleapis.com
  2. the URL parameters are also a bit changed.
  3. it seems that it is not possible to just get latest release or get webdriver if you don't know the exact driver version.

Detect which browsers are installed on the system and instantiate the corresponding WebDriver

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:

  • Probe for installed browsers in a specified order of preference and stop on the first one that is detected
    • The site may only officially support some browsers, so it will be either just those ones, or a few preferred browsers followed by "everything else"
  • Install the corresponding selenium driver executable and instantiate the corresponding Selenium 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?

Default driver setup configurations

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);

Usage

Tell DriverSetup to use x32 architecture for Internet Explorer driver by default:

DriverSetup.GetDefaultConfiguration(BrowserNames.InternetExplorer)
    .WithX32Architecture();

Add async SetUp* methods

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();

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.