Tag: selenium webdriver

为什么我不能使用Selenium Webdriver通过Firefox下载文件?

我试图使用配置文件设置在Firefox中下载文件,但它不起作用你能告诉我我做错了什么,我使用的代码发布在这一行下面 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”, “image/jpeg,application/vnd.oasis.opendocument.text,application/vnd.oasis.opendocument.spreadsheet,” + “application/vnd.oasis.opendocument.presentation,application/vnd.oasis.opendocument.graphics,” + “application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,” + “application/vnd.ms-powerpoint,application/vnd.openxmlformats-officedocument.presentationml.presentation,” + “application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.mozilla.xul+xml,” + “application/vnd.google-earth.kml+xml”);

使用Selenium以不同的用户身份运行Internet Explorer

我想用Selenium作为不同的用户启动单个Internet Explorer实例。 我提到了以下post,但没有到达任何地方。 如何以特定域用户身份运行Internet Explorer Selenium测试? 你能指出我如何实现它的正确方向吗?

无法使用c#在selenium中生成Extent报告(版本3.1.3)

我是C#的新手,我正在尝试使用ExtentReports生成报告(使用版本:3.13)。 任何帮助都将非常感谢谢谢。 我收到以下错误:消息:System.InvalidOperationException:没有记者被启动。 Atleast 1记者必须开始创建测试。 这是我的代码:` using AventStack.ExtentReports; using AventStack.ExtentReports.Reporter; using NUnit.Framework; using NUnit.Framework.Interfaces; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace AutomationReports { class ReportsGenerationClass { protected ExtentReports _extent; protected ExtentTest _test; [OneTimeSetUp] protected void Setup() { var dir = TestContext.CurrentContext.TestDirectory + “\\”; var fileName = this.GetType().ToString() + “.html”; var htmlReporter […]

使用webdriver和弹出窗口进行http授权

我正在尝试使用Selenium WebDriver使用用户名和密码自动登录到站点。 我完成了我的研究,我不相信WebDriver支持这个function,所以我需要找到另一种方法。 我正在尝试自动登录的网站位于此处 。 当提示登录时,出现一个似乎不属于浏览器的弹出窗口。 我正在使用Firefox和Chrome。 看来可能需要Windows API? 我已经尝试在URL中传递凭据,但这不起作用。 还尝试了sendkeys,但收到了Windowsexception,表明应用程序没有接受Windows消息。 我也尝试使用driver.windowhandles切换当前handle但弹出窗口似乎不是新句柄。 有人有什么想法吗? 我有点卡住了。 进入弹出窗口的初步代码是: IWebDriver driver = new FirefoxDriver(); driver.Navigate().GoToUrl(“http://www.portal.adp.com”); string currentWindow = driver.CurrentWindowHandle; IWebElement userLogin = driver.FindElement(By.Id(“employee”)); userLogin.Click();

Selenium Webdriver c#无需等待页面加载

我有以下情况: 我想导航到一个页面。 然后在出现时立即单击按钮(不等待页面加载)。 我不想等待初始页面加载,因为它需要很长时间。 我的程序目前一直停滞,直到页面加载,然后单击按钮。 我基本上想要导航到链接,然后没有等待页面并继续我的代码。 无论如何围绕这个?

无法使用Selenium WebDriver在Chrome中加载默认配置文件

我正在使用Selenium WebDriver在需要http身份validation的页面上执行某些操作。 我已经登录了我的默认个人资料。 但是seleniumchromedriver将自动使用每个用途的新配置文件,因此我无法通过身份validation阶段。 因此,我想在Selenium WebDriver for Chrome上使用我的默认配置文件(使用帐户登录)。 即使我使用下面的代码,默认配置文件似乎也没有加载到Chrome中 ChromeOptions options = new ChromeOptions(); options.AddArguments(“user-data-dir=C:/Users/user_name/AppData/Local/Google/Chrome/User Data/Default”); IWebDriver driver = new ChromeDriver(@”C:\Users\Lawrence\Desktop\selenium-dotnet-2.33.0\net40″,options); 有帮助吗? =)

无法从WebDriver获取正确的控制台日志(Chrome,C#)

我在Selenium WebDriver,C#中为Chrome浏览器编写了以下微测试(它没用,但在这里并非如此): [Test] public void T2_API_001_PrintingAlerts() { pgactions.OpenDataset(driver, settings.dataset); // opening page for (int i = 0; i < 10; i++) { ((IJavaScriptExecutor)driver).ExecuteScript("TsTable.Admin.log('this is error message', true);"); } var logs = driver.Manage().Logs.GetLog(LogType.Browser); foreach (var log in logs) { Console.WriteLine(log.ToString()); } Thread.Sleep(100000); } 在VS中调试控制台我希望看到(就像我在Web浏览器实例中看到的WebDriver启动的那样): [14:02:22.816] Settings valid! randomTable.js:6711 [14:02:22.976] Constructing table… randomTable.js:6711 [14:02:22.976] Validating 32 rows […]

无法在selenium webdriver中找到::之前的css选择器元素

我想测试复选框已选中或未选中状态。 这是复选框选中的html代码 ::before ::before是css选择器。 当我转移到复选框时,它显示webelement为span.check::before 但 driver.FindElement(By.CssSelector(“span.check::before”)); 抛出元素未找到exception。 任何帮助将受到高度赞赏。

如何用c#中的selenium2 webdriver点击特定坐标?

我正在使用Firefox进行测试,但是在单击闪存按钮时出现问题。 我没有访问flash元素的源代码,所以我不能使用flash-selenium或类似的东西进行测试。 目前我的解决方案是使用windows api获取屏幕截图,并处理屏幕截图并定义我应该点击它的按钮坐标,然后再次使用windows api点击坐标。 但是这样,我不能用我的电脑做任何其他事情,我必须等待与webdriver自己的function不同的交互式电脑。 我正在尝试使用webdriver在Firefox页面上获取屏幕截图(实际上已完成),并在屏幕截图中获取flash按钮的区域坐标并单击它而不使用基于元素的因为当我用于检查是否可能是selenium ide时,它不能点击像clickat这样的function,或者我做错了什么。

不知道为什么要使用无头浏览器

我们只是在不使用无头浏览器的情况下实现了CI,而是实际的浏览器。 因此,一旦开发团队检查了新代码。我们的烟雾自动化代码在自动机器上作为后台进程运行并发送结果。 如果有任何失败,它会发送截图。 我们没有得到的是,使用无头浏览器进行上述处理的优势是什么。 我们需要我们的烟雾脚本才能获得此保险。 比如使用Select,Calendar,Uploaded等控件提交一个可以在5分钟内运行的大型表单,而不是简单的网页加载。