Tag: firefox

使用Process.Start启动Firefox:当您设置Usename和Password时,Firefox无法启动

当我尝试使用Process.Start和ProcessStartInfo(.NET)启动Firefox时,一切似乎都能正常工作。 但是当我指定另一个帐户(用户的成员)的用户名和密码时,似乎什么也没发生。 相同的代码适用于Calc.exe或IE。 这很奇怪。 有任何想法吗? 这是代码: System.Diagnostics.ProcessStartInfo pInfo = new System.Diagnostics.ProcessStartInfo(); pInfo.CreateNoWindow = false; pInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal; pInfo.WorkingDirectory = “{WorkingDirectory}”; pInfo.Arguments = “{CommandLineArgs}”; pInfo.FileName = “{ExecutableAddress}”; pInfo.ErrorDialog = true; pInfo.UseShellExecute = false; pInfo.UserName = “{LimitedAccountUserName}”; pInfo.Password = “{SecureLimitedAccountPassword}”; System.Diagnostics.Process.Start(pInfo); 感谢大家。

selenium webdriver管理速度?

我刚刚从一个非常老的版本更新了我的selenium WebDriver,它允许我通过以下方式控制驱动程序速度: var _driver = new FireFoxDriver(); _driver.Manage().Speed = Speed.Medium; 安装FireFox 7后,运行selenium测试我的项目不再有效。 所以我通过nuGet为2.8.0.0升级了dll,现在管理速度的能力已经消失了。 还有其他办法吗? 非常感谢

Selenium Grid 2 – 远程Webdriver未在FireFox中设置用户代理首选项

我在Windows机器上使用selenium server 2.28。 我已经设置了集线器和节点。 我正在使用.net来编写我的测试用例。 我使用以下代码使用自定义FireFox(17.0.1)配置文件与用户代理更改(到iPhone)。 FirefoxProfileManager profileManager = new FirefoxProfileManager(); FirefoxProfile profile = profileManager.GetProfile(FireFox_Profile_Name); profile.SetPreference(“general.useragent.override”, _sUserAgent); DesiredCapabilities capability = DesiredCapabilities.Firefox(); capability.SetCapability(FirefoxDriver.ProfileCapabilityName, profile); 我正在实例化一个这样的RemoteWebDriver实例: driver = new RemoteWebDriver(new Uri(“hub_uri”), capability); 当我在节点机器上检查firefox实例中的about:config时,我根本看不到general.useragent.override首选项。 如果我使用: driver = new FirefoxDriver(profile); 首选项设置正确。 我错过了什么吗?

