I have read a lot of articles related to using selenium and portable firefox. But the code doesn't work with me. Did I do something wrong? I am using firefox portable 67 and Geckodriver v0.24.0.
FirefoxDriverService driverService = FirefoxDriverService.CreateDefaultService(#"D:\C# Project\FirefoxPortal tesst\FirefoxPortal tesst\bin\Debug\", "geckodriver.exe");
FirefoxOptions options = new FirefoxOptions();
//var profile = new FirefoxProfileManager().GetProfile("");
options.Profile = new FirefoxProfile(#"D:\C# Project\FirefoxPortal tesst\FirefoxPortal tesst\bin\Debug\FirefoxPortable\Data\profile");
options.BrowserExecutableLocation = #"D:\C# Project\FirefoxPortal tesst\FirefoxPortal tesst\bin\Debug\FirefoxPortable\FirefoxPortable.exe";
IWebDriver driver = new FirefoxDriver(driverService, options);
driver.Navigate().GoToUrl("https://stackoverflow.com/");
I do not have time today but try changing
options.BrowserExecutableLocation = #"D:\C# Project\FirefoxPortal tesst\FirefoxPortal tesst\bin\Debug\FirefoxPortable\FirefoxPortable.exe";
to
options.BrowserExecutableLocation = #"D:\C# Project\FirefoxPortal tesst\FirefoxPortal tesst\bin\Debug\FirefoxPortable\App\firefox64\firefox.exe";
or to wherever you have your firefox.exe file.
Related
NOTE - I am running SeleniumGrid 4.1.0 in Hub-Node mode with Hub and Node running on the same machine.
When I try to run Firefox (ver - 94.0.2) instance using following code nothing happens and Hub freezes
var firefoxOptions = new FirefoxOptions
{
PlatformName = "WINDOWS",
Profile = new FirefoxProfile()
};
_driver = new RemoteWebDriver(seleniumGridUri, firefoxOptions);
Where as if I directly use FirefoxDriver, it works. This works fine
var firefoxOptions = new FirefoxOptions
{
PlatformName = "WINDOWS",
Profile = new FirefoxProfile()
};
_driver = new FirefoxDriver(geckoDriverFolderPath, firefoxOptions);
Can someone please help?
So I am creating a bot with chrome headless browser and it works just fine. I had quite a lot warnings so I disabled them after reasearch with those commands:
ChromeOptions option = new ChromeOptions();
option.AddArgument("--headless");
option.AddArgument("--silent");
option.AddArgument("--disable-gpu");
option.AddArgument("--log-level=3");
ChromeDriverService service = ChromeDriverService.CreateDefaultService();
service.SuppressInitialDiagnosticInformation = true;
_driver = new ChromeDriver(service, option);
But there is one more message showing when programs starts:
DevTools listening on ws://127.0.0.1:12015/devtools/browser/6b70a3c5-56c8-4c90-952a-d0e0ef254ddf
Any idea how to disable it from showing?
If you are trying to fix Selenium with Python on Windows, type:
from selenium.webdriver.chrome.options import Options
options = Options()
options.add_argument('headless')
options.add_experimental_option('excludeSwitches', ['enable-logging'])
browser = webdriver.Chrome(options=options)
with the experimental_option line being the special sauce.
That did the trick
var service = ChromeDriverService.CreateDefaultService();
service.HideCommandPromptWindow = true;
Driver = new ChromeDriver(service, options);
Add following two options .
option.AddArgument("--disable-extensions");
option.AddArgument("test-type");
I tried to open modified FireFox browser using Selenium WebDriver.
(This Firefox-based browser as same as original Firefox, just with additional functionality.)
This Browser opens and then I got Error:
["OpenQA.Selenium.WebDriverException" in WebDriver.dll]
TypeError: Given browserName [object String] "firefox", but my name is [object String] "anotherbrowser"
My code[C#]:
var path = new FirefoxBinary(#"C:\FireFox_BasedBrowser\anotherbrowser.exe");
IWebDriver driver = new FirefoxDriver(path, null); //here's error
After searching I found this advice on Java:
String bname = "Browser name";
FirefoxOptions options = new FirefoxOptions();
options.setBinary("Path to browser binary");
options.setCapability("browserName", bname);
options.setCapability("marionette", false);
driver = new FirefoxDriver(options);
I tried to rewrite it into C#:
DesiredCapabilities cap = DesiredCapabilities.Firefox();
cap.SetCapability("browserName", "anotherbrowser");
cap.SetCapability("firefox_binary", #"C:\FireFox_BasedBrowser\anotherbrowser.exe");
IWebDriver driver = new FirefoxDriver(cap); //here's error
But I also got an error:
["System.ArgumentException" in WebDriver.dll] There is already an option for the browserName capability. Please use
the instead.
Please, help me, I can't find any solutions.
P.s. I can't use original Firefox browser, because it doesn't have same advantages as this modified Firefox.
Use FirefoxDriverService.CreateDefaultService(...) to define another path for Firefox:
var service = FirefoxDriverService.CreateDefaultService(#"C:\drivers", "geckodriver.exe");
service.FirefoxBinaryPath = #"C:\Program Files (x86)\Mozilla Firefox\firefox.exe";
var driver = new FirefoxDriver(service);
I need to start Selenium with Firefox Portable.
If I start Firefox.exe portable with doublé clic, it starts.
The path to Firefox.exe is correct: A FireFoxPortable folder inside Debug project's folder.
This is the code I use:
var driverService = FirefoxDriverService.CreateDefaultService();
driverService.FirefoxBinaryPath =
Path.Combine(
AppDomain.CurrentDomain.BaseDirectory,
"FireFoxPortable",
"FireFox.exe");
driverService.HideCommandPromptWindow = true;
driverService.SuppressInitialDiagnosticInformation = true;
var options = new FirefoxOptions();
var driver = new FirefoxDriver(options);
Creating the driver I have an exception -> Cannot find Firefox binary in PATH or default install locations. Make sure Firefox is installed. OS appears to be: Vista
I try this variant, but no work:
var driver = new FirefoxDriver(driverService);
I'm using this nuget packages:
Is this the correct way?
Thanks for your time!
UPDATE ---------------------------------------------
With this code Works:
var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory,
"FireFoxPortable", "FireFox.exe");
FirefoxProfile profile = new FirefoxProfile();
var driver = new FirefoxDriver(new FirefoxBinary(path),profile);
But a Warning for new FirefoxDriver Shown: FirefoxDriver should not be constructed with a FirefoxBinary object. Use FirefoxOptions instead. This constructor will be removed in a future release.'
What's the correct way?
I am using gecko/marionette driver and have tried both selenium 2 and selenium 3.
I've successfully started a Firefox session with the web driver and without a profile using both options and services to specify a binary:
FirefoxOptions options = new FirefoxOptions();
options.BrowserExecutableLocation = #"C:\Program Files (x86)\Mozilla\Firefox\firefox.exe";
driver = new FirefoxDriver(options);
or
FirefoxDriverService service = FirefoxDriverService.CreateDefaultService();
service.FirefoxBinaryPath = #"C:\Program Files (x86)\Mozilla Firefox\firefox.exe";
driver = new FirefoxDriver(service);
However, when I try to load a profile into it by adding options:
options.Profile = profile;
it gives a corrupt deflate stream exceptionn.
This also occurs when I manually specify the binary file and then try to load the profile (which is deprecated in version 3)
This same profile grab and loading was working prior to the new Firefox update. Is there anything special that needs to be done to get this working?
I've encountered the same problem corrupt deflate stream when loading custom profile, and here is what helped me:
I opened the folder of my custom profile %AppData%\Mozilla\Firefox\Profiles\TestProfile and deleted all empty (0 kB size) files. (they were "AlternateServices.txt" and "parent.lock" in the root of profile directory)
After that the following code worked like a charm:
var FirefoxProfileManager = new FirefoxProfileManager();
var profile = FirefoxProfileManager.GetProfile("TestProfile");
//driver = new FirefoxDriver(profile);
var firefoxService = FirefoxDriverService.CreateDefaultService();
var options = new FirefoxOptions();
options.Profile = profile;
driver = new FirefoxDriver(firefoxService, options, new TimeSpan(0, 0, 30));
The below works for me when using the default profile, I have used this to solve an issue where-by its not using a root cert that we need to get through our security system:
FirefoxDriverService service = FirefoxDriverService.CreateDefaultService(#"C:\\TestData\Dependencies", "geckodriver.exe");
service.FirefoxBinaryPath = #"C:\Program Files (x86)\Mozilla Firefox\firefox.exe";
FirefoxProfileManager profileM = new FirefoxProfileManager();
FirefoxProfile profile = profileM.GetProfile("default");
//service.Port = 64444;
FirefoxOptions options = new FirefoxOptions();
options.Profile = profile;
Instance = new FirefoxDriver(service,options, TimeSpan.FromMinutes(1));
TurnOnWait();
HTH