。net使用硒/ cefsharp的标准库

问题描述 投票:0回答:1

我创建了一个Windows Forms机器人,该机器人可以登录并浏览网页,获取一些数据并单击一些按钮。到目前为止,我已经使用cefsharp和cefsharp.winforms在应用程序中显示浏览器。我想将此功能移植到.net标准库中,并具有与bot通信的aspnet核心后端,并将数据发送到某些朋友(基本上我想将winforms移植到Web应用程序)。我想要一个.net标准库,以便aspnet核心和win表单可以使用相同的核心库。据我所知,cefsharp.offscreen不适用于.net标准。

我检查了nuget.org上的Selenium.WebDriver数据包,并找到了依赖项

.NETStandard 2.0
Newtonsoft.Json (>= 12.0.2)

据我所知,它应支持.net标准2.0。但是,当我尝试从使用Windows窗体4.6.1的Selenium.WebDriver和ChromeDriver包的.net标准2.0库的类创建对象时,出现运行时错误

'Could not load file or assembly 'WebDriver, Version=3.141.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified

WinForms 4.6.1应用程序中的代码:

public Form1()
{
    InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
    var test = new StandardLib.TestingWebDriver();
    test.TestDriver();
}

来自我的StardardLib .net标准2.0库项目的代码:

public class TestingWebDriver
{
    public void TestDriver() {
        var driver = new ChromeDriver();
        driver.Navigate().GoToUrl("https://google.com");
        Console.WriteLine(driver.PageSource);
    }
}

我整天都在尝试不同的方法来解决此问题,但没有成功。如果您有任何解决方案,或者可以代替cefsharp / selenium使用任何替代方案,我将不胜感激:)

c# .net selenium standards cefsharp
1个回答
0
投票

最后弄清楚了。因此,winforms应用程序试图在winforms / bin / debug文件夹中而不是库的/ bin / debug中找到(硒)webdriver.dll。

我要做的就是将标准库中的软件包安装到winforms中,并且可以使用!

我认为这是预期的工作流程(出于某些我不理解的原因),有人可以对此进行详细说明。因此,毕竟它与.net标准无关,只是我不知道如何正确使用/导入类库。

© www.soinside.com 2019 - 2024. All rights reserved.