[英]c# selenium chrome webdriver shift + enter richtexbox
我正在使用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();
尝试这个:
//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();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.