简体   繁体   English

无法加载文件或程序集 'SeleniumExtras.WaitHelpers

[英]Could not load file or assembly 'SeleniumExtras.WaitHelpers

I am trying to use我正在尝试使用

wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementIsVisible(By.Id("logonIdentifier")));

However I am getting an error Could not load file or assembly 'SeleniumExtras.WaitHelpers.但是我收到错误无法加载文件或程序集'SeleniumExtras.WaitHelpers。 I am using我在用

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netcoreapp2.1</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="DotNetSeleniumExtras.WaitHelpers" Version="3.11.0" />
    <PackageReference Include="NUnit" Version="3.12.0" />
    <PackageReference Include="TestProject.SDK" Version="0.63.1" />
  </ItemGroup>

</Project>


<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netcoreapp2.1</TargetFramework>

    <IsPackable>false</IsPackable>
      <PublishChromeDriver>true</PublishChromeDriver>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="DotNetSeleniumExtras.WaitHelpers" Version="3.11.0" />
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
    <PackageReference Include="MSTest.TestAdapter" Version="2.1.0" />
    <PackageReference Include="MSTest.TestFramework" Version="2.1.0" />
    <PackageReference Include="coverlet.collector" Version="1.2.0" />
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="..\testForLogin\testForLogin.csproj" />
  </ItemGroup>

</Project>

It works locally but when I tried pushing it to the testproject.io I get the above error message.它在本地工作,但是当我尝试将它推送到 testproject.io 时,我收到了上述错误消息。 在此处输入图片说明

I am not able to change it to the recommend selenium web driver version.我无法将其更改为推荐的 selenium Web 驱动程序版本。

The package you are using is not .NET Core compliant.您使用的包不符合 .NET Core 标准。 With some restructure of the code what you need is available with通过对代码进行一些重构,您可以使用

using OpenQA.Selenium.Support.UI;

Then take the code that used the SeleniumExtras wait helpers and change to use methods on your driver class such as然后使用使用 SeleniumExtras 等待助手的代码并更改为使用驱动程序类上的方法,例如

WebDriverWait browserWait = new WebDriverWait(driver, TimeSpan.FromSeconds(90));
browserWait.Until(driver => driver.FindElement(By.Id("logonIdentifier")).Displayed);

You could easily check the properties on the driver as well, say for the Url, such as您也可以轻松检查驱动程序上的属性,例如 Url,例如

const string expectedUrl = "https://www.google.com";
browserWait.Until(driver => driver.Url == expectedUrl);

Then go remove the package you are no longer using from your project然后从项目中删除不再使用的包

dotnet remove package DotNetSeleniumExtras.WaitHelpers

Which funny enough is pretty much the homepage of https://www.selenium.dev/documentation/en/ but when you search you tend to get distracted by the SeleniumExtras project.有趣的是https://www.selenium.dev/documentation/en/的主页,但是当您搜索时,您往往会被 SeleniumExtras 项目分心。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM