单元测试MS AJAX Toolkit HTML编辑器
是否可以对MS AJAX控制工具箱的 HTML编辑器进行单元测试?我尝试 Watin ,WebAii和Selenium都没有成功...
Is it possible to unit test the MS AJAX Control Toolkit's HTML Editor? I've tried Watin, WebAii and Selenium without any success...
我可以找到与控件相关的文本框,但尝试访问它时出现异常:
I can find the textbox related to the control but I get an exception trying to access it:
using (Browser ie = new IE()) {
ie.GoTo(testUri);
Assert.IsTrue(ie.ContainsText("Expected text"));
var textBox = ie.TextField(Find.ById(id => id.Contains("Editor")));
textBox.TypeText("testing 123");
}
System.Runtime.InteropServices.COMException:可以请勿将焦点移至
控件,因为它是不可见的,未启用的
或不接受
焦点的类型。
System.Runtime.InteropServices.COMException: Can't move focus to the control because it is invisible, not enabled, or of a type that does not accept the focus.
硒
我也尝试了Selenium IDE,但没有成功。当我加载 ASP.net的示例页面时,请在编辑器,然后单击提交按钮,这是它所做的测试用例:
Selenium
I tried the Selenium IDE also without any success. When I loaded ASP.net's sample page, typed some text into the editor and clicked the "Submit" button here is the test case it made:
[Test]
public void TheUntitledTest() {
selenium.Open("/AJAX/AjaxControlToolkit/Samples/HTMLEditor/HTMLEditor.aspx");
// Text was typed at this point
selenium.Click("ctl00_SampleContent_submit");
}
以下是重新运行Selenium IDE中记录的操作的日志消息:
Here is the log messages from rerunning the recorded actions in the Selenium IDE:
[info]执行中:|打开| /AJAX/AjaxControlToolkit/Samples/HTMLEditor/HTMLEditor.aspx | |
[info] Executing: |open | /AJAX/AjaxControlToolkit/Samples/HTMLEditor/HTMLEditor.aspx | |
[info]执行中:| click | ctl00_SampleContent_submit | |
[info] Executing: |click | ctl00_SampleContent_submit | |
查找控件是一个IFrame,其中编辑器实际上是可编辑的正文
Looking the control it is an IFrame where the editor is actually an editable body
<body contentEditable="true">
您应该能够使用
IE.Frame(Find.BySrc(frameSrc)).Eval( ... javascript goes here ... );
命令,然后单击按钮。
另一种方法是先移动鼠标,然后单击,然后发送密钥。
Another approach would be to do a mouse move, then click, then send keys.