Ask a Question

find a texblock object exist in the application

kvooturi
Occasional Contributor

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 7
YMinaev
Staff

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.
------
Yuri
TestComplete Customer Care Engineer

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
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.
YMinaev
Staff

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.
------
Yuri
TestComplete Customer Care Engineer

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
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)
YMinaev
Staff

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)?
------
Yuri
TestComplete Customer Care Engineer

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
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
YMinaev
Staff

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)?
------
Yuri
TestComplete Customer Care Engineer

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
cancel
Showing results for 
Search instead for 
Did you mean: