Azure Webjob - Timeout when trying to open ChromeDriver - c#

I'm trying to use Azure WebApps, with Webjobs, to Test applications.
Locally, it works great. But when I build to cloud it happens the problem listed above.
Apperently the file was found, but it stays wainting until timeout.
Does anybody knows how to solve this?
I'm using C# Selenium WebDriver.
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using System;
using System.Diagnostics;
using System.IO;
namespace Ololu_WebJob
{
class Program
{
static void Main()
{
IWebDriver driver = new ChromeDriver();
driver.Url = "my_url";
Console.WriteLine(driver.Title);
driver.Quit();
}
}
}
/*
LOG:
[02/10/2019 12:27:51 > 7f9c27: SYS INFO] Status changed to Initializing
[02/10/2019 12:27:51 > 7f9c27: SYS INFO] Job directory change detected: Job file 'Ololu_WebJob.exe' timestamp differs between source and working directories.
[02/10/2019 12:27:53 > 7f9c27: SYS INFO] Run script 'chromedriver.exe' with script host - 'WindowsScriptHost'
[02/10/2019 12:27:53 > 7f9c27: SYS INFO] Status changed to Running
[02/10/2019 12:27:53 > 7f9c27: INFO] Starting ChromeDriver 2.46.628402 (536cd7adbad73a3783fdc2cab92ab2ba7ec361e1) on port 9515
[02/10/2019 12:27:53 > 7f9c27: INFO] Only local connections are allowed.
[02/10/2019 12:27:53 > 7f9c27: INFO] Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
[02/10/2019 12:31:55 > 7f9c27: ERR ] Command 'cmd /c ""chromedriv ...' was aborted due to no output nor CPU activity for 121 seconds. You can increase the SCM_COMMAND_IDLE_TIMEOUT app setting (or WEBJOBS_IDLE_TIMEOUT if this is a WebJob) if needed.
cmd /c ""chromedriver.exe""
[02/10/2019 12:31:55 > 7f9c27: SYS INFO] Status changed to Failed
[02/10/2019 12:31:55 > 7f9c27: SYS ERR ] System.AggregateException: One or more errors occurred. ---> Kudu.Core.Infrastructure.CommandLineException: Command 'cmd /c ""chromedriv ...' was aborted due to no output nor CPU activity for 121 seconds. You can increase the SCM_COMMAND_IDLE_TIMEOUT app setting (or WEBJOBS_IDLE_TIMEOUT if this is a WebJob) if needed.
cmd /c ""chromedriver.exe""
at Kudu.Core.Infrastructure.IdleManager.WaitForExit(IProcess process) in C:\Kudu Files\Private\src\master\Kudu.Core\Infrastructure\IdleManager.cs:line 45
at Kudu.Core.Infrastructure.ProcessExtensions.<Start>d__12.MoveNext() in C:\Kudu Files\Private\src\master\Kudu.Core\Infrastructure\ProcessExtensions.cs:line 212
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Kudu.Core.Infrastructure.Executable.<ExecuteAsync>d__31.MoveNext() in C:\Kudu Files\Private\src\master\Kudu.Core\Infrastructure\Executable.cs:line 255
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
at System.Threading.Tasks.Task`1.get_Result()
at Kudu.Core.Infrastructure.Executable.ExecuteInternal(ITracer tracer, Func`2 onWriteOutput, Func`2 onWriteError, Encoding encoding, String arguments, Object[] args) in C:\Kudu Files\Private\src\master\Kudu.Core\Infrastructure\Executable.cs:line 216
at Kudu.Core.Infrastructure.Executable.ExecuteReturnExitCode(ITracer tracer, Action`1 onWriteOutput, Action`1 onWriteError, String arguments, Object[] args) in C:\Kudu Files\Private\src\master\Kudu.Core\Infrastructure\Executable.cs:line 165
at Kudu.Core.Jobs.BaseJobRunner.RunJobInstance(JobBase job, IJobLogger logger, String runId, String trigger, ITracer tracer, Int32 port) in C:\Kudu Files\Private\src\master\Kudu.Core\Jobs\BaseJobRunner.cs:line 272
---> (Inner Exception #0) ExitCode: -1, Output: Command 'cmd /c ""chromedriv ...' was aborted due to no output nor CPU activity for 121 seconds. You can increase the SCM_COMMAND_IDLE_TIMEOUT app setting (or WEBJOBS_IDLE_TIMEOUT if this is a WebJob) if needed., Error: Command 'cmd /c ""chromedriv ...' was aborted due to no output nor CPU activity for 121 seconds. You can increase the SCM_COMMAND_IDLE_TIMEOUT app setting (or WEBJOBS_IDLE_TIMEOUT if this is a WebJob) if needed., Kudu.Core.Infrastructure.CommandLineException: Command 'cmd /c ""chromedriv ...' was aborted due to no output nor CPU activity for 121 seconds. You can increase the SCM_COMMAND_IDLE_TIMEOUT app setting (or WEBJOBS_IDLE_TIMEOUT if this is a WebJob) if needed.
cmd /c ""chromedriver.exe""
at Kudu.Core.Infrastructure.IdleManager.WaitForExit(IProcess process) in C:\Kudu Files\Private\src\master\Kudu.Core\Infrastructure\IdleManager.cs:line 45
at Kudu.Core.Infrastructure.ProcessExtensions.<Start>d__12.MoveNext() in C:\Kudu Files\Private\src\master\Kudu.Core\Infrastructure\ProcessExtensions.cs:line 212
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Kudu.Core.Infrastructure.Executable.<ExecuteAsync>d__31.MoveNext() in C:\Kudu Files\Private\src\master\Kudu.Core\Infrastructure\Executable.cs:line 255<---
*/

Per my experience, you can not directly use selenium and chromedriver without an installed instance of Chrome or Chromium on Azure WebApp, as the requirement of ChromeDriver Setup said below.
Ensure Chromium/Google Chrome is installed in a recognized location
ChromeDriver expects you to have Chrome installed in the default location for your platform. You can also force ChromeDriver to use a custom location by setting a special capability.
However, due to some restricts of Azure WebApp sandbox which include Win32k.sys (User32/GDI32) Restrictions and Local Address Requests, you could not start Chrome or Chromium without GDI support via chromedriver even if you uploaded a portable distribution of Chrome or Chromium into Azure WebApp and configured environment variables.
Although your error information did not point out the real reason of the issue in your C# code, I got the error information in Python on Azure WebApp as below.
So a workaround way is to directly use selenium and chromedriver on Azure VM. Or considering for your scenario, you can start chromedriver on default port 9515 on Azure VM and configure the VM NSG role to allow the inbound of port 9515, then to use class OpenQA.Selenium.Remote.RemoteWebDriver to connect the remote webdriver in Azure WebJob.
Here is a sample code for using RemoteWebDriver which comes from C# (CSharp) OpenQA.Selenium.Remote RemoteWebDriver.FindElement Examples
IWebDriver webDriver = new RemoteWebDriver(new Uri("http://<vm host ip>:9515"), DesiredCapabilities.Chrome());

Related

Starting Selenium Grid with Selenium 4 for C#

I am having issues running Selenium Grid from Visual Studio from Csharp using Selenium 4. I keep getting the error:
Message:
System.InvalidOperationException : Could not start a new session. Could not start a new session. Error while creating session with the driver service. Stopping driver service: Driver server process died prematurely.
Build info: version: '4.1.1', revision: 'e8fcc2cecf'
System info: host: 'ATTPA-1450', ip: '172.26.0.1', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '11.0.12'
Driver info: driver.version: unknown
Build info: version: '4.1.1', revision: 'e8fcc2cecf'
System info: host: 'ATTPA-1450', ip: '172.26.0.1', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '11.0.12'
Driver info: driver.version: unknown
Build info: version: '4.1.1', revision: 'e8fcc2cecf'
System info: host: 'ATTPA-1450', ip: '172.26.0.1', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '11.0.12'
Driver info: driver.version: unknown (SessionNotCreated)
TearDown : System.NullReferenceException : Object reference not set to an instance of an object.
Stack Trace:
WebDriver.UnpackAndThrowOnError(Response errorResponse)
WebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
WebDriver.StartSession(ICapabilities desiredCapabilities)
WebDriver.ctor(ICommandExecutor executor, ICapabilities capabilities)
RemoteWebDriver.ctor(ICommandExecutor commandExecutor, ICapabilities desiredCapabilities)
RemoteWebDriver.ctor(Uri remoteAddress, ICapabilities desiredCapabilities, TimeSpan commandTimeout)
WebDriverFactory.OpenBrowser() line 28
BaseTest.Test_Setup() line 54*
Can you tell me what I am missing. I downloaded the .jar file from this location - https://www.selenium.dev/downloads/
I started selenium hub on my local machine here:
I then registered selenium node here:
I made sure I can get to grid here:
Here is my code (I initially used http://localhost:4444/wd/hub) but still got the same error:
When I change the code to
I get this error
_driver = new RemoteWebDriver(new Uri("http://localhost:4444/wd/hub"), browserOptions);
Message:
OpenQA.Selenium.WebDriverException : The HTTP request to the remote WebDriver server for URL http://localhost:4444/wd/hub/session timed out after 60 seconds.
----> System.Threading.Tasks.TaskCanceledException : The operation was canceled.
----> System.IO.IOException : Unable to read data from the transport connection: The I/O operation has been aborted because of either a thread exit or an application request..
----> System.Net.Sockets.SocketException : The I/O operation has been aborted because of either a thread exit or an application request.
TearDown : System.NullReferenceException : Object reference not set to an instance of an object.*
This error message...
System.InvalidOperationException : Could not start a new session. Could not start a new session. Error while creating session with the driver service. Stopping driver service: Driver server process died prematurely.
Build info: version: '4.1.1', revision: 'e8fcc2cecf'
System info: host: 'ATTPA-1450', ip: '172.26.0.1', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '11.0.12'
Driver info: driver.version: unknown
...implies that the ChromeDriver was unable to initiate/spawn a new Browsing Context i.e. Chrome Browser session.
Possibly your main issue is the incompatibility between the version of the binaries you are using as the ChromeDriver version is not getting detected:
Driver info: driver.version: unknown
Solution
Ensure that:
ChromeDriver is updated to current ChromeDriver 97.0.4692.71 level.
Chrome is updated to current chrome=Version 97.0.4692.71 (as per chrome=97.0.4692.71 release notes).

Issue initializing DB when run from PowerShell prompt

The Issue:
Perform the following steps to recreate the issue:
cd C:\Temp
New-Item -ItemType Directory -Name init-db-issue
cd .\init-db-issue
# Download ASP.NET Core sample projects
Invoke-WebRequest -Uri https://codeload.github.com/dotnet/AspNetCore.Docs/zip/main -OutFile main.zip
# Expanding takes a while
Expand-Archive -Path .\main.zip
cd .\main\AspNetCore.Docs-main\aspnetcore\security\authorization\secure-data\samples\final3
dotnet user-secrets set SeedUserPW Secret123!
# Drop the database in case it already exists
sqlcmd -S "(localdb)\MSSQLLocalDB" -Q "DROP DATABASE [aspnet-ContactManager-02]"
At this point, do not load the project in vs or vscode. Simply run the project from a PowerShell prompt:
dotnet run
Here's what I get on my system:
PS C:\Temp\init-db-issue\main\AspNetCore.Docs-main\aspnetcore\security\authorization\secure-data\samples\final3> dotnet run
C:\Program Files\dotnet\sdk\5.0.200\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.EolTargetFrameworks.targets(28,5): warning NETSDK1138: The target framework 'netcoreapp3.0' is out of support and will not receive security updates in the future. Please refer to https://aka.ms/dotnet-core-support for more information about the support policy. [C:\Temp\init-db-issue\main\AspNetCore.Docs-main\aspnetcore\security\authorization\secure-data\samples\final3\ContactManager.csproj]
C:\Program Files\dotnet\sdk\5.0.200\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.EolTargetFrameworks.targets(28,5): warning NETSDK1138: The target framework 'netcoreapp3.0' is out of support and will not receive security updates in the future. Please refer to https://aka.ms/dotnet-core-support for more information about the support policy. [C:\Temp\init-db-issue\main\AspNetCore.Docs-main\aspnetcore\security\authorization\secure-data\samples\final3\ContactManager.csproj]
C:\Program Files\dotnet\sdk\5.0.200\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.EolTargetFrameworks.targets(28,5): warning NETSDK1138: The target framework 'netcoreapp3.0' is out of support and will not receive security updates in the future. Please refer to https://aka.ms/dotnet-core-support for more information about the support policy. [C:\Temp\init-db-issue\main\AspNetCore.Docs-main\aspnetcore\security\authorization\secure-data\samples\final3\ContactManager.csproj]
fail: ContactManager.Program[0]
An error occurred seeding the DB.
System.AggregateException: One or more errors occurred. (Value cannot be null. (Parameter 'password'))
---> System.ArgumentNullException: Value cannot be null. (Parameter 'password')
at Microsoft.AspNetCore.Identity.UserManager`1.CreateAsync(TUser user, String password)
at ContactManager.Data.SeedData.EnsureUser(IServiceProvider serviceProvider, String testUserPw, String UserName) in C:\Temp\init-db-issue\main\AspNetCore.Docs-main\aspnetcore\security\authorization\secure-data\samples\final3\Data\SeedData.cs:line 49
at ContactManager.Data.SeedData.Initialize(IServiceProvider serviceProvider, String testUserPw) in C:\Temp\init-db-issue\main\AspNetCore.Docs-main\aspnetcore\security\authorization\secure-data\samples\final3\Data\SeedData.cs:line 26
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at System.Threading.Tasks.Task.Wait()
at ContactManager.Program.Main(String[] args) in C:\Temp\init-db-issue\main\AspNetCore.Docs-main\aspnetcore\security\authorization\secure-data\samples\final3\Program.cs:line 35
info: Microsoft.Hosting.Lifetime[0]
Now listening on: http://localhost:5000
info: Microsoft.Hosting.Lifetime[0]
Now listening on: https://localhost:5001
info: Microsoft.Hosting.Lifetime[0]
Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
Hosting environment: Production
info: Microsoft.Hosting.Lifetime[0]
Content root path: C:\Temp\init-db-issue\main\AspNetCore.Docs-main\aspnetcore\security\authorization\secure-data\samples\final3
Note the following part:
fail: ContactManager.Program[0]
An error occurred seeding the DB.
System.AggregateException: One or more errors occurred. (Value cannot be null. (Parameter 'password'))
Now, load the project in vs but do not run it from there:
Start-Process .\ContactManager.csproj
Run the app from the PowerShell prompt:
dotnet run
Now I don't get the message An error occurred seeding the DB and the DB is indeed seeded.
Question:
Why does the issue go away when we simply load the project into Visual Studio? I would expect the project to work fine when running it via dotnet run without needing to also run Visual Studio. Is this a bug? Or is it due to some aspect of how the project is setup?
The project can be viewed here.
This project is the example used in the following tutorial:
Create an ASP.NET Core web app with user data protected by authorization
The issue is that Properties/launchSettings.json does not exist.
See this comment:
https://github.com/dotnet/AspNetCore.Docs/issues/21668#issuecomment-795543707
Here's a minimal test case which demonstrates the issue:
cd C:\Temp
mkdir init-db-issue-new-app
cd init-db-issue-new-app
dotnet new webapp -o ContactManager -au Individual -uld
cd .\ContactManager
dotnet user-secrets set SeedUserPW abc
#"
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using System;
namespace ContactManager
{
public class Program
{
public static void Main(string[] args)
{
var host = CreateHostBuilder(args).Build();
var config = host.Services.GetRequiredService<IConfiguration>();
var testUserPw = config["SeedUserPW"];
Console.WriteLine("{0}", testUserPw);
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
}
}
"# | Set-Content .\Program.cs
dotnet run # abc is displayed
mv .\Properties\launchSettings.json .\Properties\_launchSettings.json
dotnet run # abc is not displayed

SQLite error "database is locked" when publishig on linux azure app service (.net core 3.1). But i am not using SQLite

When the application is published on windows it works perfectly. I am not using SQLite, I´m using SqlServer.
Error log from azure:
2020-11-27T17:36:08.879028391Z Documentation: http://aka.ms/webapp-linux
2020-11-27T17:36:08.879035191Z Dotnet quickstart: https://aka.ms/dotnet-qs
2020-11-27T17:36:08.879041791Z ASP .NETCore Version: 3.1.8
2020-11-27T17:36:08.879048191Z Note: Any data outside '/home' is not persisted
2020-11-27T17:36:09.077744493Z Running oryx create-script -appPath /home/site/wwwroot -output /opt/startup/startup.sh -defaultAppFilePath /defaulthome/hostingstart/hostingstart.dll -bindPort 8080 -userStartupCommand ''
2020-11-27T17:36:09.582281718Z Cound not find build manifest file at '/home/site/wwwroot/oryx-manifest.toml'
2020-11-27T17:36:09.583285560Z Could not find operation ID in manifest. Generating an operation id...
2020-11-27T17:36:09.583308261Z Build Operation ID: cf1c55c9-70a7-4bd1-bfa2-e3a2350cf36c
2020-11-27T17:36:10.816104146Z Writing output script to '/opt/startup/startup.sh'
2020-11-27T17:36:11.085709074Z Trying to find the startup DLL name...
2020-11-27T17:36:11.086560810Z Found the startup D name: Digibyte.API.dll
2020-11-27T17:36:11.088017070Z Running the command: dotnet "Digibyte.API.dll"
2020-11-27T17:36:47.812986572Z [41m[30mfail[39m[22m[49m: Microsoft.EntityFrameworkCore.Database.Command[20102]
2020-11-27T17:36:47.813053275Z Failed executing DbCommand (30,042ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
2020-11-27T17:36:47.813066676Z PRAGMA journal_mode = 'wal';
2020-11-27T17:36:47.944070916Z Unhandled exception. System.AggregateException: One or more errors occurred. (SQLite Error 5: 'database is locked'.)
**2020-11-27T17:36:47.944105917Z ---> Microsoft.Data.Sqlite.SqliteException (0x80004005): SQLite Error 5: 'database is locked'.**
2020-11-27T17:36:47.944116518Z at Microsoft.Data.Sqlite.SqliteException.ThrowExceptionForRC(Int32 rc, sqlite3 db)
2020-11-27T17:36:47.944124918Z at Microsoft.Data.Sqlite.SqliteDataReader.NextResult()
2020-11-27T17:36:47.944132618Z at Microsoft.Data.Sqlite.SqliteCommand.ExecuteReader(CommandBehavior behavior)
2020-11-27T17:36:47.944140519Z at Microsoft.Data.Sqlite.SqliteCommand.ExecuteReader()
2020-11-27T17:36:47.944148119Z at Microsoft.Data.Sqlite.SqliteCommand.ExecuteNonQuery()
2020-11-27T17:36:47.944155719Z at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteNonQuery(RelationalCommandParameterObject parameterObject)
2020-11-27T17:36:47.944187521Z at Microsoft.EntityFrameworkCore.Sqlite.Storage.Internal.SqliteDatabaseCreator.Create()
2020-11-27T17:36:47.944197721Z at Microsoft.EntityFrameworkCore.Storage.RelationalDatabaseCreator.CreateAsync(CancellationToken cancellationToken)
2020-11-27T17:36:47.944205421Z at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.MigrateAsync(String targetMigration, CancellationToken cancellationToken)
2020-11-27T17:36:47.944213022Z at Microsoft.Extensions.DependencyInjection.ServiceCollectionExtensions.CreateDatabase(IServiceProvider serviceProvider)
2020-11-27T17:36:47.944220422Z --- End of inner exception stack trace ---
2020-11-27T17:36:47.944229022Z at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
2020-11-27T17:36:47.944236223Z at System.Threading.Tasks.Task.Wait()
2020-11-27T17:36:47.944243123Z at Microsoft.Extensions.DependencyInjection.ServiceCollectionExtensions.AddHealthChecksUI(IServiceCollection services, String databaseName, Action`1 setupSettings)
2020-11-27T17:36:47.944250523Z at Digibyte.API.Startup.ConfigureServices(IServiceCollection services) in /home/vsts/work/1/s/Digibyte.API/Startup.cs:line 177
With the tip posted by #jason-pan I´ve found that the error was caused by HealthChecks package.
https://github.com/Xabaril/AspNetCore.Diagnostics.HealthChecks/issues/455
Related to: ASP.NET Core on Azure WebApp crashes because of SQLite

How to Run Selenium UI tests in azure pipeline for c#. OpenQA.Selenium.WebDriverException : The HTTP request to the remote WebDriver server for URL

I am trying to run selenium UI tests through vsts release pipeline usingVisual Studio Test tasks from vsts release. My tests are getting recognized but not getting executed. getting same error for all tests.
I have tried updating the chrome drive used the old chrome driver still no luck. Initially I was using the chromedrive.exe file in my sln but then I removed that and add a nuget reference form Selenium.Chrome.Webdriver 2.45. tests are running fine on my local machine but when I deploy on vsts agent server I am getting an error
this the error I am getting in my VsTest log
Starting ChromeDriver 2.45.615291 (ec3682e3c9061c10f26ea9e5cdcf3c53f3f74387) on port 4620
Only local connections are allowed.
Failed _MenuConfirmation
Error Message:
OpenQA.Selenium.WebDriverException : The HTTP request to the remote WebDriver server for URL http://localhost:4580/session/1315de45cb967b450b25cef659f6/window/current/size timed out after 60 seconds.
----> System.Net.WebException : The operation has timed out
Stack Trace:
at
OpenQA.Selenium.Remote.HttpCommandExecutor.MakeHttpRequest(HttpRequestInfo requestInfo)
at OpenQA.Selenium.Remote.HttpCommandExecutor.Execute(Command commandToExecute)
at OpenQA.Selenium.Remote.DriverServiceCommandExecutor.Execute(Command commandToExecute)
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
at OpenQA.Selenium.Remote.RemoteWindow.set_Size(Size value)
at abc.AutomatedTests.BaseTestingClass.CommonInit() in D:\teams\build4\_work\1\s\src\abc.AutomatedTests\BaseTestingClass.cs:line 43
--WebException
at System.Net.HttpWebRequest.GetResponse()
at OpenQA.Selenium.Remote.HttpCommandExecutor.MakeHttpRequest(HttpRequestInfo requestInfo)
In my basetestingclass.cs I have code to launch the browser and set its size.
[SetUp]
public void CommonInit()
{
driver = new SeleniumDriver (browser).getdriver();
driver.Navigate().GoToUrl(url);
driver.Manage().Window.Size = new Size { Width = 1920, Height = 1080 };
//driver.Manage().Window.Maximize();
}
In my prior tries I was getting same error for Maximize() code.
This is was added in mu csproj after the nuget addition
<Import Project="..\packages\Selenium.Chrome.WebDriver.2.45\build\Selenium.Chrome.WebDriver.targets" Condition="Exists('..\packages\Selenium.Chrome.WebDriver.2.45\build\Selenium.Chrome.WebDriver.targets')" />
and this in packages.
<package id="Selenium.Chrome.WebDriver" version="2.45" targetFramework="net452" />
I want to Run the selenium tests In my VSTS pipeline using the Visual Studio Test. Also I have Visual Studio Test Platform Installer task prior to test execution task in my pipeline and my tests are getting recognized successfully.
I tried most of the available solution but still the same error. hence asking again.
The error message indicates that the agent you are running the UI tests on can't reach the URL you've specified.
Are you using a hosted agent in the release pipeline in AzDO? If so, it won't have line of sight to your localhost URL. Check that by changing your URL to google.com or bing.com and it should be able to run the test successfully.
Install a self-hosted agent on your machine instead: https://learn.microsoft.com/en-us/azure/devops/pipelines/agents/agents?view=azure-devops#install
Or follow this: https://www.azuredevopslabs.com/labs/vstsextend/selenium/.
You'll want to make sure that the appropriate NuGet packages for Selenium are also getting restored but I don't think that's specifically related to this error you're getting.

