Element <span class="selectable-text copyable-text"> is not reachable by keyboard. C#

Viewed 42

So I m trying, to send a message the whatsapp text field but whenever i try to input it. It only inputs the first letter of the sentence. Since only one character is getting to the text field i am traying to change this one character that is already in the text field to the actual setence that i want to send but when i try to do this i get this error "Element is not reachable by keyboard".

I am using OpenQA.Selenium;

IWebElement num = driver.FindElement(By.CssSelector(search));
num.SendKeys(Target);
System.Threading.Thread.Sleep(250);

driver.FindElement(By.XPath("//span[@title = '" + Target + "']")).Click();
System.Threading.Thread.Sleep(250);

IWebElement num2 = driver.FindElement(By.XPath("//div[@class='fd365im1 to2l77zo bbv8nyr4 mwp4sxku gfz4du6o ag5g9lrv']"));
num2.SendKeys("x");
System.Threading.Thread.Sleep(250);

IWebElement num3 = driver.FindElement(By.XPath("//p/span[contains(text(),'x')]"));
num3.SendKeys(message);

This is the html code:
This is the html code

This is the code error:
This is the code error

1 Answers

Span is not an input field so you have to change its text i.e. by javascript. Something like this should work:

WebElement i = driver.findElement(By.id("id"));
JavascriptExecutor j = (JavascriptExecutor)driver;
j.executeScript("arguments[0].innerText='YOUR_TEXT';", i);
Related