如何在作为Windows服务运行的Jenkins上以无头模式运行Selenium测试(C#,.NET)

我正在尝试设置Jenkins(版本2.117)并使用Selenium在Windows 10中的.NET堆栈上运行自动化测试,Jenkins作为Windows服务运行。 我正在尝试使用Firefox 56的Firefox Web驱动程序,它支持无头模式。 机器和软件 Windows 10专业版 jenkins2.117 Selenium Webdriver(截至此问题的最新版本) Firefox 56,32位 GeckoDriver v0.16.1 Visual Studio 2017企业版 selenium测试 [TestClass] public class SeleniumTest { [TestMethod] [TestProperty(“Selenium”, “Google”)] public void GoToGoogle() { var options = new FirefoxOptions(); options.AddArgument(“-headless”); var driver = new FirefoxDriver(options); driver.Navigate().GoToUrl(“https://www.google.com”); StringAssert.Contains(driver.PageSource, “Google”); } } 我可以通过Visual Studio进行测试,但在Jenkins构建期间失败了。 用于运行测试的命令: “C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\Extensions\TestPlatform\vstest.console.exe” […]

尝试启动Firefox驱动程序时出错

请在编写启动firefox驱动程序的代码时出现此错误: ================================================== ================================ WebDriver.dll中发生未处理的“OpenQA.Selenium.DriverServiceNotFoundException”类型exception 附加信息:geckodriver.exe文件不存在于当前目录或PATH环境变量的目录中。 该驱动程序可以从https://github.com/mozilla/geckodriver/releases下载。 这是代码: using System; using System.Collections.Generic; using System.Linq; using System.Text; using OpenQA.Selenium; using OpenQA.Selenium.Firefox; using System.Threading.Tasks; namespace FireFox_Driver_Launch { class Program { static void Main(string[] args) { var Driver = new FirefoxDriver(); Driver.Navigate().GoToUrl(“http://www.starwoodhotels.com/preferredguest/account/enroll/index.html”); } } } ================================================== ============== 我还添加了“Manager Nuget Packages”中的selenium webdriver包。 我搜索了这个网站和谷歌的解决方案。 但是,我还没有得到解决方案。 firefox浏览器安装在PC上。 我已经下载了geckodriver。 请问,我怎么把它放在PATH中? 我相信它应该在系统环境变量中? 谢谢您的帮助。

当我将Webdriver Firefox配置文件设置为默认下载所有文件时它无法正常工作

我设置firefox配置文件默认下载所有文件,但是当涉及到图像时,它弹出一个对话框,并告诉我天气保存或查看。 我使用的代码如下 var folderName = “temp”; var profile = new FirefoxProfile { EnableNativeEvents = true }; profile.SetPreference(“browser.download.folderList”, 2); profile.SetPreference(“browser.download.manager.showWhenStarting”, false); profile.SetPreference(“browser.download.dir”, folderName); profile.SetPreference(“browser.download.downloadDir”, folderName); profile.SetPreference(“browser.download.defaultFolder”, folderName); profile.SetPreference(“browser.helperApps.neverAsk.saveToDisk”, “application/all”); _webDriver = new FirefoxDriver(profile);

Selenium:Firefox驱动程序,使用c#中的SelectElement从下拉列表中选择项目无法正常工作

我正在尝试通过使用显示的文本来尝试选择下拉列表中的值。 场景如下。 我的HTML看起来像。 Test1 Test2 Test3 Test4 通过使用selenium我想使用下拉列表中的第二个项目test2。 我为此编写的C#代码是。 FirefoxDriverService service = FirefoxDriverService.CreateDefaultService(); service.FirefoxBinaryPath = @”C:\Program Files (x86)\Mozilla Firefox\firefox.exe”; string localURL = “http://localhost:82/”; using (IWebDriver driver = new FirefoxDriver(service)) { driver.Navigate().GoToUrl(localURL); var div = driver.FindElement(By.Id(“TestContainer”)); div.Click(); IWebElement dropDownListBox = div.FindElement(By.TagName(“select”)); SelectElement demoSelect = new SelectElement(dropDownListBox); demoSelect.SelectByText(“Test2”); driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(2)); } 除了以上所述,我甚至尝试逐个迭代选项并选择下面的相应项目也无济于事。 if (option.Text.Equals(“Test2”)) { option.Click(); driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(2)); break; […]

在Saucelabs中使用Selenium远程Firefox webdriver安装扩展程序

问题 尝试在Saucelabs上远程执行Selenium测试期间安装Firefox浏览器扩展。 在本地执行测试时,扩展程序在Firefox中安装并处于活动状态,但在Saucelabs上的远程执行中,扩展名不会出现在已安装的扩展名列表中。 按照此Saucelabs 支持文章中概述的步骤操作。 建立 Selenium.Support v2.48.2或v2.49.0 Selenium.WebDriver v2.48.2或v2.49.0 Windows 10或7 Firefox 43 C#测试设置 private static FirefoxProfile CreateFirefoxProfile() { FirefoxProfile profile = new FirefoxProfile(); profile.AddExtension(“Tools/modify_headers-0.7.1.1-fx.xpi”); profile.SetPreference(“general.useragent.override”, “UA-STRING”); profile.SetPreference(“extensions.modify_headers.currentVersion”, “0.7.1.1-signed”); profile.SetPreference(“modifyheaders.headers.count”, 1); profile.SetPreference(“modifyheaders.headers.action0”, “Add”); profile.SetPreference(“modifyheaders.headers.name0”, “SampleHeader”); profile.SetPreference(“modifyheaders.headers.value0”, “test1234”); profile.SetPreference(“modifyheaders.headers.enabled0”, true); profile.SetPreference(“modifyheaders.config.active”, true); profile.SetPreference(“modifyheaders.config.alwaysOn”, true); profile.SetPreference(“modifyheaders.config.start”, true); return profile; } private static IWebDriver GetRemoteDriver() { var […]

动态设置PDF文件名

我希望我能够准确地解释我的情况。 我有一个ASP.NET页面,使用以下代码为用户转储PDF文件: Response.ContentType = “application/pdf”; Response.AppendHeader(“content-disposition”, string.Format(“inline; filename={0}”, getFileName(DateTime.Now))); 我使用“内联”而不是“附件”的原因,因此我可以强制用户直接在浏览器中查看PDF,而不是打开杂技演员来查看PDF。 到目前为止一切都很好,但是当用户想要保存文件时,文件名应该设置为“getFileName(DateTime.Now)” ,而不是像myPDFpage.pdf那样获取页面的名称。 无论如何,没有将内容处置设置为“attachment”,用户是否使用getFileName()方法指定的名称保存文件? 提前致谢。 badallen

如何检查浏览器是否打开

如何检查浏览器是否打开? 我知道我可以检查一个进程,但有时进程正在运行,但在计算机浏览器上仍在启动。 我只需要2个浏览器,Chrome和Firefox。