Answer the question
In order to leave comments, you need to log in
How to assign a value to a TextBox in cefsharp?
Hello. I'm trying to execute scripts and take the value in the text field
private void button1_Click(object sender, EventArgs e)
{
textBox1.Text = chromeBrowser.ExecuteScriptAsync("document.querySelector('#content > div > div:nth-child(1) > div > div > div:nth-child(2) > div > div.box-gray.aligncenter').outerText;");
}
string textData = "document.querySelector('#content > div > div:nth-child(1) > div > div > div:nth-child(2) > div > div.box-gray.aligncenter').outerText;";
textBox1.Text = chromeBrowser.ExecuteScriptAsync(textData);
Answer the question
In order to leave comments, you need to log in
Try using XPath https://metanit.com/sharp/tutorial/16.4.php
to extract the node and its value.
This method is convenient in that you can check the paths to the node - through the debug console of the browser.
C js I would contact last.
That doesn't work either :(
string script = string.Format("document.querySelector('#content > div > div:nth-child(1) > div > div > div:nth-child(2) > div > div.box-gray.aligncenter').outerText;");
chromeBrowser.EvaluateScriptAsync(script).ContinueWith(x =>
{
var response = x.Result;
if (response.Success && response.Result != null)
{
var startDate = response.Result;
textBox1.Text = Convert.ToString(startDate);
}
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question