我正在使用c#硒铬webdriver。我在Whatsapp网站中名为div的_1Plpp类中使用SendKeys发送文本。但是,当RichTextBox中的新行结束时,WhatsApp会将其视为新文本。我想将其发送为一个文本。
String myText = richTextBox1.Text.Replace("\n", OpenQA.Selenium.Keys.Shift + OpenQA.Selenium.Keys.Enter);
driveri.FindElement(By.ClassName("_1Plpp")).SendKeys(richTextBox1.Text.Replace("\r\n", OpenQA.Selenium.Keys.Shift + OpenQA.Selenium.Keys.Enter));
driveri.FindElement(By.ClassName("_35EW6")).Click();
答案 0 :(得分:0)
尝试一下:
//Create an Actions object that will handle the keys.
Actions action = new Actions(driver);
//Tell the action object to send shift-enter and release them.
a.MoveToElement(driver.FindElement(By.ClassName("_1Plpp")))
.KeyDown(Keys.Shift)
.KeyDown(Keys.Enter)
.KeyUp(Keys.Enter)
.KeyUp(Keys.Shift);
//Do the action
a.Perform();
driver.FindElement(By.ClassName("_35EW6")).Click();