基于UITestControl codedUI对象的创建对象、UITestControl、codedUI

2023-09-04 03:33:07 作者:谎言成双

我的问题是延续以下$c$cdUI不承认HTMLControl时,当UITestControl的范围,而不是BrowserWindow 问题的范围搜索。

My question is a continuation on the following CodedUI not recognizing HtmlControl when searched within scope of UITestControl instead of BrowserWindow question.

我遇到了同样的问题,我想知道为什么会这样。这里是我的发现。

I'm experiencing the same problem and I would like to know why this is happening. Here are my findings.

BrowserWindow从ApplicationUnderTest,继承了其对自己继承的ApplicationBase,这再次从UITestControl继承。

BrowserWindow inherits from ApplicationUnderTest, which on his own inherits on ApplicationBase, which again inherits from UITestControl.

所有的控件HtmlRow确实包含一个构造要求作为参数UITestControl。从经验我可以证实,没有母校,如果你传递的例子HtmlDiv或BrowserWindow的情况下,控制将构建正确的行为。

All the controls as HtmlRow do contain a constructor requesting as a parameter UITestControl. From the experience I can confirm that, no mater if you pass in an instance of at example HtmlDiv or BrowserWindow, the control will construct and behave correctly.

这是一个奇怪的行为,我无法解释,需要多一点分析。

This is a strange behavior I can't explain and needs a bit more analyzing.

我不看,我可以用下面的情况下复制相同的:

I do see that I can replicate the same with the following case:

private readonly UITestControl _container;

protected Page(Process process)
{
    _container = BrowserWindow.FromProcess(process);
}

protected Page(UITestControl testControl)
{
    _container = testControl;
}

public UITestControl Container
{
    get { return _container; }
}

private HtmlEdit _startDateTextBox;

protected HtmlEdit StartDateTextBox
{
    get
    {
        if (_startDateTextBox == null)
        {
            _startDateTextBox = new HtmlEdit(Container);
            _startDateTextBox.SearchProperties.Add(HtmlControl.PropertyNames.Id, StartDateTextBoxId,
                PropertyExpressionOperator.Contains);
        }

        return _startDateTextBox;
    }
}

这个例子是失败,同时我希望它应该如下面的例子可以正常工作:

This example is failing, meanwhile I expect it should work as the following example works correctly:

private readonly BrowserWindow _container;

protected Page(Process process)
{
    _container = BrowserWindow.FromProcess(process);
}

public UITestControl Container
{
    get { return _container; }
}

private HtmlEdit _startDateTextBox;

protected HtmlEdit StartDateTextBox
{
    get
    {
        if (_startDateTextBox == null)
        {
            _startDateTextBox = new HtmlEdit(Container);
            _startDateTextBox.SearchProperties.Add(HtmlControl.PropertyNames.Id, StartDateTextBoxId,
                PropertyExpressionOperator.Contains);
        }

        return _startDateTextBox;
    }
}

如果任何人有这个问题的线索,我会真的很想知道为什么。

If anyone has a clue about this problem, I'll be really curious to understand why.

感谢

推荐答案

你能送我一个摄制拉链,我问在上述提到的问题吗?我喜欢潜水到这一点,因为我没能瑞普根据提供的code。

are you able to send me a repro zip as I asked in the afore mentioned question? I would love to dive in to this since I was not able to repro based on the code provided.