'How to send encoded text using Selenium ChromeDriver SendKeys
I am trying to automate sending messages via WhatsApp using Selenium. Here is the C# code, I have used and it throwing "Error: ChromeDriver only supports characters in the BMP"
The message has Emoji's and hyperlink and special characters.
🔥🔥Insulated Lunch Bag❤️50% Off with Promo CODE ABCDEFGHIJ🔗 https://amazon.com/dp/B08ZMVC8QQ?tag=xcv2090-00
What is the I have tried so far:
string mesg = "🔥🔥Insulated Lunch Bag❤️50% Off with Promo CODE ABCDEFGHIJ🔗
https://amazon.com/dp/B08ZMVC8QQ?tag=xcv2090-00";
ChromeOptions options = new ChromeOptions();
options.AddArgument(@"--user-data-dir=C:\\Users\\ABCD\\AppData\\Local\\Google\\Chrome\\User Data\\Default");
options.AddArgument(@"--profile-directory=Default");
IWebDriver chromeDriver = new ChromeDriver(Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory), options);
chromeDriver.Navigate().GoToUrl("https://web.whatsapp.com/");
chromeDriver.FindElement(By.XPath("//span[@title='UserName']")).Click();
Thread.Sleep(500);
var msgBox = chromeDriver.FindElement(By.XPath("//div[@class='p3_M1']"));
Thread.Sleep(500);
msgBox.SendKeys(mesg);
What is the expectation:
Formatted text in WhatsApp, here is the example:
🔥 78% off Samsung Galaxy S22 Ultra Case🔹 Clip Coupon: 8%🔹 Coupon Code: 709M6CET 📍 Final Price: $3.08Works only on the listed optionJust click the above code to copy it
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
