I want to run firefox headless.
Not hide the browser window or open it in a virtual desktop, Firefox supports headless mode by using "-headless" flag.
Problem is I know how to do it in chrome but not in Firefox.
My code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
namespace MyApp {
public partial class Form1: Form {
public Form1() {
InitializeComponent();
}
private void StartBtn_Click(object sender, EventArgs e) {
IWebDriver driver;
FirefoxOptions options = new FirefoxOptions();
options.AddArguments("--headless");
driver = new FirefoxDriver(options);
}
}
}
My WinForm application only has a button with name StartBtn. On clicking of the button Firefox should run headless, but it opens in a normal window.
Update I updated firefox to 56.0.1
Now I get a different error:
An unhandled exception of type 'OpenQA.Selenium.WebDriverException' occurred in WebDriver.dll
Additional information: Expected browser binary location, but unable to find binary in default location, no 'moz:firefoxOptions.binary' capability provided, and no binary flag set on the command line