c# - 使用 Selenium 在 textArea 中输入完整的 html
问题描述
我有一个文本区域,我需要在那里输入一个完整的 HTML。
在 BDD 中,我将传递文件的路径,但我不知道如何捕获完整的 HTML(带标签)以通过 SendKeys 应用于 Textarea。
我正在使用 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。
解决方案
只需阅读内容,然后在您的步骤 def 中将其传递到文本区域。
string fullHtml = File.ReadAllText(file);
char tab = '\u0009';
fullHtml = fullHtml.Replace(tab.ToString(), "");
driver.FindElement(By.Id("TxtConteudo")).SendKeys(fullHtml);
推荐阅读
- java - groovy.lang.MissingMethodException:Jmeter 上的错误
- php - 从 PHP 打开 SQLITE 数据库并将结果报告到 HTML 页面时出现问题
- react-native - React native 我在 app.js 中放了一个启动画面,但出现错误
- r - R函数用于删除列中的前4个字符?
- android - 在 Android Studio 中重新加载 Activity
- python - 在 Python 标签中使用 BeautifulSoup 进行网页抓取
- reactjs - TypeError:无法读取未定义的属性“联系人”
- arrays - 在这个 Ruby 案例中,“self”关键字引用了什么?
- file-extension - 打开 .grp .mps 和 .rsc .rsr
- html - Html 文件没有与我的 css 文件一起下沉?