Selenium Chrome Driver can't be found - asp.net-mvc

I am trying to use Selenium web driver. I am using asp.net mvc. I have set up a very basic test. I'm basically just trying to open the browser.
Imports NUnit.Framework
Imports OpenQA.Selenium
Imports OpenQA.Selenium.Chrome
Imports OpenQA.Selenium.Firefox
<TestFixture()>
Public Class SeleniumEg
Dim driverFF As IWebDriver
Dim driverGC As IWebDriver
Dim driverPath As String = "c:\chromedriver.exe"
<Test()>
Public Sub OpenBrowser()
driverGC = New ChromeDriver(driverPath)
driverGC.Navigate().GoToUrl("https://www.google.ie/")
End Sub
End Class
But when I run test i am getting this Error Message
Result Message:
OpenQA.Selenium.DriverServiceNotFoundException : The file c:\chromedriver.exe\chromedriver.exe does not exist. The driver can be downloaded at http://chromedriver.storage.googleapis.com/index.html
I have also tried putting the driver in the soloution, but I am still getting driver does not exist. The error message seems to repeat the file name when saying its location:
c:\chromedriver.exe\chromedriver.exe when it should be c:\chromedriver.exe

From the error message, I think the problem should be evident
Result Message: OpenQA.Selenium.DriverServiceNotFoundException : The file c:\chromedriver.exe\chromedriver.exe does not exist. The driver can be downloaded at http://chromedriver.storage.googleapis.com/index.html
The ChromeDriver constructor (pardon me if I am not using the proper .NET terminologies, I am a Java guy) expects the directory in which the chromedriver.exe binary exists and not the actual location of the binary itself. See here
So please change
Dim driverPath As String = "c:\chromedriver.exe"
to
Dim driverPath As String = "c:\"
and see if that helps fix your issue.

Related

The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception. "Unable to load DLL 'git2-572e4d8':

We are also getting the same exception. We are using Azure Function and using v0.26.0 of LibGit2Sharp. This exception arises when we are debugging our azure function using Azure CLI debugger.
We have already tried adding 'AutoGenerateBindingRedirects true AutoGenerateBindingRedirects' to csproj file of the project but still no luck. Though it runs fine in console app but is throwing exception in Azure function.
Here is the stack trace:
at LibGit2Sharp.Core.NativeMethods.git_repository_open(git_repository*& repository, FilePath path)
at LibGit2Sharp.Core.Proxy.git_repository_open(String path)
at LibGit2Sharp.Repository..ctor(String path, RepositoryOptions options, RepositoryRequiredParameter requiredParameter)
at LibGit2Sharp.Repository..ctor(String path)
at GitDeploy.GitRepositoryManager.UpdateRepository()
at CrmSolution.RepositoryHelper.TryPushToRepository(String committerName, String committerEmail, String authorEmail, SolutionFileInfo solutionFile, String solutionFilePath, HashSet`1 hashSet)
at CrmSolution.RepositoryHelper.TryUpdateToRepository(String solutionUniqueName, String committerName, String committerEmail, String authorEmail)

The type provider 'ProviderImplementation.JsonProvider' reported an error despite program working

I am writing a service using .net Core with Visual Studio 2017. I want to use JSON for the configuration, so I defined my type like this:
type ServiceConfig = JsonProvider<"exampleConfig.json", EmbeddedResource="MyService, exampleConfig.json", SampleIsList = true>
In my program, I load it like this:
let conf = ServiceConfig.Load "config.json"
When I run it, it works fine, but in VS 2017 I get a red squiggly line and the error log says:
FS3033 The type provider 'ProviderImplementation.JsonProvider'
reported an error in the context of provided type
'FSharp.Data.JsonProvider,Sample="exampleConfig.json",SampleIsList="True",EmbeddedResource="MyService, exampleConfig.json"', member 'Load'. The error: Method
'FSharp.Data.Runtime.BaseTypes.IJsonDocument
Create(System.IO.TextReader, System.String)' not found in type
''. This method may be missing in the types available in the
target assemblies.
How do I get rid of this?
I'm not sure that this is the problem, but it might help to give an absolute path of the sample file. Resolving a relative path is a constant source of issues in type providers. You can do something like:
[<Literal>]
let sample = __SOURCE_DIRECTORY__ + "/exampleConfig.json"
type ServiceConfig =
JsonProvider< sample, EmbeddedResource="MyService, e
xampleConfig.json", SampleIsList = true >
By chance I found the answer myself. It must have been some Visual Studio index having gone wonky. I had another problem with another project in my solution so I just did an "emergency commit" to git, cleaned my local working copy using git clean -fdx and then reloaded the solution, rebuilt everything and the errors went away.

CloudTable.Execute not working in API

I just moved a function from an MVC App to an MVC API App, and for some reason it all works except CloudTable.Execute.
Code:
try
{
CloudStorageAccount storageAccount = new CloudStorageAccount(new Microsoft.WindowsAzure.Storage.Auth.StorageCredentials(
"accountName",
"key"), true);
CloudTableClient cloudTableClient = storageAccount.CreateCloudTableClient();
CloudTable table = cloudTableClient.GetTableReference("SkypeUsers");
table.CreateIfNotExistsAsync();
TableOperation retrieveOperation = TableOperation.Retrieve<WorkUser>("Skype", skypeid);
TableResult retrievedResult = table.Execute(retrieveOperation); //Does not work
retrievedSkypeId = ((WorkUser)retrievedResult.Result).RowKey;
}
catch (Exception ex)
{
}
Error:
Error CS1061 'CloudTable' does not contain a definition for 'Execute' and no
extension method 'Execute' accepting a first argument of type 'CloudTable' could
be found (are you missing a using directive or an assembly reference?)
The reference to Microsoft.WindowsAzure.Storage is the same version I use in my App. Ive tried cleaning and re-building. Not sure what the issue is.
EDIT:
Print of my only Execute-options:
I am targeting .NET Core & using assembly Microsoft.WindowsAzure.Storage, Version=9.2.0.0.
The ExecuteQuery does not exist within CloudTable for this version.
This might be your case as well.
Use:
table.ExecuteQuerySegmentedAsync(query, null).Result;
The ExecuteQuery sync is still available for .NET Framework version however for NET Standard use ExecuteQuerySegmentedAsync instead.
Error CS1061 'CloudTable' does not contain a definition for 'Execute' and no extension method 'Execute' accepting a first argument of type 'CloudTable' could be found (are you missing a using directive or an assembly reference?)
CloudTable.Execute Method (TableOperation, TableRequestOptions, OperationContext) accepts a TableOperation object as the first argument, and according to the code you provide, we could find you indeed pass a TableOperation object to Execute method, it should not return the error. Please try to install the latest version Microsoft Azure Storage Client Library for .NET to your project (the code works fine with WindowsAzure.Storage v8.0.0 on my side) and test if same issue will appear. You could also tell us the version of WindowsAzure.Storage you are using now, and then we will test the code with that version.
Besides, please try to use TableQuery to generate a query and call CloudTable.ExecuteQuery method to retrieve the entity.
TableQuery<WorkUser> query = new TableQuery<WorkUser>().Where(
TableQuery.CombineFilters(
TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, "Skype"),
TableOperators.And,
TableQuery.GenerateFilterCondition("RowKey", QueryComparisons.Equal, skypeid)));
retrievedSkypeId = table.ExecuteQuery(query).FirstOrDefault().RowKey;

Installing Windows Service in F#: "No public installers with the RunInstallerAttribute.Yes attribute ..."

I'm attempting to install the Windows Service I have written in F#, but I keep getting the following message when I run installutil:
No public installers with the RunInstallerAttribute.Yes attribute could be found in the C:\path\to\service\myservice.exe assembly.
The Windows service installer code is below. Note that both of the things which the error message claims are missing are, in fact, present:
ProjectInstaller is public.
ProjectInstaller is tagged/decorated with RunInstaller(true) attribute.
The service installer code:
module Project.WindowsService.Installer
open System.Configuration.Install
open System.ComponentModel
open System.ServiceProcess
[<RunInstaller(true)>]
type public ProjectInstaller () as installer =
inherit Installer()
// Define the process settings
let processInstaller =
new ServiceProcessInstaller(
Account = ServiceAccount.LocalSystem,
Password = null,
Username = null)
// Define the service settings
let serviceInstaller =
new ServiceInstaller(
ServiceName = "Project.WindowsService",
DisplayName = "My Service",
Description = "Blah. Blah, blah, blah. And, of course, blah.",
StartType = ServiceStartMode.Automatic)
do
// Define the installers
[| processInstaller :> Installer
serviceInstaller :> Installer |]
|> installer.Installers.AddRange
Turns out that putting the ProjectInstaller within a module is a problem: For some reason, installutil cannot find it.
Changing the module declaration:
module Project.WindowsService.Installer
... to a namespace declaration fixes everything:
namespace Project.WindowsService
If you came to here from a search link then these two other post may be more relevant to you. In particular the 1st link below.
Install Windows Service created in Visual Studio
Unable to install windows service with the help of InstallUtil tool

asp.net mvc code not getting compiled on server

i have this code in one of my asp.net mvc views:
<%Html.RenderFile(#"C:\Members\newsletters\welcome.html");%>
I have created an extension on the Html class to read in a file. the code looks like this:
public static class HtmlRenderer
{
public static void RenderFile(this HtmlHelper helper_, string path_)
{
var reader = new StreamReader(path_);
var contents = reader.ReadToEnd();
helper_.ViewContext.HttpContext.Response.Write(contents);
}
}
This all works perfectly when i run in visual studio on my desktop but when i ftp these files to the server, i get the following error in the browser:
Compiler Error Message: CS1061: 'System.Web.Mvc.HtmlHelper' does not contain a definition for 'RenderFile' and no extension method 'RenderFile' accepting a first argument of type 'System.Web.Mvc.HtmlHelper' could be found (are you missing a using directive or an assembly reference?)
The HtmlRenderer class is in a namespace with my controllers so there is no other external assembly reference needed.
Does anyone have any idea how this could be happening or what i am doing wrong ?
You need to compile the project and then deploy (xcopy or publish from VS) to the server.
Googled and found something.Does the server has .net 3.5?
Try to publish the web on a local IIS7 or IIS6.( Right click project "Publish" ).
You have a good chance you already get a more specific error during "publish".
If not run the page on your local IIS6 or 7 and see if you get an error.
i tried doing a full refresh (deleting everything on the server and republishing and now everything works fine..
so i am happy that everything is working but still have no clue why it wasn't before.

Resources