이 날 미치게하고 나는 By.Id or By.Xpath
를 사용하여 시도 없지만 아무도 내 Select Method
이 System.NotImplementedException는 : 요소가 더 이상 유효하지 -Selenium Webdriver
// 테스트 코드
드롭 다운리스트 에서 텍스트를 선택하려고 여기에 작업을하지 않기SelectMyText(By.XPath("//*[@id='ctl00_ContentPlaceHolder1_ddlCategory']"), "Employee");
// 방법 : 여기
public void SelectMyText(By locator, string valueToBeSelected)
{
var options = GetElementId(locator).FindElements(By.TagName("option"));
foreach (var option in options)
{
if (valueToBeSelected == option.Text)
{
option.Click();
return;
}
}
}
public IWebElement GetElementId(By locator)
{
return Driver.FindElement(locator);
}
오류가 점점 :
threw exception:
System.NotImplementedException: Element is no longer valid
at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
at OpenQA.Selenium.Remote.RemoteWebDriver.InternalExecute(String driverCommandToExecute, Dictionary`2 parameters)
at OpenQA.Selenium.Remote.RemoteWebElement.Execute(String commandToExecute, Dictionary`2 parameters)
at OpenQA.Selenium.Remote.RemoteWebElement.get_Text()
다음은이 오류의 스크린 샷입니다 :
브라우저가 DOM을 재구성했기 때문일 수 있습니다. try catch에 해당 코드를 래핑하고 실패 할 경우 코드를 다시 호출하십시오. 두 번째로 작동한다면 아마 그럴 것이고, 마침내 포기하기 전에 합리적인 횟수를 다시 시도하는 테스트에 '안정화 코드'를 만들어야 할 것입니다. 가장 좋은 방법은 – lefthandedgoat