Tag: webdriver

Selenium webdriver选择新窗口c#

尝试在c#中使用selenium webdriver编写一些测试用例,并且有一个我不确定如何解决的场景 用户场景正在搜索患者的表格,选择患者然后打开一个新窗口,然后在窗口上断言各种项目 我的问题是我无法选择新窗口来断言任何东西,它不是一个弹出窗口,它是一个全新的浏览器窗口,但它没有窗口标题/名称来识别它,我怎么能够将驱动程序焦点切换到此窗口? 提前致谢

无法在45000内启动套接字

我正在使用FF版本19 它一切正常,直到昨天,突然今天早上我开始得到这个错误,我有与之前运行的相同的确切代码,没有任何改变 错误信息: Test ‘M:.TestCases.12’ failed: Failed to start up socket within 45000 OpenQA.Selenium.WebDriverException: Failed to start up socket within 45000 at OpenQA.Selenium.Firefox.Internal.ExtensionConnection.ConnectToBrowser(Int64 timeToWaitInMilliSeconds) at OpenQA.Selenium.Firefox.Internal.ExtensionConnection.Start() at OpenQA.Selenium.Firefox.FirefoxDriver.StartClient() at OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor commandExecutor, ICapabilities desiredCapabilities) at OpenQA.Selenium.Firefox.FirefoxDriver..ctor(FirefoxBinary binary, FirefoxProfile profile, TimeSpan commandTimeout) at OpenQA.Selenium.Firefox.FirefoxDriver..ctor(FirefoxBinary binary, FirefoxProfile profile) at OpenQA.Selenium.Firefox.FirefoxDriver..ctor(FirefoxProfile profile) 0 passed, 1 failed, 0 skipped, took […]

如何使用C#在Firefox中启动特定的URL

我正在尝试使用Firefox启动特定的URL。 但我只能打开Firefox浏览器而无法启动该URL。 class BrowserHelper { IWebDriver driver; string path = Path.Combine(Environment.CurrentDirectory, @”gecko\\”); public void Navigate(string url) { path = path.Replace(@”\”, @”\\”); var driverService = FirefoxDriverService.CreateDefaultService(path); driverService.HideCommandPromptWindow = true; if (driver == null) { driver = new FirefoxDriver(driverService); } driver.Url = url; driver.Navigate().GoToUrl(driver.Url); driver.Manage().Window.Maximize(); } } class Realtest { BrowserHelper BH = new BrowserHelper(); public void […]

如何查找具有动态ID的ExtJS元素

我正在使用Selenium,需要获取控件的ID,但ID是动态的,我无法得到它。 数字1122是动态的,还有其他按钮具有相同的开始button-###+btnWrap 。

C#Selenium – 在不断增长的页面上寻找元素

我试图找到一个更好的方法来做到这一点,而不是使用: js.ExecuteScript(“scroll(0, 1300)”); 我有一个页面,数据可以改变,使页面高度上下变化。 因此,当我今天点击一个位于1500px的元素时,明天它可能是800px并且找不到元素并且测试用例失败。 那么你们有什么用来在页面上找到尺寸变化的元素?

使用Selenium PageObject设计模式的最佳方法是什么

我正在使用Selenium 2 Web Driver和C#.Net创建测试。 在阅读了很多Selenium文档之后,我仍然不确定如何使用PageObject设计模式进行测试。 许多selenium示例仅在Java中显示,并且.Net的API绑定并不总是与人们认为的相似,这是由于某些语言设置的限制和标准。 在.Net Selenium Web Driver中将PageObject设计模式与PageFactory一起使用的最佳方法是什么? 最终,我希望我的PageObjects能够处理更多function,而不是使用PageObject IWebElements进行NUnit测试。 下面是我目前将如何创建我的测试的示例。 public class LoginPage { private IWebDriver webDriver; [FindsBy(How = How.Id, Using = “ctl00_ctl00_ctl00_insideForm_insideForm_content_txtPassword”)] public IWebElement Password { get; set; } [FindsBy(How = How.Id, Using = “ctl00_ctl00_ctl00_insideForm_insideForm_content_cmdSubmit”)] public IWebElement SubmitButton { get; set; } [FindsBy(How = How.Id, Using = “ctl00_ctl00_ctl00_insideForm_insideForm_content_txtUserName”)] public IWebElement UserName […]

C#Selenium’ExpectedConditions已过时’

当尝试使用ExpectedConditions显式等待元素变得可见时,Visual Studio警告我它现在已经过时,很快就会从Selenium中删除。 实现相同结果的当前/新方法是什么? var wait = new WebDriverWait(driver, new TimeSpan(0, 0, 30)); var element = wait.Until(ExpectedConditions.ElementIsVisible(By.Id(“content-section”)));

升级到版本3.9后无法启动Selenium IE Driver

从这里更新到IEDriverServer 3.9 for 64-bit后,我在尝试使用IE运行任何测试时遇到以下exception(版本:11.0.9600.17842,Win8.1)。 有谁知道怎么解决这个问题,还是应该降级到3.8? OpenQA.Selenium.WebDriverException:抛出了一个带有null响应的exception,向URL http:// localhost:53379 / session发送HTTP请求到远程WebDriver服务器。 exception的状态是ReceiveFailure,消息是:基础连接已关闭:接收上发生意外错误。 —-> System.Net.WebException:基础连接已关闭:接收上发生意外错误。 —-> System.IO.IOException:无法从传输连接读取数据:远程主机强制关闭现有连接。 —-> System.Net.Sockets.SocketException:远程主机TearDown强制关闭现有连接:System.NullReferenceException:未将对象引用设置为对象的实例。 堆栈跟踪如下: 结果StackTrace:在OpenQA.Selenium的OpenQA.Selenium.Remium.DriverServiceCommandExecutor.Execute(Command commandToExecute)中的OpenQA.Selenium.Remote.HttpCommandExecutor.MakeHttpRequest(HttpRequestInfo requestInfo)中的OpenQA.Selenium.Remote.HttpCommandExecutor.Execute(命令commandToExecute)。在OpenQA.Selenium的OpenQA.Selenium.Remium.RemoteWebDriver..ctor(ICommandExecutor commandExecutor,ICapabilities desiredCapabilities)的OpenQA.Selenium.Remote.RemoteWebDriver.StartSession(ICapabilities desiredCapabilities)上的Remote.RemoteWebDriver.Execute(String driverCommandToExecute,Dictionary`2参数)位于OpenQA.Selenium.IE.InlennetExplorerDriver..ctor()上的.IE.InternetExplorerDriver..ctor(InternetExplorerDriverService服务,InternetExplorerOptions选项)OpenQA.Selenium.Remote.HttpCommandExecutor.MakeHttpRequest中System.Net.HttpWebRequest.GetResponse()的WebException (HttpRequestInfo requestInfo) – System.Net.Sockets.NetworkStream.Read上的–IOException(Byte []缓冲区,Int32偏移量, System32.Net.Connection.SyncRead上的System.Net.PooledStream.Read(Byte []缓冲区,Int32偏移量,Int32大小)的Int32大小)(HttpWebRequest请求,Boolean userRetrievedStream,Boolean probeRead) – System.Net.Sockets上的SocketException System.SNet.Sockets.NetworkStream.Read(Byte []缓冲区,Int32偏移量,Int32大小)的.Socket.Receive(Byte []缓冲区,Int32偏移量,Int32大小,SocketFlags socketFlags)

为什么Selenium InternetExplorerDriver Webdriver在调试模式下非常慢(visual studio 2010和IE9)

我正在使用SeleniumHq站点中的示例代码 – 但在调试模式下,性能非常糟糕。 在发布模式下,整个测试大约需要6秒钟(包括启动和关闭IE)在调试模式下需要65秒? 示例代码只是: [Test] public void testBrowser() { // Do something here IWebDriver driver = new InternetExplorerDriver(); //Notice navigation is slightly different than the Java version //This is because ‘get’ is a keyword in C# driver.Navigate().GoToUrl(“http://www.google.com”); IWebElement query = driver.FindElement(By.Name(“q”)); query.SendKeys(“Cheese”); System.Console.WriteLine(“Page title is: ” + driver.Title); // TODO add wait driver.Quit(); } […]

使用Selenium 2查找嵌套的iFrame

我正在为遗留应用程序编写测试,其中主文档中有一个iFrame,然后是其中的另一个iFrame。 所以层次结构是: Html Div (id = tileSpace) iFrame (id = ContentContainer) iFrame (id = Content) Elements 这是我的代码(我正在使用C#) RemoteWebDriver driver = new InternetExplorerDriver(); var tileSpace = driver.FindElement(By.Id(“tileSpace”)); var firstIFrame = tileSpace.FindElement(By.Id(“ContentContainer”)); var contentIFrame = firstIFrame.FindElement(By.Id(“Content”)); 问题是,我无法达到第二级iFrame即contentIFrame 有任何想法吗?