OpenQA.Selenium.WebDriverException: unknown error: Chrome failed to start: exited abnormally while executing tests through Selenium start on linux

I created an application that use Selenium using .NetCore for use it on Linux, actually this is my code implementation:
public class Program
{
public static async Task Main(string[] args)
{
//Settings for chrome
var chromeOpts = new ChromeOptions();
chromeOpts.AddArgument("headless");
chromeOpts.AddArgument("no-sandbox");
//Get assembly path where chrome driver is located
string codeBase = Assembly.GetExecutingAssembly().CodeBase;
UriBuilder uri = new UriBuilder(codeBase);
string path = Uri.UnescapeDataString(uri.Path);
path = Path.GetDirectoryName(path);
var driver = new ChromeDriver(path, chromeOpts, TimeSpan.FromSeconds(180));
}
}
as you can see I am using as driver Chrome, I downloaded it here, I also added the driver inside the folder of the assembly, in this way the ChromeDriver knows already where to search it.
On linux I changed the folder permission using chmod -R 777, but when I run my Dotnet application I get this:
Seems that Selenium cannot start the application.
Looking at the Exception I get:
Cannot find Chrome binary
Unfortunately I didn't find anything similar on the web, someone could help me?
Thanks in advance.
UPDATE
I Just reinstalled Chrome on my linux machine and now the error above went away, but there is another problem now, infact I get this error:
OpenQA.Selenium.WebDriverException: unknown error: Chrome failed to start: exited abnormally (Driver info: chromedriver=2.9.248304,platform=Linux 4.4.0-130-generic x86_64)
at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
at OpenQA.Selenium.Remote.RemoteWebDriver.StartSession(ICapabilities desiredCapabilities)
at OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor commandExecutor, ICapabilities desiredCapabilities)
at OpenQA.Selenium.Chrome.ChromeDriver..ctor(ChromeDriverService service, ChromeOptions options, TimeSpan commandTimeout)
at OpenQA.Selenium.Chrome.ChromeDriver..ctor(String chromeDriverDirectory, ChromeOptions options, TimeSpan commandTimeout)\ at ODS.Program.Main(String[] args)
This error message...
OpenQA.Selenium.WebDriverException: unknown error: Chrome failed to start: exited abnormally
...implies that the ChromeDriver was unable to initiate/spawn a new WebBrowser i.e. Chrome Browser session.
Your main issue is the incompatibility between the version of the binaries you are using as follows:
You are using chromedriver=2.9 which is pretty ancient.
So there is a clear mismatch between the ChromeDriver version (v2.33) and the recent Chrome Browser version (vVersion 68.0)
Solution
Upgrade ChromeDriver to current ChromeDriver v2.41 level.
Keep Chrome version between Chrome v67-69 levels. (as per ChromeDriver v2.41 release notes)
Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
If your base Web Client version is too old, then uninstall it through Revo Uninstaller and install a recent GA and released version of Web Client.
Execute your #Test.
References
You can find a couple of relevant discussions in:
WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally with ChromeDriver Chrome and Selenium on debian server
Message: unknown error: Chrome failed to start: exited abnormally on AWS Cloud9 with Linux 4.9.85-38.58.amzn1.x86_64 x86_64
WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally with ChromeDriver Chrome and Selenium through Python on VPS
first, check your google-chrome version
then download related chromedriver version i.e

Categories