4

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();
            }

        }



    }
3
  • 1
    The error indicates that the path to the firefox executable is wrong. Have you checked that it is correct? Is Firefox also installed on the server where you want to execute the code? Commented Nov 27, 2018 at 9:06
  • Run to windows hosting plesk. Commented Nov 27, 2018 at 9:29
  • no solution?!!!!! unknown error: cannot find Chrome binary (Driver info: chromedriver=2.41.578737 (49da6702b16031c40d63e5618de03a32ff6c197e),platform=Windows NT 10.0.14393 x86_64) Commented Nov 28, 2018 at 15:19

2 Answers 2

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?

Sign up to request clarification or add additional context in comments.

Comments

0

Find the installed location of firefox e.g. C:\Program Files\Mozilla Firefox\firefox.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");

1 Comment

As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.