简体   繁体   中英

c# selenium chrome webdriver shift + enter richtexbox

I am using c # selenium chrome webdriver. I send text with SendKeys in _1Plpp class named div in Whatsapp web. But when the new line in RichTextBox is over, WhatsApp perceives it as a new text. I want to send it in one text.

            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(); 

Try this:

//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();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM