none
HtmlDocument is an ambiguous reference RRS feed

  • Question

  • Hi,

      The structure of our application is Browser->Document->Object. but when i give the following code

    HtmlDocument oHtmlDocument = new HtmlDocument(oBrowser);
    oHtmlDocument.SearchProperties.Add("ControlType", "Document");
    oHtmlDocument.SearchProperties.Add("TagName", "BODY");

    I recieve 'HtmlDocument' is an ambiguous reference between 'System.Windows.Forms.HtmlDocument' and 'Microsoft.VisualStudio.TestTools.UITesting.HtmlControls.HtmlDocument'

    Do i need to add any references to avoid this issue?

    Thanks

    Manojith

    Thursday, January 24, 2013 8:19 AM

Answers

  • Hi Manojith,

    If you are doing a Coded UI Tests, then it is advisable to add reference of Microsoft.VisualStudio.TestTools.UITesting.HtmlControls to use HtmlDocument. This will specify that you are using UITesting.HtmlControls object and not Windows.Forms object

    This ambiguity occurs since Coded UI tests uses both System.Windows.Form.HtmlDocument and Microsoft.VisualStudio.TestTools.UITesting.HtmlControls in the project and HtmlDocument is defined in both. Hence VS cannot distinguish between the two without explicitly mentioning which one you are using.

    Thank you

    Bharath.


    Bharath G P MSFT

    Thursday, January 24, 2013 9:15 AM

All replies

  • Hi Manojith,

    If you are doing a Coded UI Tests, then it is advisable to add reference of Microsoft.VisualStudio.TestTools.UITesting.HtmlControls to use HtmlDocument. This will specify that you are using UITesting.HtmlControls object and not Windows.Forms object

    This ambiguity occurs since Coded UI tests uses both System.Windows.Form.HtmlDocument and Microsoft.VisualStudio.TestTools.UITesting.HtmlControls in the project and HtmlDocument is defined in both. Hence VS cannot distinguish between the two without explicitly mentioning which one you are using.

    Thank you

    Bharath.


    Bharath G P MSFT

    Thursday, January 24, 2013 9:15 AM
  • Hi Bharath,

    Thanks for your reply.

    A Quick question; Is this the right way to define the document?

    using Htmldoc = Microsoft.VisualStudio.TestTools.UITesting.HtmlControls;

    Htmldoc.HtmlDocument oHtmlDocument = new Htmldoc.HtmlDocument(oBrowser);
    oHtmlDocument.SearchProperties.Add("ControlType", "Document");
    oHtmlDocument.SearchProperties.Add("TagName", "BODY");

    Thanks,

    Manojith

    Thursday, January 24, 2013 12:39 PM
  • Hi Manojith,

    Yes you can use the above method to define the document. This is an easier and better way to define when you use lots of references to Microsoft.VisualStudio.TestTools.UITesting class. The above method will serve your purpose well

    Feel free to ask any other doubts you while testing Coded UI Tests

    Thank you

    Bharath


    Bharath G P MSFT

    Thursday, January 24, 2013 12:49 PM
  • Thankyou Bharath. Sure...
    Friday, January 25, 2013 6:35 AM
  • How do i need to do the same in VB?

    Dim Mainwindow As New BrowserWindow
            Mainwindow.SearchProperties(UITestControl.PropertyNames.Name) = "CCH Integrator"
            Mainwindow.SearchProperties(UITestControl.PropertyNames.ClassName) = "IEFrame"
            Mainwindow.SearchProperties(UITestControl.PropertyNames.ControlType) = "Window"
            Dim Mainscreenframe As New HtmlFrame(Mainwindow)
            Mainscreenframe.SearchProperties(HtmlFrame.PropertyNames.Name) = "FrameMain"
            Mainscreenframe.SearchProperties(HtmlFrame.PropertyNames.Id) = "FrameMain"
            Mainscreenframe.SearchProperties(HtmlFrame.PropertyNames.TagName) = "FRAME"
            Mainscreenframe.SearchProperties(HtmlFrame.PropertyNames.ControlType) = "Frame"
            Dim Mainbody As New HtmlDocument(Mainwindow)
            Mainbody.SearchProperties(HtmlDocument.PropertyNames.Name) = "FrameMain"

    This is my hierarchy

    BrowserWindow> HtmlFrame> HtmlDocument> HtmlTable> HtmlCell

    I am getting the same error here?


    Thursday, May 7, 2015 1:19 AM