使用 Selenium 在 textArea 中输入完整的 html

我有一个文本区域,我需要在那里输入完整的 HTML。


在 BDD,我将传递文件的路径,但我不知道如何捕获完整的 HTML(带有标签)以通过 SendKeys 应用于文本区域。


我使用 Specflow + Selenium + C#


Scenario Outline: Input Disclaimer Filme

  Given I choose the type of disclaymer <type>

  When I open the html file <file>

  Then I send then 


  Examples:

    | type               | file                                  | 

    |    "Cota Capital"  |   "C:\Disclaimers\CotaCapital.html"   |    

    |    "Caucionamento" |   "C:\Disclaimers\Caucionamento.html" |   


方法内部:


driver.FindElement(By.Id("TxtConteudo")).SendKeys(fullHtml);


我想打开文件,读取所有 html,将其保存在某个 var / string 中,然后将其传递给 textArea。


慕码人8056858
浏览 105回答 1
1回答

墨色风雨

只需阅读内容,然后将其传递到文本区域,在您的步骤定义中。string fullHtml = File.ReadAllText(file);char tab = '\u0009';fullHtml = fullHtml.Replace(tab.ToString(), "");driver.FindElement(By.Id("TxtConteudo")).SendKeys(fullHtml);
打开App,查看更多内容
随时随地看视频慕课网APP