简体   繁体   中英

Error, when I'm initializing IE browser using Selenium C#

When I initialize IE browser using Selenium C#,

 case BrowserType.InternetExplorer:
                     IWebDriver driver = new InternetExplorerDriver("C:\\Program Files\\internet
 explorer\\iexplore.exe");
                     driver.Navigate().GoToUrl("http://www.google.com");
                    //InternetExplorerOptions options2= new InternetExplorerOptions();
                    // options2. = ("C:\\Program Files\\internet explorer\\iexplore.exe");
                     //DriverContext.Driver = new InternetExplorerDriver();
                     //DriverContext.Browser = new Browser(DriverContext.Driver);
                    // DriverContext.Browser.Maximize();
                  break;

I get the following error:

System.NullReferenceException : Object reference not set to an instance of an object. TearDown : System.NullReferenceException : Object reference not set to an instance of an object.

From the available code the only thing which jumps out to me is that you are specifying the location of IE. I would drop this and allow the webdriver to use the default location. I've never had to specify path with IE. I don't think it's possible for it to be in an alternate location.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM