skip to Main Content

this sample work:
get text of google and show in home page sample asp.net
test for correct work selenium in windows host.

i want to run selenium in windows hosting plesk.

error for me:

Server Error in ‘/’ Application.

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 (SessionNotCreated)

Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: 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 (SessionNotCreated)

Source Error:

An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of
the exception can be identified using the exception stack trace below.
Stack Trace:

[InvalidOperationException: 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 (SessionNotCreated)] OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response
errorResponse) +1059
OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String
driverCommandToExecute, Dictionary`2 parameters) +125
OpenQA.Selenium.Remote.RemoteWebDriver.StartSession(ICapabilities
desiredCapabilities) +235
OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor
commandExecutor, ICapabilities desiredCapabilities) +54
OpenQA.Selenium.Firefox.FirefoxDriver..ctor(FirefoxOptions options)
+81 WebDriverwithwebapp._Default.Page_Load(Object sender, EventArgs e) +178
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender,
EventArgs e) +51 System.Web.UI.Control.OnLoad(EventArgs e) +95
System.Web.UI.Control.LoadRecursive() +59
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
+678

   protected void Page_Load(object sender, EventArgs e)
    {

        FirefoxOptions options = new FirefoxOptions();
        options.BrowserExecutableLocation = ("C:\Program Files\Mozilla Firefox\firefox.exe"); //This is the location where you have installed Firefox on your machine

       // WebDriver driver = new FirefoxDriver(options);

        using (var FireFoxPage = new FirefoxDriver())
        {
            //_driver = new FireFoxDriver();
            _driver.Manage().Window.Maximize();
            _driver.SwitchTo().Window(_driver.CurrentWindowHandle);
            _driver.Manage().Cookies.DeleteAllCookies();
            // _driver.Manage().Timeouts().ImplicitWait(TimeSpan.FromSeconds(3));

            _driver.Navigate().GoToUrl("https://google.com/");

            _driver.FindElement(By.Id(Button_ID)).Click();


          IwebElement  Element1 = _driver.FindElement(By.XPath("/html/body/main/div/div/div[3]/span"));
            ksc = Element1.Text.ToString();

            Label1.Text = ksc.ToString();

            _driver.Quit();
            Process[] geckodriverProcesses = Process.GetProcessesByName("geckodriver");
            foreach (var geckodriver in geckodriverProcesses)
            {
                geckodriver.Kill();
            }

        }



    }

2

Answers


  1. Try passing the options variable into the parameters of new FirefoxDriver(). It worked for me like this:

    FirefoxOptions options = new FirefoxOptions();
        options.BrowserExecutableLocation = ("C:\Program Files\Mozilla Firefox\firefox.exe"); //This is the location where you have installed Firefox on your machine
    
       // WebDriver driver = new FirefoxDriver(options);
    
        using (var FireFoxPage = new FirefoxDriver(options))
        {
       //...
    

    Actually, I see a commented variable using the options object, did you have any errors using it instead?

    Login or Signup to reply.
  2. Find the installed location of firefox
    e.g. C:Program FilesMozilla Firefoxfirefox.exe

    FirefoxOptions option = new FirefoxOptions();
    option.BrowserExecutableLocation = "C:\Program Files\Mozilla Firefox\firefox.exe";
    

    //Location of geckodriver.exe file in project solution
    string path = "C://Users//v-sacgupta//source//repos//PracticeExcersice//PracticeExcersice//drivers//";

    driver = new FirefoxDriver(path + @"/drivers/", option);
    driver.Manage().Window.Maximize();
    driver.Navigate().GoToUrl("https://google.com");
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search