草庐IT

scrapy_selenium

全部标签

c# - 有没有人找到并行运行 C# Selenium RC 测试的方法?

有没有人找到用C#并行编写的运行SeleniumRC/SeleniumGrid测试的方法?我目前有一个使用SeleniumRC的C#驱动程序编写的相当大的测试套件。运行整个测试套件需要一个多小时才能完成。我通常不需要运行整个套件,所以到目前为止这还不是一个问题,但我希望能够更经常地做这件事(即,作为自动构建的一部分)最近,我一直在研究SeleniumGrid项目,该项目的主要目的是让这些测试并行运行。不幸的是,我使用的TestDriven.net插件似乎连续运行测试(即,一个接一个)。我假设NUnit会以类似的方式执行测试,尽管我还没有实际测试过。我注意到NUnit2.5测试版开始谈论

c# - HtmlAgilityPack 和 Selenium Webdriver 返回随机结果

我正在尝试从网站上抓取产品名称。奇怪的是,我似乎只随机抓取了12个项目。我已经尝试了HtmlAgilityPack和HTTPClient,我得到了相同的随机结果。这是我的HtmlAgilityPack代码:usingHtmlAgilityPack;usingSystem.Net.Http;varurl=@"http://www.roots.com/ca/en/men/tops/shirts-and-polos/";HtmlWebweb=newHtmlWeb();vardoc=web.Load(url,"GET",proxy,newNetworkCredential(PROXY_UID,

c# - 等待 Selenium Webdriver 更改的最佳实践?

点击事件后,我需要等待元素属性发生变化,然后再继续(点击事件导致某些元素移出焦点,而某些其他元素通过JS获得焦点)在花时间在网络驱动程序中搜索“waitForAttribute”(selenium1命令)的可靠替代方案之后......我可以让下面的代码工作。但我不确定这是否是最好的实现...还有其他更好的解决方案吗?wait=newWebDriverWait(wedriver1,TimeSpan.FromSeconds(5));.....button.Click();wait.Until(webdriver1=>webdriver2.webelement.GetAttribute("s

c# - 如何使用带有 C# 的 Selenium 获取文本输入的值?

使用Seleniumfor.NET,如何从html输入中获取当前值?可以通过.GetAttribute()获取value属性,但这是html属性,而不是输入到文本框中的当前值;一种类似于jQuery的.val()而不是jQuery的.attr()的方法。 最佳答案 Element.Text对我不起作用。我使用了element.GetAttribute("value")查看此问答SettinginputtextboxtextandthenretrievingitinSpecflow&Selenium

c# - Selenium ChromeDriver 切换选项卡

当我单击测试中的链接时,它会打开一个新选项卡。我希望ChromeDriver然后专注于该选项卡。我已尝试使用以下代码让ChromeDriver使用ctrl+tab快捷方式更改选项卡:Actionsbuilder=newActions(driver);builder.KeyDown(Keys.Control).KeyDown(Keys.Tab).KeyUp(Keys.Tab).KeyUp(Keys.Control);//switchtabsIActionswitchTabs=builder.Build();switchTabs.Perform();但这会引发以下异常:ekmLiveCha

c# - 在 C# 中使用 Selenium 通过部分 id 查找元素

我正在尝试定位具有动态生成的ID的元素。字符串的最后一部分是常量(“ReportViewer_fixedTable”),因此我可以使用它来定位元素。我尝试在XPath中使用正则表达式:targetElement=driver.FindElement(By.XPath("//table[regx:match(@id,"ReportViewer_fixedTable")]"));并通过CssSelector定位:targetElement=driver.FindElement(By.CssSelector("table[id$='ReportViewer_fixedTable']"));两

c# - Selenium 错误 : No response from server for url http://localhost:7055

我正在使用Selenium、C#、NUnit编写测试,有时我会遇到以下错误:-OpenQA.Selenium.WebDriverException:Noresponsefromserverforurlhttр://lоcalhost:7055/hub/session/8dd13f5c-7ca6-4aa6-babc-f0ff6d940f0a/element这是堆栈跟踪:OpenQA.Selenium.WebDriverException:Noresponsefromserverforurlhttр://localhost:7055/hub/session/8dd13f5c-7ca6-4a

c# - Selenium 找不到 chromedriver.exe

我们正在升级到.NETCore,并且我们有一个使用Selenium执行某些任务的爬网引擎。我们使用chromedriver.exe,它在.NET4.6.1中工作得很好。对于.NETCore,我们创建了一个控制台应用程序,并添加了这些包:但是当我运行我的代码时,我得到这个错误:Thechromedriver.exefiledoesnotexistinthecurrentdirectoryorinadirectoryonthePATHenvironmentvariable.Thedrivercanbedownloadedathttp://chromedriver.storage.googl

c# - 如何为 Selenium 添加自定义 ExpectedConditions?

我正在尝试为Selenium编写自己的ExpectedConditions,但我不知道如何添加新的。有人有例子吗?我在网上找不到任何教程。在我目前的情况下,我想等到元素存在、可见、启用并且没有属性“aria-disabled”。我知道这段代码不起作用:varwait=newWebDriverWait(driver,TimeSpan.FromSeconds(seconds));returnwait.Until((d)=>{returnExpectedConditions.ElementExists(locator)&&ExpectedConditions.ElementIsVisible

c# - 如何使用 Selenium Webdriver .NET 绑定(bind)设置 Chrome 首选项?

这是我用的,useragent可以设置成功,而下载首选项不能。Windows7、Chrome26、Selenium-dotnet-2.31.2、chromedriver_win_26.0.1383.0ChromeOptionschromeOptions=newChromeOptions();varprefs=newDictionary{{"download.default_directory",@"C:\code"},{"download.prompt_for_download",false}};chromeOptions.AddAdditionalCapability("chrome