Попытка открыть chrome через веб-драйвер с помощью C#. После сборки появилось следующее сообщение:
Запуск test.test2.test2.Start.HeadlessTest ...
OneTimeSetUp: не найдено подходящего конструктораРезультат сообщения:
OneTimeSetUp: подходящий конструктор не найден
using System;
using NUnit.Framework;
using OpenQA.Selenium.Chrome;
namespace test2
{
[TestFixture]
public class Start
{
public Start(ChromeOptions options) => this.Options = options;
public ChromeOptions Options { get; } = new ChromeOptions();
[Test(Description = "Navigate a website, check text is present")]
public void HeadlessTest()
{
//options.AddArgument("--headless");
ChromeDriver chromeDriver = new ChromeDriver(Options);
ChromeDriver chromy = chromeDriver;
string expected_text = "Announcements";
// maximizes the browser window
chromy.Manage().Window.Maximize();
// sets the browser window size
chromy.Manage().Window.Size = new System.Drawing.Size(1200, 600);
// waits up to specified time for a page to load
chromy.Manage().Timeouts().PageLoad = TimeSpan.FromSeconds(10);
chromy.Navigate().GoToUrl("http://www.google.com/");
// replaces 3 lines above
StringAssert.Contains(expected_text, chromy.FindElementByTagName("h2").Text);
// another type of Assert with the same result
Assert.That(Equals(expected_text, chromy.FindElementByTagName("h2").Text));
// prints the page URL
Console.Write("\n" + chromy.Url);
// prints the page title
Console.Write("\n" + chromy.Title);
for (int i = 0; i < 3; i++)
{
Console.WriteLine("\nTest successfull " + i);
}
//chromy.Close();
}
}
}