Я пытаюсь очистить текст 睡觉
на странице edited out the site
У него есть селектор css:
#autocplt_wrap > ul:nth-child(1) > li:nth-child(1) > span:nth-child(1) > a:nth-child(1)
И x-Path:
/html/body/div[2]/div[1]/div[3]/div[2]/div[1]/div/div[1]/div[2]/div/div/ul[1]/li/span/a[1]
Мой код:
IWebDriver driver = new FirefoxDriver();
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
//load webdriver
driver.Manage();
driver.Navigate().GoToUrl("https://dict.naver.com/linedict/zhendict/#/cnen/home");
driver.FindElement(By.ClassName("ac_input")).SendKeys("睡觉" + Keys.Enter);
driver.FindElement(By.CssSelector("#autocplt_wrap > ul:nth-child(1) > li:nth-child(1) > span:nth-child(1) > a:nth-child(1)"));
Независимо от того, что я пытаюсь, я всегда получаю ошибку:
Unhandled exception. OpenQA.Selenium.NoSuchElementException: Unable to locate element: #autocplt_wrap > ul:nth-child(1) >
li:nth-child(1) > span:nth-child(1) > a:nth-child(1)
at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
at OpenQA.Selenium.Remote.RemoteWebDriver.FindElement(String mechanism, String value)
at OpenQA.Selenium.By.<>c__DisplayClass29_0.<CssSelector>b__0(ISearchContext context)
at OpenQA.Selenium.By.FindElement(ISearchContext context)
at OpenQA.Selenium.Remote.RemoteWebDriver.FindElement(By by)
ExpectedConditions
сейчас обесценивается. Вам нужно написать свою функцию или установитьDotNetSeleniumExtras.WaitHelpers
с помощью nuget 31.05.2020SeleniumExtras.WaitHelpers.ExpectedConditions
на случай, если кто-то прочтет это в будущем 31.05.2020DotNetSeleniumExtras.WaitHelpers
31.05.2020