I am standing up a NUnit framework in VSCode but am running into an issue when setting up PageFactory within my page ctor. I have added DotNetSeleniumExtras.PageObjects to my .csproj but am unable to call PageFactory.InitElements(driver,this) even with the using SeleniumExtras.PageObjects in place.
I have seen the articles/videos regarding PageObjects being removed from .Net Core but I thought (perhaps naively) that DotNetSeleniumExtras would solve this.
Has anyone gotten this working since PageObjects were pulled out into their own project?
Here are the steps I've followed in getting setup:
1) Install VSCode
2) Create New Folder
3) Open Folder in VSCode
4) Install .Net Core
5) Install Extensions:
C#
.Net Core Test Explorer
Show Test Results (TDD Support for NUnit .Net Core)
6) Add NUnit Template:
dotnet new -i NUnit3.DotNetNew.Template
7) Create a project:
dotnet new nunit
8) Add Packages:
dotnet add package Selenium.Webdriver
dotnet add package Selenium.Support
dotnet add package DotNetSeleniumExtras.PageObjects
dotnet add package NUnit
dotnet add package NUnit3TestAdapter
dotnet add package Microsoft.NET.Test.Sdk
.csproj Contents
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="DotNetSeleniumExtras.PageObjects" Version="3.11.0" />
<PackageReference Include="nunit" Version="3.10.1" />
<PackageReference Include="NUnit3TestAdapter" Version="3.10.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.6.1" />
<PackageReference Include="Selenium.Support" Version="3.11.0" />
<PackageReference Include="Selenium.Webdriver" Version="3.11.0" />
</ItemGroup>
</Project>
Page.cs
using NUnit.Framework;
using System;
using SeleniumExtras.PageObjects;
using OpenQA.Selenium;
namespace IS.Pages
{
class Landing
{
public Landing()
{
PageFactory.InitElements(DriverUtil.driver,this);
}
// Start Search Button
[FindsBy(How = How.CssSelector, Using = "body > main > header > div.background-wrapper > div > div > div:nth-child(1) > div > a")]
public IWebElement AdvancedSearch {get; set;}
Sigh,
I didn't look at the Dependancies for DotNetSeleniumExtras. Not supported (yet) by .Net Core
Related
I use .NET Core 5.0.100-preview.7.20366.6 , Blazor webassembly, Microsoft Visual Studio Community 2019 Preview Version 16.7.0 Preview 6.0
file foo.csproj
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<RuntimeIdentifier>browser-wasm</RuntimeIdentifier>
<UseBlazorWebAssembly>true</UseBlazorWebAssembly>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="DevExpress.Blazor" Version="20.1.5" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="5.0.0-preview.7.20365.19" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="5.0.0-preview.7.20365.19" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication" Version="5.0.0-preview.7.20365.19" />
<PackageReference Include="System.Net.Http.Json" Version="5.0.0-preview.7.20364.11" />
</ItemGroup>
</Project>
When press F5 to run debug:
Error
NETSDK1073: The FrameworkReference 'Microsoft.AspNetCore.App' was not
recognized
How to fix it?
For .NET Core 3.1 apps, adding <GenerateErrorForMissingTargetingPacks>false</GenerateErrorForMissingTargetingPacks> to the .csproj file will prevent this error:
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<GenerateErrorForMissingTargetingPacks>false</GenerateErrorForMissingTargetingPacks>
</PropertyGroup>
I just resolved the same issue with this process:
-Close the project
-Delete the bin and obj folders in the Blazor.Client project
-Reopen the project
-Open Nuget Console: Tools -> Nuget Package Manager -> Nuget Package Manager Console
-Enter dotnet restore in the command line
After that I hit F5 and the project compiled, and started
I m working with N-tier architecture with .netcore 2.2
see how my project structure:
MainProject Version: how I m create the project(ASP.NET Core Web Application->Next->create->Empty(select the DropDown ASP.NET Core 2.2)
business logic project Version: how I m create the project(class library .net core)
data access project Version: how I m create the project(class library .net core)
model project Version: how I m create the project(class library .net core)
Error is:
Severity Code Description Project File Line Suppression State
Error NU1107 Version conflict detected for Microsoft.EntityFrameworkCore. Install/reference Microsoft.EntityFrameworkCore 3.1.2 directly to the project to resolve this issue.
projectname-> projectname.BusinessLogic -> projectname.DataAccess -> Microsoft.EntityFrameworkCore (>= 3.1.2)
projectname-> Microsoft.AspNetCore.App 2.2.0 -> Microsoft.EntityFrameworkCore (>= 2.2.0 && < 2.3.0). projectname
when I click on an error then this file display:
projectname.csproj
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.4" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\DMEBase.BusinessLogic\DMEBase.BusinessLogic.csproj" />
<ProjectReference Include="..\DMEBase.Model\DMEBase.Model.csproj" />
</ItemGroup>
</Project>
Only 1 error is generated in my project
how to solve this issue? help
NuGet Packages ScreenShot:
Write Click On Solution then I m going to Managenugetpackages->Consolidate->No Packages Found:
Downgrade entity framework core version as compatible core framework.
I've start to develop a web application with ASP.NET Core 3 and Blazor framework.
During few days/weeks, I could build my application.
Since preview 5 announced, I couldn't build my application (with dotnet build command).
I've the next error:
C:\Users\a\.nuget\packages\microsoft.aspnetcore.blazor.build\3.0.0-preview5-19227-01\targets\Blazor.MonoRuntime.targets(439,5): error MSB3073: The command "dotnet "" -l
-o "D:\Repos\IdeaStudio.Website.Client\obj\Debug\netstandard2.0\linker/"
-x "C:\Users\a\.nuget\packages\microsoft.aspnetcore.blazor.build\3.0.0-preview5-19227-01\targets\BuiltInBclLinkerDescriptor.xml"
-x "D:\Repos\IdeaStudio.Website.Client\obj\Debug\netstandard2.0\linker.descriptor.xml"
-a "C:\Users\a\.nuget\packages\microsoft.aspnetcore.blazor\3.0.0-preview5-19227-01\lib\netstandard2.0\Microsoft.AspNetCore.Blazor.dll"
-a "C:\Users\a\.nuget\packages\microsoft.aspnetcore.components\3.0.0-preview5-19227-01\lib\netstandard2.0\Microsoft.AspNetCore.Components.dll"
-a "C:\Users\a\.nuget\packages\microsoft.aspnetcore.components.browser\3.0.0-preview5-19227-01\lib\netstandard2.0\Microsoft.AspNetCore.Components.Browser.dll"
-a "C:\Users\a\.nuget\packages\microsoft.extensions.dependencyinjection\3.0.0-preview5.19227.9\lib\netstandard2.0\Microsoft.Extensions.DependencyInjection.dll"
-a "C:\Users\a\.nuget\packages\microsoft.extensions.dependencyinjection.abstractions\3.0.0-preview5.19227.9\lib\netstandard2.0\Microsoft.Extensions.DependencyInjection.Abstractions.dll"
-a "C:\Users\a\.nuget\packages\microsoft.jsinterop\3.0.0-preview5.19227.9\lib\netstandard2.0\Microsoft.JSInterop.dll"
-a "C:\Users\a\.nuget\packages\mono.webassembly.interop\3.0.0-preview5.19227.9\lib\netstandard2.0\Mono.WebAssembly.Interop.dll"
-a "C:\Users\a\.nuget\packages\system.componentmodel.annotations\4.6.0-preview5.19224.8\lib\netstandard2.0\System.ComponentModel.Annotations.dll"
-a "D:\Repos\IdeaStudio.Website.Client\obj\Debug\netstandard2.0\IdeaStudio.Website.Client.dll"" exited with code 1.
[D:\Repos\IdeaStudio.Website.Client\IdeaStudio.Website.Client.csproj]
My csproj looks like :
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<RestoreAdditionalProjectSources>
https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json;
https://dotnet.myget.org/F/blazor-dev/api/v3/index.json;
</RestoreAdditionalProjectSources>
<LangVersion>7.3</LangVersion>
<RazorLangVersion>3.0</RazorLangVersion>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<OutputType>Exe</OutputType>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.5.1" />
<PackageReference Include="Microsoft.AspNetCore.Blazor" Version="3.0.0-preview5-19227-01" />
<PackageReference Include="Microsoft.AspNetCore.Blazor.Build" Version="3.0.0-preview5-19227-01" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Blazor.DevServer" Version="3.0.0-preview5-19227-01" PrivateAssets="all" />
</ItemGroup>
</Project>
I did not understand for several days until...
This issue on the Mono GitHub is related.
Basically, as far as I understand it, somewhere in Mono the IL Linker fails and throws this cryptic error message. We can see hints to this in your error message.
As of now, michaelccote on GitHub solved the problem by adding the <BlazorLinkOnBuild>false</BlazorLinkOnBuild> element inside the <PropertyGroup>...</PropertyGroup> tags of the .csproj file
Maybe when I did the Visual Studio / .NET Core 3 preview 5
dotnet cli can't build an application with a csproj which contains <TargetFramework> and <TargetFrameworks> properties...
When you are using Blazor WebAssembly, ASP.NET Core 3.1 please navigate to yoursolution/yourproject.Client/ and edit yourproject.Client.csproj-File. Add the following line:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
[...]
<BlazorWebAssemblyEnableLinking>false</BlazorWebAssemblyEnableLinking>
</PropertyGroup>
[...]
</Project>
I can create a new dotnetcore app that has authentication/identity using the command line:
dotnet new mvc --auth Individual
How can i include entity framework in the project also?
TL;DR
You already have it in your project
Long form answer
After creating your application, it should have Entity Framework as a dependency. I'm assuming that you're running the .NET Core 2.0 SDK.
Here's the output from my machine
$ dotnet new mvc --auth Individual --name testForStackOverflow
The template "ASP.NET Core Web App (Model-View-Controller)" was created successfully.
This template contains technologies from parties other than Microsoft, see https://aka.ms/template-3pn for details.
Processing post-creation actions...
Running 'dotnet restore' on testForStackOverflow/testForStackOverflow.csproj...
Restoring packages for testForStackOverflow/testForStackOverflow.csproj...
Restore completed in 40.17 ms for testForStackOverflow/testForStackOverflow.csproj.
Restore completed in 40.17 ms for testForStackOverflow/testForStackOverflow.csproj.
Restore completed in 25.25 ms for testForStackOverflow/testForStackOverflow.csproj.
Generating MSBuild file testForStackOverflow/obj/testForStackOverflow.csproj.nuget.g.props.
Generating MSBuild file testForStackOverflow/obj/testForStackOverflow.csproj.nuget.g.targets.
Restore completed in 2.84 sec for testForStackOverflow/testForStackOverflow.csproj.
Restore succeeded.
I then look a look at the csproj which was generated:
$ cd testForStackOverflow/
~/testForStackOverflow$ ls
app.db Data Startup.cs
appsettings.Development.json Extensions testForStackOverflow.csproj
appsettings.json Models Views
bower.json obj wwwroot
bundleconfig.json Program.cs
Controllers Services
~/testForStackOverflow$ cat testForStackOverflow.csproj
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<UserSecretsId>aspnet-testForStackOverflow-AD382505-1A70-4A75-8059-1E0E3897A088</UserSecretsId>
</PropertyGroup>
<ItemGroup>
<None Update="app.db" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.0.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.0.0" PrivateAssets="All" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.0" />
<DotNetCliToolReference Include="Microsoft.Extensions.SecretManager.Tools" Version="2.0.0" />
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0" />
</ItemGroup>
</Project>
The important line of the csproj is here:
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
This is a reference to the ASP.NET Core metapackage. This package contains all of the common ASP.NET Core NuGet packages, including Entity Framework Core - as per this screen shot from NuGet (captured a few moments ago)
This means that part of the package restore operation included restoring EF Core into your project.
I would say that you should take a look at this documentation for EF Core - the link should take you directly to the section labelled "The Model". You don't need the stuff in the preceding section (labelled "Get Entity Framework Core") as you already have it.
Of course, if you're using version 1.x of the .NET Core SDK, then it's a slightly different story.
I tried to setup a .net core console application which uses EF core 2.0.0 and Redis.Core 1.0.3 (both are the current latest version).
Unfortunately if you try to put both into one application it won't even start. Even if you try to set a breakpoint right at the beginning or start debugging with Step into or Step Over doesn't help. All you get is this:
I think there happens some kind of type load exception or something similar. So far to reproduce the problem is quite easy with this project:
Project File (MyProject.csproj)
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Caching.Redis.Core" Version="1.0.3" />
</ItemGroup>
</Project>
Application (Program.cs)
using Microsoft.Extensions.Caching.Redis;
using Microsoft.Extensions.Options;
namespace MyApplication
{
class Program
{
static void Main(string[] args)
{
var cache = new RedisCache(Options.Create(new RedisCacheOptions()));
}
}
}
Anybody an idea or solution?
The problem is that
Microsoft.Extensions.Caching.Redis.RedisCache 1.0.3 depends on Microsoft.Extensions.Caching.Abstractions 1.0.3
Microsoft.EntityFrameworkCore 2.0.0 depends on Microsoft.Extensions.Caching.Abstractions 2.0.0
If you look at the Output Window, you will get:
TypeLoadException: Method GetAsync in type
Microsoft.Extensions.Caching.Redis.RedisCache from assembly
'Microsoft.Extensions.Caching.Redis, Version=1.0.3.0, Culture=neutral,
PublicKeyToken=adb9793829ddae60' does not have an implementation.
So: either wait until RedisCache gets updated to 2.0.0 or use EntityFrameworkCore < 2.0.0