public static void AuthorGetText(IWebDriver _driver)
{
try
{
_driver.Navigate().GoToUrl("какая то страница");
_driver.FindElement(By.Id("loginform-login")).SendKeys(Authorization.LoginAuthor);
_driver.FindElement(By.Id("loginform-password")).SendKeys(Authorization.PwdAuthor);
_driver.FindElement(By.XPath("//*[@class='btn btn-success']")).Click();
_driver.Manage().Timeouts().ImplicitlyWait(new TimeSpan(0, 0, 3));
var TableElements = _driver.FindElement(By.XPath(".//table[@class='table table-bordered'][2]")).FindElements(By.TagName("tr"));
bool End = false;
foreach (var TableElement in TableElements)
{
var TableElementsTd = TableElement.FindElements(By.TagName("td"));
foreach (var TableElementTd in TableElementsTd)
{
if (TableElementTd.Text.Equals("Тестовый больничный лист 001"))
{
var ClickLink = TableElement.FindElement(By.TagName("a"));
ClickLink.Click();
End = true;
break;
}
}
if (End) { break; }
}
_driver.FindElement(By.CssSelector("input[name='AuthorTextForm[title]']")).SendKeys("Тест");
_driver.FindElement(By.CssSelector("input[name='AuthorTextForm[subtitle]']")).SendKeys("Тест");
string TextCheck = "тут какой- то текст";
Thread.Sleep(4000);
var frame = _driver.SwitchTo().Frame(0);
var text = frame.FindElement(By.TagName("body"));
text.SendKeys(TextCheck);
Thread.Sleep(2500);
_driver.SwitchTo().DefaultContent();
var test = _driver.FindElement(By.CssSelector("input[[name='AuthorTextForm[tocheck]']"));
Console.WriteLine(test);
test.Click();
Thread.Sleep(2500);
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("Author (отправка текста на проверку) Passed");
Console.ResetColor();
}
catch (Exception e)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Author (отправка текста на проверку) Failed");
Console.ResetColor();
Console.WriteLine(e.Message);
}
}
WebDriver defaultContent()
Selects either the first frame on the page, or the main document when a page contains iframes.
Returns: This driver focused on the top window/first frame.
пробуйте
WebDriver parentFrame()
Change focus to the parent context. If the current context is the top level browsing context, the context remains unchanged.
Returns: This driver focused on the parent frame
спасибо за ответы
var test = _driver.FindElement(By.CssSelector("input[[name='AuthorTextForm[tocheck]']"));
ошибка была в этой строке, ну и соответственно помогло WebDriver parentFrame()