Forum Discussion

kvooturi's avatar
kvooturi
Occasional Contributor
14 years ago

find a texblock object exist in the application

We have a an object whose clrfullclassname is "System.Windows.Controls.TextBlock"



Question:

1. to which object shall I map this,(I mapped it to WPFEdit)

2. How do I find whether an object with name " "Segment A1 (12:28)" exists, following is the way I am doing. plz suggest



testobject.TextBlock( "Segment A1 (12:28)").exists




7 Replies

  • Hi,



    1. You don't need to map this object to any type of control. Work with it via its native properties and methods in the way you'd do this inside your application.



    2. Inspect this object in the Object Browser and see what property has the needed value ("Segment A1 (12:28)"). Then, use the Find method (see the "Find Method" help topic) to search for the object by this property.
  • kvooturi's avatar
    kvooturi
    Occasional Contributor
    I checked the object in the object browser: The following properties have



    Name = WPFObject("TextBlock", "Segment A1 (12:28)", 2)



    Text = Segment A1 (12:28)



    WPFControlText = Segment A1 (12:28)



    So I am doing the following way.



    1. setting

    set mysegment  =  frmNewsPlexMDI.MdiClient.frmMocoContainer.splitContainer1.SplitterPanel.mocoHost.HwndSource_AdornerDecorator.AdornerDecorator.AvalonAdapter.main.dockMain.gridContent.gridMain.Viewbox.Grid.MocoPanel.header.Border.Grid



    2. getting cordinates

    leftcordinate = mysegment.TextBlock(WPFcontroltext = "Segment A1 (12:28)").screenleft



    3. MsgBox(leftcordinate)





    But I get the message saying non-existent object. please suggest the correct way to do.
  • Hi,



    As I said in my previous post, use the Find method. The first parameter is "Text", the second one is "Segment A1 (12:28)". You can find an example in the "Find Method" help topic.
  • kvooturi's avatar
    kvooturi
    Occasional Contributor
    I am doing the following way but I still get saying the object does not exist.  can you tell what may be wrong.

    [FYI: the object I am trying find is something like this - WPFObject("TextBlock", "Segment A1 (12:28)", 2)  ]



    step 1

    set mysegment = Sys.Process("NewsFlex").WinFormsObject("frmNewsPlexMDI").WinFormsObject("MdiClient", "").WinFormsObject("frmMocoContainer").WinFormsObject("splitContainer1").WinFormsObject("SplitterPanel", "", 2).WinFormsObject("mocoHost").WPFObject("HwndSource: AdornerDecorator", "elementHost1").WPFObject("AdornerDecorator", "", 1).WPFObject("AvalonAdapter", "", 1).WPFObject("main").WPFObject("dockMain").WPFObject("gridContent").WPFObject("gridMain").WPFObject("Viewbox", "", 1).WPFObject("Grid", "", 1).WPFObject("MocoPanel", "", 1).WPFObject("header").WPFObject("Border", "", 1).WPFObject("Grid", "", 1)



    step2

    set pobject = mysegment.Find("WPFControlText","Segment A1 (12:28)",20)





    step3

    msgbox(pobject.Name)
  • Hi,



    In which line do you get this error and what is the missing object (see the Remarks section of the error message in the log to figure this out)?
  • kvooturi's avatar
    kvooturi
    Occasional Contributor
    The error is in this line

    set mysegment =
    Sys.Process("NewsFlex").WinFormsObject("frmNewsPlexMDI").WinFormsObject("MdiClient",
    "").WinFormsObject("frmMocoContainer").WinFormsObject("splitContainer1").WinFormsObject("SplitterPanel",
    "", 2).WinFormsObject("mocoHost").WPFObject("HwndSource:
    AdornerDecorator", "elementHost1").WPFObject("AdornerDecorator", "",
    1).WPFObject("AvalonAdapter", "",
    1).WPFObject("main").WPFObject("dockMain").WPFObject("gridContent").WPFObject("gridMain").WPFObject("Viewbox",
    "", 1).WPFObject("Grid", "", 1).WPFObject("MocoPanel", "",
    1).WPFObject("header").WPFObject("Border", "", 1).WPFObject("Grid", "",
    1)



    The object not found is "WPFControlText","Segment A1 (12:28)",20
  • Hi,



    What text do you see in the Remarks section of the error message you get (see the "Test Log Pages and Panels" help topic)?