Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/unit-testing/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/286.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Unit testing 为什么编码的UI模块看不到Internet Explorer浏览器中显示的UI控件元素?_Unit Testing_Internet Explorer_Coded Ui Tests_Automated Tests_Ui Testing - Fatal编程技术网

Unit testing 为什么编码的UI模块看不到Internet Explorer浏览器中显示的UI控件元素?

Unit testing 为什么编码的UI模块看不到Internet Explorer浏览器中显示的UI控件元素?,unit-testing,internet-explorer,coded-ui-tests,automated-tests,ui-testing,Unit Testing,Internet Explorer,Coded Ui Tests,Automated Tests,Ui Testing,我们的自动化UI测试代码需要搜索并找到包含“p”html元素的链接,其中包含名为Customers的文本。最后,我们需要对代码进行自动化测试,以点击前面提到的链接 <div data-bind="foreachRibbonItem: items"> blah blah blah blah blah <a class="btn txt-color-white" href="#" data-bind="click: content, tooltip: {title :

我们的自动化UI测试代码需要搜索并找到包含“p”html元素的链接,其中包含名为Customers的文本。最后,我们需要对代码进行自动化测试,以点击前面提到的链接

<div data-bind="foreachRibbonItem: items">
 blah blah
 blah blah blah
<a class="btn txt-color-white" href="#" data-bind="click: content,      tooltip: {title : description, placement: 'bottom' }, keyTipsGroup : {         parentGroup: ribbonTabKeyTip, group: text }" data-original-title="" title="">
 <span class="txt-color-blueDark">
 <p data-bind="html: text">Customers</p>
  </a>
 blah blah
 blah blah blah
 </div>
上述代码的问题在于,当代码运行时,它无法拾取任何UI控件元素。 有人能帮我确定出什么问题吗? 我的直觉是,我实例化HtmlControl的方式以及所述HtmlControl与“测试中的网站”的关联方式可能有问题


有人能指出上面代码的错误吗?

获取链接的简单方法:

public HtmlHyperlink link()
{
    HtmlControl paragraph = new HtmlControl(brwsWin);
    paragraph.SearchProperties["InnerText"] = "Customers";
    HtmlHyperlink target = (HtmlHyperlink)paragraph.GetParent();
    return target;
}
这样你现在就可以用鼠标点击(link())

我总是喜欢使用BrowserWindow对象本身作为父对象,但根据定义,使用
doc
对象不会给您带来任何问题

为了提高速度,它有助于向HTML元素(如ID或名称)添加识别标记,这些标记对于所讨论的元素是唯一的。我发现编码的UI引擎可以比使用InnerText属性更快地进行搜索。另一个提示是在更高级别上过滤父对象,这样工具就可以首先找到更高级别的元素,而不必在整个页面中搜索“客户”。例如,树中的链接:

<body>
    <div id='div1'>
        <div id='div2'>
            <div id='div3'>
                <a id='customerLink'>Customers</a>
            </div>
        </div>
    </div>
<body>
对每个父对象执行此操作,在实例化它时将其正上方的div指定为父对象(就像我们对上面的brwsWin所做的那样),然后在链接上:

public HtmlHyperlink link()
{
    HtmlHyperlink target = new HtmlHyperlink(div3);
    target.SearchProperties["id"] = "customerLink";
    return target;
}

@Adrianhh嘿,我试图缩小我在UI测试中面临的技术问题的具体细节。你能看一下这篇文章吗?提前感谢。@Adrianhh我现在面临一个问题,就是运行测试的速度有多慢。我的项目使用的是真正的bootstraphunter.com/smartadmin-product.php UI界面,它有很多UI控件。问题是Microsoft编码的UI需要很长时间来搜索UI元素。你能建议我如何改进吗测试速度?Ryan,谢谢你的帮助。我现在面临的问题是运行测试的速度有多慢。我的项目使用的是真正的UI界面,它有很多UI控件。问题是Microsoft编码的UI需要很长时间来搜索UI元素。你能建议我如何提高测试速度吗?希望这能有所帮助。根据我的经验,编码用户界面往往比你想象的要慢。老实说,我使用SeleniumWebDriver工具获得了更好的结果(速度方面)。
<body>
    <div id='div1'>
        <div id='div2'>
            <div id='div3'>
                <a id='customerLink'>Customers</a>
            </div>
        </div>
    </div>
<body>
public HtmlDiv div1()
{
    HtmlDiv div = new HtmlDiv(brwsWin);
    div.SearchProperties["ID"] = "div1";
    return div;
}

public HtmlDiv div2()
{
    HtmlDiv div = new HtmlDiv(div1);
    div.SearchProperties["id"] = "div2";
    return div;
}
public HtmlHyperlink link()
{
    HtmlHyperlink target = new HtmlHyperlink(div3);
    target.SearchProperties["id"] = "customerLink";
    return target;
}