Quantcast
Channel: Active questions tagged selenium - Stack Overflow
Viewing all articles
Browse latest Browse all 99418

Selenium C#: Getting System.ArgumentOutOfRangeException when I add and extension and start firefox

$
0
0

I have a firefox extension which works pretty well when I use it in java, python and js. However when I use the same extension in C#, it throws an exception. Also, adding a chrome extension in my C# doesn't show any errors.

C#:

using System;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium.Remote;
using System.Threading;
namespace sel_cs
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            IWebDriver driver = null;
            try
            {
                FirefoxOptions options = new FirefoxOptions();
                FirefoxProfile profile = new FirefoxProfile();
                profile.AddExtension("/path/to/firefox-ext.xpi");
                options.Profile = profile;
                ICapabilities capabilities = options.ToCapabilities();
                driver = new RemoteWebDriver(new Uri("http://localhost:4444/wd/hub"), capabilities);
                driver.Navigate().GoToUrl("http://www.google.com");
                driver.Quit();
            }
            catch(Exception e)
            {
                Console.Write(e);
                driver.Quit();
            }
        }
    }
}

Exception stacktrace:

System.ArgumentOutOfRangeException: Year, Month, and Day parameters describe an un-representable DateTime.
  at System.DateTime.DateToTicks (System.Int32 year, System.Int32 month, System.Int32 day) [0x0006c] in <d2ec5c92492f4d6ba8c422bdf574b786>:0 
  at System.DateTime..ctor (System.Int32 year, System.Int32 month, System.Int32 day, System.Int32 hour, System.Int32 minute, System.Int32 second) [0x00000] in <d2ec5c92492f4d6ba8c422bdf574b786>:0 
  at System.IO.Compression.ZipStorer.DosTimeToDateTime (System.UInt32 dosTime) [0x00000] in <19027cc8501444099501b87290061165>:0 
  at System.IO.Compression.ZipStorer.ReadCentralDirectory () [0x00167] in <19027cc8501444099501b87290061165>:0 
  at OpenQA.Selenium.Firefox.FirefoxExtension.Install (System.String profileDirectory) [0x00063] in <19027cc8501444099501b87290061165>:0 
  at OpenQA.Selenium.Firefox.FirefoxProfile.InstallExtensions () [0x00027] in <19027cc8501444099501b87290061165>:0 
  at OpenQA.Selenium.Firefox.FirefoxProfile.WriteToDisk () [0x00038] in <19027cc8501444099501b87290061165>:0 
  at OpenQA.Selenium.Firefox.FirefoxProfile.ToBase64String () [0x00006] in <19027cc8501444099501b87290061165>:0 
  at OpenQA.Selenium.Firefox.FirefoxOptions.GenerateFirefoxOptionsDictionary () [0x00019] in <19027cc8501444099501b87290061165>:0 
  at OpenQA.Selenium.Firefox.FirefoxOptions.ToCapabilities () [0x00015] in <19027cc8501444099501b87290061165>:0 
  at sel_cs.MainClass.Main (System.String[] args) [0x00057] in /home/local/prasanth/Projects/sel_cs/sel_cs/Program.cs:20

WebDriver.dll version: 3.14.0

Selenium server version: 3.9.1

Firefox version: 70.0

Geckodriver version: 0.24.0


Viewing all articles
Browse latest Browse all 99418

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>