使用 Selenium 在 textArea 中输入完整的 html
Input full html in textArea using Selenium
我有一个文本区域,我需要在那里输入完整的 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。
只需阅读内容,然后将其传递到文本区域,在您的步骤定义中。
string fullHtml = File.ReadAllText(file);
char tab = '\u0009';
fullHtml = fullHtml.Replace(tab.ToString(), "");
driver.FindElement(By.Id("TxtConteudo")).SendKeys(fullHtml);
我有一个文本区域,我需要在那里输入完整的 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。
只需阅读内容,然后将其传递到文本区域,在您的步骤定义中。
string fullHtml = File.ReadAllText(file);
char tab = '\u0009';
fullHtml = fullHtml.Replace(tab.ToString(), "");
driver.FindElement(By.Id("TxtConteudo")).SendKeys(fullHtml);