我可以用firefox Portable控制硒吗?

时间:2019-07-05 00:55:37

标签: c# selenium selenium-webdriver selenium-firefoxdriver portable-applications

我已经阅读了很多有关使用硒和便携式Firefox的文章。但是代码对我不起作用。我做错什么了吗?我正在使用firefox Portable 67和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/");

1 个答案:

答案 0 :(得分:0)

我今天没有时间,但是尝试改变

options.BrowserExecutableLocation = @"D:\C# Project\FirefoxPortal tesst\FirefoxPortal tesst\bin\Debug\FirefoxPortable\FirefoxPortable.exe";

options.BrowserExecutableLocation = @"D:\C# Project\FirefoxPortal tesst\FirefoxPortal tesst\bin\Debug\FirefoxPortable\App\firefox64\firefox.exe";

或保存到firefox.exe文件的任何地方。