如何更改Squish中的waitForObject函数使用的默认超时

时间:2018-09-09 14:00:10

标签: python qt automated-tests squish

用于waitForObject的函数如下。我希望每次使用此功能时都等待默认的秒数。

def login():
    type(waitForObject(names.login_lineEditUserId_QLineEdit), "786")

3 个答案:

答案 0 :(得分:6)

waitForObject()的默认超时为testSettings.waitForObjectTimeout。 可以在settings.xml或您的测试脚本中或从 “测试设置-AUT”标签(仅限Squish 6.4)。

https://doc.froglogic.com/squish/latest/rgs-squish.html#testSettings.waitForObjectTimeout-property

最好的问候

艾伦·埃斯特斯特

答案 1 :(得分:0)

如果您希望超时取决于代码行,请通过添加以毫秒为单位的超时作为 WaitForObject 函数的最后一个参数来修改调用。

例如,对于4秒钟的超时,请从更改代码:

type(waitForObject(names.login_lineEditUserId_QLineEdit), "786")

至:

type(waitForObject(names.login_lineEditUserId_QLineEdit, 4000), "786")

对于 WaitForObjectItem WaitForObjectExists ,其工作方式相同。

注意:超时的默认值为20秒。

答案 2 :(得分:0)

我在import random #Function for Player ones rolls def rollP1(): #Player 1 rolls twice print("\n\nPlayer 1's rolls:") rollOne1 = random.randint(1,6) rollTwo1 = random.randint(1,6) #Checking if player 1 has a double, even total, or odd total #if player has a double, player gets a bonus roll if rollOne1 == rollTwo1: print("You got a double. ", rollOne1, "and ", rollTwo1,", have a bonus roll!") rollThree1 = random.randint(1,6) print(rollThree1) rollTotal1 = rollOne1 + rollTwo1 + rollThree1 print("Your total score for this round is ", rollTotal1, ". Well Done.") #if player gets an even total, score increases by 10 elif (rollOne1 + rollTwo1)%2 == 0: rollTotal1 = rollOne1 + rollTwo1 + 10 print("You got ", rollOne1, " and ", rollTwo1, ", your total is an even number, plus 10 points. Your total for this round is now ", rollTotal1, ". Well Done.") #if player gets an odd total, score decreases by 5 elif (rollOne1 + rollTwo1)%2 != 0: rollTotal1 = (rollOne1 + rollTwo1) - 5 print("You got ", rollOne1, " and ", rollTwo1, ". Unlucky, total is an odd number. Minus 5 points Your total for this round now ", rollTotal1, ". Better luck next time.") #Returning the total score for Player one for the round. return rollTotal1 #Function for Player twos' rolls def rollP2(): #Player 2 rolls twice print("\nPlayer 2's rolls:") rollOne2 = random.randint(1,6) rollTwo2 = random.randint(1,6) #Checking if player 2 has a double, even total, or odd total #if player has a double, player gets a bonus roll if rollOne2 == rollTwo2: print("You got a double. ", rollOne2," and", rollTwo2, ", have a bonus roll!") rollThree2 = random.randint(1,6) print(rollThree2) rollTotal2 = rollOne2 + rollTwo2 + rollThree2 print("Your total score for this round is ", rollTotal2, ". Well Done.") #if player gets an even total, score increases by 10 elif (rollOne2 + rollTwo2)%2 == 0: rollTotal2 = rollOne2 + rollTwo2 + 10 print("You got ", rollOne2, " and ", rollTwo2, ". Your total is an even number, plus 10 points. Your total for this round is now ", rollTotal2, ". Well Done.") #if player gets an odd total, score decreases by 5 elif (rollOne2 + rollTwo2)%2 != 0: rollTotal2 = (rollOne2 + rollTwo2) - 5 print("You got ", rollOne2, " and ", rollTwo2, ". Unlucky, your total is an odd number. Minus 5 points Your total for this round is now ", rollTotal2, ". Better luck next time") #Returning the total score for Player two for the round. return rollTotal2 Total1 = 0 Total2 = 0 rounds = 1 while rounds < 6: print("Round ", rounds) rolledP1 = rollP1() rolledP2 = rollP2() rollTotal1 = rolledP1 rollTotal2 = rolledP1 print("Player 1's score for this round is ", rollTotal1, " and player 2's score for this round is ", rollTotal2) Total1 = Total1 + rollTotal1 Total2 = Total2 + rollTotal2 print("Player 1's total so far is ", Total1, ", Player 2's total so far is ", rollTotal2, ". Round Over\n\n") rounds = rounds + 1 和所有其他AUT设置中进行了所有必要的更改(除了在两者之间实际使用贪睡功能外,对我没有任何帮助)。

当前,我仅使用settings.xml,因为40是一个神奇的数字,您可以在全局文件中声明它们,并在每次要使用这些对象时调用它。

请明确说明:

  1. time.sleep(40) //这样,系统将在执行第2行之前等待30秒
  2. Time.sleep(30) //避免使用坐标,因为如果对象或窗口移动了这些位置,则测试将通过映射对象而失败,squish只会找到具有特定id的对象)

请不要忘记在程序的开头添加type(waitForObject(names.login_lineEditUserId_QLineEdit), "786")