簡體   English   中英

C#Selenium Chrome WebDriver shift +輸入richtexbox

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM