Tag: webdriver

在C#中使用Selenium WebDriver中的特定Firefox配置文件

我正在尝试使用我已经为seflium 2设置的firefox配置文件,但没有C#的文档。 我试过的代码如下: FirefoxProfileManager profileManager = new FirefoxProfileManager(); FirefoxProfile profile = profileManager.GetProfile(profileName); driver = new FirefoxDriver(profile); 我在Java中看到的代码使用的是使用ProfilesIni而不是FirefoxProfileManager的代码,但这在C#中不可用。 以这种方式设置驱动程序时,使用的selenium配置文件具有所有默认设置,而不是我试图指向的配置文件中指定的设置。 我不确定我是否使用正确的方法来检索配置文件,但如果有人使用Selenium 2和C#,任何信息都会有所帮助。

如何使用WebDriver(Selenium 2)检查dom是否有类?

我对Selenium很新,所以如果这是一个愚蠢的问题,我道歉。 我已经成功地将IntelliJ(Play!框架)与Selenium连接起来,并使用firefoxDrivers创建了一些测试。 我正在尝试检查页面是否已经过正确validation。 长话短说,我正在选择这样一个元素: WebElement smallDecel = firefoxDriver.findElement(By.cssSelector(“#configTable tr:nth-child(2) td .playerDecelInput”)); 我做了一些进一步的操作(清除并更改值,提交’表单’),然后我想检查输入所在的TD是否给了另一个类。 所以,问题是 – 是否有一种简单的技术可以用来确定WebElement / DOM是否指定了类?

使用selenium Firefox webdriver将 文本清空

我在Windows 7上使用Firefox 21和C#WebDriver 2.33。我很困惑为什么以下测试失败(我只是检查我的配置设置是否正确)。 这在其他浏览器中传递。 [Test] public void FirefoxDriverWorks() { var firefoxDriver = new FirefoxDriver(); TestGoogleStillExists(firefoxDriver); firefoxDriver.Quit(); } public void TestGoogleStillExists(IWebDriver webDriver) { webDriver.Navigate().GoToUrl(“http://www.google.com”); var title = webDriver.FindElement(By.CssSelector(“head title”)); Assert.That(title.Text, Is.EqualTo(“Google”)); }

Selenium IE WebDriver:NoSuchElementException

我正在尝试使用Selenium Internet Explorer WebDriver,但是一旦我尝试在加载的页面中找到一个元素,它就会一直抛出exception。 我正在使用在Windows 8.1 x64计算机上运行的Selenium客户端和版本2.44,Internet Explorer 11(我尝试过32位和64位版本)的.NET实现。 这是我正在使用的C#测试代码: IWebDriver driver = new InternetExplorerDriver(); driver.Navigate().GoToUrl(“http://mytesturl.com”); const string name = “Test”; IWebElement nameElement = driver.FindElement(By.Name(“name”)); nameElement.SendKeys(name); //… 这是我正在运行测试的网页: TestSelenium <form action="” method=”post”> Insert name: Submit 一旦到达driver.FindElement(By.Name(“name”))调用,就会引发exception。 在此之前,执行按预期工作(在实例化webdriver时启动IE并正确导航到URL)。 这是我得到的例外: OpenQA.Selenium.NoSuchElementException : Unable to find element with name == name en OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse) en OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 […]

Selenium WebDriver – 没有司机在为我工作

我正在努力让Selenium测试运行。 我正在使用C#。 我遇到的每个司机都遇到了问题。 铬 var options = new OpenQA.Selenium.Chrome.ChromeOptions(); options.BinaryLocation = @”C:\Users\Vilem\AppData\Local\Google\Chrome\Application\”; using (IWebDriver driver = new OpenQA.Selenium.Chrome.ChromeDriver(options)) { … 好像找到了chromedriver.exe,但它可以找到Chrome二进制文件。 在自动搜索失败后,我明确设置了chrome.exe的路径。 我甚至在最后尝试使用“chrome.exe”。 我总是得到相同的结果: 找不到Chrome二进制文件: C:\用户\ Vilem \应用程序数据\本地\谷歌\镀铬\应用 火狐 new OpenQA.Selenium.Firefox.FirefoxDriver(); 我也尝试了配置文件: FirefoxProfile profile = new FirefoxProfile(@”E:\…\FirefoxProfile”); new OpenQA.Selenium.Firefox.FirefoxDriver(); 我得到的错误: 无法在45000毫秒内绑定到锁定端口7054 IE var ieOptions = new InternetExplorerOptions(); ieOptions.IntroduceInstabilityByIgnoringProtectedModeSettings = true; new InternetExplorerDriver(@”C:\Program Files (x86)\IEDriver\”, ieOptions); […]

从JavaScriptExecutor获取ExecuteScript的值

我有一个问题,我需要价值 string someValue = ((IJavaScriptExecutor)Global.Driver).ExecuteScript(“$(‘#publication_title’).val();”); Console.WriteLine(someValue); 任何的想法?

Selenium Webdriver – 如何为Firefox设置代理以“自动检测”

我的脚本在chrome和IE上运行正常,但由于firefox为其代理设置设置了“manual”,因此无法在firefox上启动。 如何将其设置为“自动检测”? C#中的源代码请。 谢谢

拖放被执行但它没有被执行 – webdriver

我已经尝试了这两个代码,它被执行但是动作没有执行,任何人都可以告诉我为什么? //Type one approach Actions action = new Actions(Browser.Driver); IWebElement sourceElement = Browser.Driver.FindElement(By.XPath(Filexpath)); IWebElement targetElement = Browser.Driver.FindElement(By.XPath(NewXpath)); //Type two approach Actions Sourcebuilder = new Actions(Browser.Driver); Actions SourceAction = Sourcebuilder.ClickAndHold(sourceElement); Sourcebuilder.Build(); SourceAction.Perform(); /// move and drop Actions builder = new Actions(Browser.Driver); Actions action = builder.MoveToElement(targetElement); builder.Release(targetElement); builder.Build(); action.Perform(); 提前致谢

Xunit为每个新测试创建Test类的新实例(使用WebDriver和C#)

有没有办法在使用Xunit的Webdriver(Selenium)在同一浏览器中运行多个测试,目前xunit为每个新测试启动新浏览器,下面是示例代码 public class Class1 { private FirefoxDriver driver; public Class1() { driver = new FirefoxDriver(); } [Fact] public void Test() { driver.Navigate().GoToUrl(“http://google.com”); driver.FindElementById(“gbqfq”).SendKeys(“Testing”); } [Fact] public void Test2() { driver.Navigate().GoToUrl(“http://google.com”); driver.FindElementById(“gbqfq”).SendKeys(“Testing again”); } }

Selenium 2.0 WebDriver Advcanced Interactions DoubleClick帮助(c#)

所以在我的selenium回归测试中,我一直试图双击日历来制作新的appt。 我试图使用doubleClick(); advanceduserinteractions库中的方法,但存在问题; 两次点击不够快/足够接近以实现双击! 有人在他们的测试中找到了解决这个问题的方法吗?