将鼠标悬停在编码用户界面的链接上后无法找到带链接的菜单

时间:2015-02-23 06:20:53

标签: coded-ui-tests

目前我在使用鼠标悬停在链接上时显示的工具提示菜单中返回内部文本甚至链接时遇到问题。使用开发工具我看到这个链接和出现在Div标签为alphabetTooltip的悬停菜单。任何人都可以告诉我,如果我正朝着正确的方向前进。

  public void get_All_Carousel_Cards_ofAlphabet() {
        //Mouse.Click(CarouselLinks);
        Mouse.Hover(CarouselLinks);
        HtmlDiv tooltipdiv = new HtmlDiv();
        tooltipdiv.SearchProperties[HtmlDiv.PropertyNames.Class] = "alphabetTooltip";
        HtmlControl controls = new HtmlControl();
        controls.SearchProperties.Add(HtmlControl.PropertyNames.ClassName, "HtmlHyperlink");
        UITestControlCollection collection = controls.FindMatchingControls();

        foreach (UITestControl links in collection)
        {
         //cast the item to html hyperlink typ
            HtmlHyperlink mylinks = (HtmlHyperlink)links;
            //get the innertext from the link, which inturn returns the link value itself
            carousel_innerText = mylinks.InnerText;

        }


    }

1 个答案:

答案 0 :(得分:0)

尝试添加工具提示作为超链接搜索的父级,如下所示:

HtmlDiv tooltipdiv = new HtmlDiv();
tooltipdiv.SearchProperties[HtmlDiv.PropertyNames.Class] = "alphabetTooltip";
HtmlControl controls = new HtmlControl(tooltipdiv);