1

I have been assigned the task to automate qml programs. I am pretty new to python as well as Squish. I am trying to find a way to get the id property of a text element for example:

Text{
id:testLabel
text:"Hello"
}

So in Squish to get capture the object i get (via Spy)

waitForObject(":GAMES.Hello_Text")

But instead i want to capture it as

waitForObject(":GAMES.testLabel_Text")

Is this possible to acheive?if not what are the other ways i can go about it.

NOTE:I need to compare the text for different languages

dbn
  • 13,144
  • 3
  • 60
  • 86

1 Answers1

2

Diagnosis

I think that you are confusing "real names" with "symbolic names." I'd recommend checking out Squish's official documentation about the objects map, but my understanding is that Squish symbolic names (names which start with a colon) are essentially equivalent to variable names. They are keys used to look up an identifier within your objects.map.

The objects.map includes the symbolic name and what Squish refers to as a "real name." The real name is a matching pattern that can be used to find a Qt object. For instance, you may have rows in your objects.map file that look like:

:GAMES.Hello_Text    {name='Hello_Text' type='QLineEdit' visible='1' window=':GAMES'}
:GAMES.testLabel_Text    {name='testLabel_Text' type='QLineEdit' visible='1' window=':GAMES'}

As you can see, this says that both ":GAMES.Hello_Text" and ":GAMES.testLabel_Text" are QLineEdit fields within the ":GAMES" window (itself a symbolic name with a real specification elsewhere in the objects.map).

Potential solutions

To get full help, I'd recommend posting the relevant entries from your objects.map. Relevant entries would be those for the objects that you are interested in, and probably their immediate parents.

With the caveat that I'm not sure exactly what you need, here are three approaches if you are looking for arbitrary and programmatically determined elements within the object specified by the ":GAMES" symbolic name.

1. Look up the parent object and examine its attributes

games = waitForObject(":GAMES")
mytext = games.testLabel_Text

2. Look up the parent object's attributes

mytext = waitForObjectAttribute(":GAMES", "testLabel_Text") 

Note that in this case, "testLabel_Text" is an arbitrary text string referring to a attribute of the object specified by the ":GAMES" symbolic name. You can think of waitForObjectAttribute() as analogous to the Python built-in getattr().

3. Look up the desired information using a real name

mytext = waitForObject("{name='testLabel_Text' type='QLineEdit' visible='1' window=':GAMES'}")
dbn
  • 13,144
  • 3
  • 60
  • 86