硒运行非常缓慢(C#) [英] Selenium running very slowly (C#)
问题描述
我要拔掉硒,因为硒运行缓慢.
I'm pulling my hair out about Selenium running slowly.
如果我重新启动PC并第一次运行测试,它将以正确的速度运行.
If I restart my PC and run my test for the first time it'll perform at the correct speed.
如果我立即重新运行测试,那将永远!有人见过这种行为吗?
If I immediately rerun my test it takes forever! Has anyone seen this behaviour before?
这也不是特别复杂的代码,只需输入数据并单击几个链接即可.它只是在最近才开始这样做.在大约一周前,它将以正确的速度(即相当快)运行.
It's not particularly complex code either, just entering data and clicking a couple of links. It only started doing this recently. Prior to about a week ago it would just run at the correct speed (ie.pretty rapid).
硒的版本
Selenium.Webdriver - v3.6
Selenium.Support - v3.6
Selenium.WEbdriver.IEDriver - 3.6
var driver = new InternetExplorerDriver();
driver.Navigate().GoToUrl(URL);
System.Threading.Thread.Sleep(500);
driver.FindElementByXPath(AddRecord).Click();
//Input date on Case details page
driver.FindElementById(C4NameID).SendKeys(C4NameArray[i]);
driver.FindElementByXPath(EliteMatterX).SendKeys(EliteMatterRefArray[i]);
driver.FindElementByXPath(StatusX).SendKeys(StatusArray[i]);
driver.FindElementByXPath(PolicyCategoryX).SendKeys(PoliceCategoryArray[i]);
driver.FindElementByXPath(ScheduledDateX).SendKeys(ScheduledNextReviewDateArray[i]);
driver.FindElementByXPath(ServiceLineX).SendKeys(ServiceLineArray[i]);
driver.FindElementByXPath(BridgingPaymentX).SendKeys(BridgingPaymentArray[i]);
driver.FindElementByXPath(SubClusterX).SendKeys(SubClusterArray[i]);
driver.FindElementByXPath(DidWilliamsLeaHaveARoleX).SendKeys(DidWilliamLeaHaveARoleArray[i]);
driver.FindElementByXPath(C4TypeX).SendKeys(C4TypeArray[i]);
driver.FindElementByXPath(LegalOmbudsmanX).SendKeys(LegalOmbudsmanCategoryArray[i]);
driver.FindElementById(FeeEarnerID).SendKeys(FeeEarnerNameArray[i]);
driver.FindElementById(FeeEarnerPhoneNoID).SendKeys(FeeEarnerPhoneNumberArray[i]);
driver.FindElementById(ContactPartnerID).SendKeys(ContactPartnerArray[i]);
driver.FindElementById(C4OwnerID).SendKeys(C4OwnerArray[i]);
//Wait
System.Threading.Thread.Sleep(500);
//Click INformation for Insurer tab
driver.FindElementByXPath(InformationForInsurerTab).Click();
//Wait
System.Threading.Thread.Sleep(500);
//Inputs for Info for insurers page
driver.FindElementById(C4OccurrenceDateID).SendKeys(C4OccurenceDateArray[i]);
driver.FindElementById(IndemnityPeriodID).SendKeys(IndemnityPeriodArray[i]);
driver.FindElementById(InsuranceReferenceID).SendKeys(InsurerRefArray[i]);
driver.FindElementById(FEResponsibleWhenErrorOccuredID).SendKeys(FEResponsibleWhenErrorOccuredArray[i]);
driver.FindElementById(C4HolderID).SendKeys(C4HolderArray[i]);
//Wait
System.Threading.Thread.Sleep(500);
//Click INformation for Insurer tab
driver.FindElementByXPath(CaseDetailsTab).Click();
//Wait
System.Threading.Thread.Sleep(500);
/*//Inputs for Info for case details tab
driver.FindElementByXPath(BackgroundX).SendKeys(BackgroundArray[i]);
driver.FindElementByXPath(ResolutionPlanX).SendKeys(ResolutionPlanArray[i]);
driver.FindElementByXPath(LatestPositionX).SendKeys(LatestPositionArray[i]);
driver.FindElementByXPath(ConditionalLearningPointsX).SendKeys(ConditionalLearningArray[i]);
*/
//Wait
System.Threading.Thread.Sleep(500);
//Click Financials tab
driver.FindElementByXPath("//*[@id='c4wrapper']/form/div/ul/li[4]/a").Click();
System.Threading.Thread.Sleep(100);
//Iouts for Financials tab
driver.FindElementById(MaxPossLossID).SendKeys(MaxPossLossArray[i]);
driver.FindElementById(ProbMaxLossID).SendKeys(ProbMaxLossArray[i]);
System.Threading.Thread.Sleep(1000);
//Click Save
var SaveButton = driver.FindElementById(SaveX);
SaveButton.Click();
推荐答案
If you are running .NET Core, you are hitting a known bug.
在IISExpress和测试uri中同时切换到127.0.0.1
可以缓解此问题.
Switching to 127.0.0.1
both in IISExpress and in the test uri mitigates the issues.
这篇关于硒运行非常缓慢(C#)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!