Answer the question
In order to leave comments, you need to log in
How to properly write CssSelector using c# and OpenQA.Selenium.Chrome?
Getting familiar with UI automation. To begin with, I decided to write a simple C# code using OpenQA.Selenium.Chrome, which would drive a link to a chat into the Telegram search, select it and send a message. I was able to define a text field for searching and enter text into it, but I had problems with the remaining two steps.
Code in C#:
driver.Navigate().GoToUrl("https://web.telegram.org/#/login");
IWebElement query = driver.FindElement(By.CssSelector("input[type='search']"));
query.SendKeys("https://t.me/bAHdiTu");
IWebElement query1 = driver.FindElement(By.CssSelector("ul.nav.nav-pills.nav-stacked li:first-child"));
query1.Click();
IWebElement query2 = driver.FindElement(By.CssSelector("div[class='composer_rich_textarea']"));
query2.SendKeys("тест");
Answer the question
In order to leave comments, you need to log in
"input[type='search']"
"input[type=\"search\"]"
"ul.nav.nav-pills.nav-stacked li:first-child"
"ul.nav-pills.nav-stacked>li:first-child"
"div[class='composer_rich_textarea']"
"div.composer_rich_textarea"
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question