Write text with emoji using Chromedriver

423 views
Skip to first unread message

Gardel Costa

unread,
Aug 14, 2022, 5:42:20 PM8/14/22
to Selenium Users
I'm trying to write in a field with text containing emoji on the website web.whatsapp.com .<br>
My project uses C#, Chromedriver , .Net 5 and Selenium.<br>
Selenium doesn't write emojis in Chromedriver natively, so I need to write using javascript.<br>
I can write with javascript in the field, but when I click again in the field and submit the text, the content I write disappears.<br>
I could write a few days ago, but now I can't.<br>
How to solve this?<br>
Here's the code:<br><br>

     try
    {
        IJavaScriptExecutor js = (IJavaScriptExecutor)driver;
        js.ExecuteScript("document.getElementsByClassName('_13NKt copyable-text selectable-text')[0].innerText=arguments[0]", "Hello😁");
        driver.FindElement(By.XPath("//*[@id='app']/div/div/div[2]/div[2]/span/div/span/div/div/div[2]/div/div[1]/div[3]/div/div/div[2]/div[1]/div[2]")).SendKeys(" ");
        driver.FindElement(By.XPath("//*[@id='app']/div[1]/div[1]/div[2]/div[2]/span/div[1]/span/div[1]/div/div[2]/div/div[1]/div[3]/div/div/div[2]/div[1]/div[2]")).SendKeys(OpenQA.Selenium.Keys.Backspace);
        driver.FindElement(By.XPath("//span[@data-testid ='send']")).Click();
    }
    catch (Exception ex)
    {
        Console.WriteLine(ex.Message);
    }

SuperKevy

unread,
Aug 15, 2022, 2:07:50 PM8/15/22
to Selenium Users
Assuming it's an academic test... 
Follow along with this code set hints and convert as needed.  
Reply all
Reply to author
Forward
0 new messages