Squish/Finding List Items that End in a Given String: Difference between revisions
< Squish
Jump to navigation
Jump to search
AutoSpider (talk | contribs) (Move [[Category::Tools::Squish]] -> [[Category::Squish]]) |
(Un-nominate for deletion: Page is no longer a category) |
||
Line 1: | Line 1: | ||
{{ | {{LangSwitch}} | ||
[[Category:Squish]] | [[Category:Squish]] | ||
As Squish uses the full item text for identifying items in a list view, this could cause problems when | As Squish uses the full item text for identifying items in a list view, this could cause problems when |
Revision as of 08:40, 8 December 2018
As Squish uses the full item text for identifying items in a list view, this could cause problems when the beginning of the item text is different based on e.g. which machine you are running the test case.
One solution to this could be to look for items ending with a given string, to avoid including the changing string prefix. This can be done with the utility function below, which clicks an item that ends in a given string in a given column:
def clickListItem(obj, endValue, column):
model = waitForObject(obj).model()
rows = model.rowCount()
for i in range(rows):
itemString=str(model.data(model.index(i, column), Qt.DisplayRole).toString())
if itemString.endswith(endValue):
waitForObjectItem(obj, itemString)
clickItem(obj, itemString, 0, 0, 0, Qt.LeftButton)
return
test.fatal("Could not find item with end value: " + endValue)
Selecting an item that ends in the string "value1" in a specific list view is then done by doing:
clickListItem(":MyQListView", "value1", 0)