operasoftware / operachromiumdriver

OperaDriver for Chromium-based Opera releases
Other
261 stars 47 forks source link

Mac C# Visual Studio Asks for EXE? #78

Open SeamusMacRat opened 4 years ago

SeamusMacRat commented 4 years ago

I'm attempting to run this driver on all three operating systems. It works without issue on Windows and has done for a long while. However, when I attempt to run it on both Mac OS X and Ubuntu, I am confronted with the following error:

The file [...]operadriver.exe does not exist. The driver can be downloaded at https://github.com/operasoftware/operachromiumdriver/releases

Of course, it won't find an exe file on a Mac installation ... or a Linux one ...

I am instantiating using the following methodology:

Driver = new OperaDriver(_operaDriverFolderLocation, _options, _timeout);

Where: _operaDriverFolderLocation contains the parent folder for the driver executable _options contains only the address for the Opera binary _timeout contains a thirty second timespan

panosru commented 4 years ago

I have exactly the same issue, so far I wasn't able to find any solution to that (~same happens with Edge driver~ - I was using Canary version, with stable works fine...), Safari, Firefox and Chrome drivers work fine.

Update

What I actually ended up doing is the following:

private static IWebDriver CreateOperaDriver(
    string driverDirectory,
    bool isDebuggerAttached)
{
    var options = new OperaOptions();
    var service = OperaDriverService.CreateDefaultService(driverDirectory, "operadriver");

    if (!isDebuggerAttached)
    {
        options.AddArgument("--headless");
    }

    return new OperaDriver(service, options);
}
[SkippableTheory]
[InlineData("Chrome")]
[InlineData("Edge")]
[InlineData("Firefox")]
[InlineData("Opera")]
[InlineData("Safari")]
public static void Check_About_Page(string browserName)
{
    // Arrange
    // Skip.If(
    //     !RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && (browserName == "Edge"),
    //     $"{browserName} is only supported on Windows.");

    // Act
    using var driver = CreateWebDriver(browserName);
    driver.Navigate().GoToUrl("https://localhost:5001/en/about");

    // Assert
    driver.FindElement(By.ClassName("whoami"))
        .FindElement(By.TagName("span"))
        .Text.Should().Be("Whoami?");
}

image

for your case, you could do something like this:

OperaDriverService service = OperaDriverService.CreateDefaultService(_operaDriverFolderLocation, "operadriver");
IWebDriver driver = new OperaDriver(service, _options, _timeout);

That way I got it working.