Firefox 驱动程序未在 VM 机器上启动
Firefox driver is not getting launch on VM machine
1. resources I used : C# , Selenium , VS 2017, Jenkins , VM machine (windows 10) , Nunit v3.9, geckoDrive v19, firefox v56/57
2. I can execute firefox / chrome browser cases on local machine
3. I can execute chrome browser cases on VM machine
4. Issue : **I can Not execute firefox cases on VM machine and its throwing below error.**
**Error Message**
OpenQA.Selenium.WebDriverException:无法在 http://localhost:50352/
上启动驱动程序服务
拆解:System.NullReferenceException:对象引用未设置为对象的实例。
我在下面添加了一些代码,这是抛出问题的地方
堆栈跟踪
at OpenQA.Selenium.DriverService.Start()
at OpenQA.Selenium.Remote.DriverServiceCommandExecutor.Execute(Command commandToExecute)
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
at OpenQA.Selenium.Remote.RemoteWebDriver.StartSession(ICapabilities desiredCapabilities)
at OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor commandExecutor, ICapabilities desiredCapabilities)
at OpenQA.Selenium.Firefox.FirefoxDriver..ctor(String geckoDriverDirectory, FirefoxOptions options, TimeSpan commandTimeout)
at MPAutomation.Driver.Initialize(String browser) in D:\Workspace.Automation\MPproject\MPAutomation\Utility\Driver.cs:line 79
# code on this line : Instance = new FirefoxDriver(service.FirefoxBinaryPath, options, TimeSpan.FromSeconds(10));
at MPAutomation.BaseTest.Init() in D:\Workspace.Automation\MPproject\MPAutomation\Utils\BaseTest.cs:line 54
#code here : LoginPage.GoTo(Settings.BrowserType); # I am passing "Firefox"
--TearDown
at MPAutomation.Driver.Close() in D:\Workspace.Automation\MPproject\MPAutomation\Utility\Driver.cs:line 117
# Instance.Close();
at MPAutomation.BaseTest.Cleanup() in D:\Workspace.Automation\MPproject\MPAutomation\Utils\BaseTest.cs:line 97
---------------------------------------------------------------------
firefox implemnetation 在 Driver.cs 中看起来像这样
- 我也尝试过各种版本的 Firefox,但 none 在 VM
上工作
else if(browser.Equals(Constant.Firefox)) {
// driver init from here
FirefoxDriverService service = FirefoxDriverService.CreateDefaultService(DrivePath);
service.FirefoxBinaryPath = DrivePath;
var profile = new FirefoxProfile();
profile.AcceptUntrustedCertificates = true;
var options = new FirefoxOptions();
options.AcceptInsecureCertificates = true;
options.Profile = profile;
Instance = new FirefoxDriver(service.FirefoxBinaryPath, options, TimeSpan.FromSeconds(10));
Instance.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10);
Utility.Logger.Write("***** Firefox Browser has been initialized now *********");
}
--------------------------------
5. We have one certificate for firefox and which has already been taken care locally and on VM
6. I am not sure why automation is not able to start firefox on VM
终于找到了这个问题的解决方案。
我们需要在 VM 上为 firefox 设置 "sandbox level"。
profile.setPreference("security.sandbox.content.level", 5);
1. resources I used : C# , Selenium , VS 2017, Jenkins , VM machine (windows 10) , Nunit v3.9, geckoDrive v19, firefox v56/57
2. I can execute firefox / chrome browser cases on local machine
3. I can execute chrome browser cases on VM machine
4. Issue : **I can Not execute firefox cases on VM machine and its throwing below error.**
**Error Message**
OpenQA.Selenium.WebDriverException:无法在 http://localhost:50352/
上启动驱动程序服务拆解:System.NullReferenceException:对象引用未设置为对象的实例。
我在下面添加了一些代码,这是抛出问题的地方
堆栈跟踪
at OpenQA.Selenium.DriverService.Start()
at OpenQA.Selenium.Remote.DriverServiceCommandExecutor.Execute(Command commandToExecute)
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
at OpenQA.Selenium.Remote.RemoteWebDriver.StartSession(ICapabilities desiredCapabilities)
at OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor commandExecutor, ICapabilities desiredCapabilities)
at OpenQA.Selenium.Firefox.FirefoxDriver..ctor(String geckoDriverDirectory, FirefoxOptions options, TimeSpan commandTimeout)
at MPAutomation.Driver.Initialize(String browser) in D:\Workspace.Automation\MPproject\MPAutomation\Utility\Driver.cs:line 79
# code on this line : Instance = new FirefoxDriver(service.FirefoxBinaryPath, options, TimeSpan.FromSeconds(10));
at MPAutomation.BaseTest.Init() in D:\Workspace.Automation\MPproject\MPAutomation\Utils\BaseTest.cs:line 54
#code here : LoginPage.GoTo(Settings.BrowserType); # I am passing "Firefox"
--TearDown
at MPAutomation.Driver.Close() in D:\Workspace.Automation\MPproject\MPAutomation\Utility\Driver.cs:line 117
# Instance.Close();
at MPAutomation.BaseTest.Cleanup() in D:\Workspace.Automation\MPproject\MPAutomation\Utils\BaseTest.cs:line 97
---------------------------------------------------------------------
firefox implemnetation 在 Driver.cs 中看起来像这样 - 我也尝试过各种版本的 Firefox,但 none 在 VM
上工作else if(browser.Equals(Constant.Firefox)) {
// driver init from here
FirefoxDriverService service = FirefoxDriverService.CreateDefaultService(DrivePath);
service.FirefoxBinaryPath = DrivePath;
var profile = new FirefoxProfile();
profile.AcceptUntrustedCertificates = true;
var options = new FirefoxOptions();
options.AcceptInsecureCertificates = true;
options.Profile = profile;
Instance = new FirefoxDriver(service.FirefoxBinaryPath, options, TimeSpan.FromSeconds(10));
Instance.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10);
Utility.Logger.Write("***** Firefox Browser has been initialized now *********");
}
--------------------------------
5. We have one certificate for firefox and which has already been taken care locally and on VM
6. I am not sure why automation is not able to start firefox on VM
终于找到了这个问题的解决方案。
我们需要在 VM 上为 firefox 设置 "sandbox level"。
profile.setPreference("security.sandbox.content.level", 5);