0

I have read alot of the answer on here about my question, but they do not help, because everything i try has not worked

I am using Selenium via ASP.NET C# on my web app. I want to be able to login and get a webpage and parse that page.

My problem is that it continues to say cannot find binary(chrome or firefox). The environment path contains the location to both. I add the Binary path and still nothing. The code I have attempted is below:

var ffBinary = new FirefoxBinary(@"C:\Program Files\Mozilla Firefox\firefox.exe");
var firefoxProfile = new FirefoxProfile(ProfilePath);
var driver = new FirefoxDriver(firefoxProfile);

This tells me it cannot find the binary for firefox, but the executable is in that location

var options = new OpenQA.Selenium.Chrome.ChromeOptions();
options.BinaryLocation = "C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe"; 
var driver = new ChromeDriver(AppDomain.CurrentDomain.BaseDirectory + @"\Scripts", options, TimeSpan.FromSeconds(180)); 

I mean this looks perfectly fine, but i am getting nowhere. Can somebody help me with this conundrum?

Here is the error: Specified firefox binary location does not exist or is not a real file: C:\Program Files\Mozilla Firefox\firefox.exe

Here is the stack trace:

[WebDriverException: Specified firefox binary location does not exist or is not a real file: C:\Program Files\Mozilla Firefox\firefox.exe] OpenQA.Selenium.Firefox.Internal.Executable..ctor(String userSpecifiedBinaryPath) +229 OpenQA.Selenium.Firefox.FirefoxBinary..ctor(String pathToFirefoxBinary) +87 AddNewFanTmPlyrs.YahooFanTm(String URLLink, String UNm, String PW) in h:\root\home\slickpk-001\www\site1\AddNewFanTmPlyrs.aspx.cs:394 AddNewFanTmPlyrs.LoadTmBtn_Click(Object sender, EventArgs e) in h:\root\home\slickpk-001\www\site1\AddNewFanTmPlyrs.aspx.cs:194 System.Web.UI.WebControls.Button.OnClick(EventArgs e) +9659822 System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +108 System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +12 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +15 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +35 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1639

3
  • Whats the actual error + stack trace? Commented Oct 30, 2015 at 23:07
  • Specified firefox binary location does not exist or is not a real file: C:\Program Files\Mozilla Firefox\firefox.exe Commented Oct 30, 2015 at 23:26
  • See edit above @Arran Commented Oct 30, 2015 at 23:33

2 Answers 2

1

Please try this...works on the latest version of Selenium 2.48.0 with FF 41.0

FirefoxProfileManager profileManager = new FirefoxProfileManager();
FirefoxProfile firefoxProfile = profileManager.GetProfile("default"); // Or your custom created profile name
FirefoxBinary objbin = new FirefoxBinary(@"C:\Program Files (x86)\Mozilla Firefox\firefox.exe"); // Firefox installation directory

driver = new FirefoxDriver(objbin, firefoxProfile);
Sign up to request clarification or add additional context in comments.

Comments

0

Well I doubt the framework is wrong, considering you probably aren't the first person to use that particular piece of code. Rather, it's much more likely you are wrong.

I'm on a 64 bit PC. By default, Chrome installs on 64 bit Windows at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe since it is a 32 bit application. I imagine that's the source of your problem. But perhaps you chose a non-default install directory. Or you installed to a different drive letter. Make 100% sure of the location of the files. If you are positive, then perhaps it is afterall a bug, and you should file a bug report.

Another possibility: the user that your C# code is running from may not have permissions to that directory structure. I find that highly unlikely though, as someone would probably have had to manually do that.

And lastly, there exists the possibility that you're running the code on the wrong machine. The machine where the code is executing needs to have Chrome/Firefox, not necessarily the ASP.NET server you're trying to test (unless they're the same machine).

1 Comment

Well the paths are correct. The code is being run on the server. The driver files are on the server. The chrome and firefox are on the local machine(my computer). When i run this on my machine it works fine, but then i deploy and it has a problem with selenium, trying to launch the browser i am calling

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.