-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathguessTheNumberPyTest.fg
48 lines (43 loc) · 1.2 KB
/
guessTheNumberPyTest.fg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!syntax:pythonic
def startOfString(p_text, p_howManyCharacter):
js (p_text, p_howManyCharacter):
return p_text.slice(0, p_howManyCharacter)
def getAnswer():
var answer := getText('#gameBoard p:nth-last-of-type(2)')
var answer2 := getText('#gameBoard p:nth-last-of-type(1)')
var result
if answer = 'Too low! Try again!':
result := 'tooLow'
if answer = 'Too high! Try again!':
result := 'tooHigh'
if startOfString(answer2, 10) = 'Well Done!':
result := 'equal'
result
print('Test ++++++++++++++++++++++++++++')
var answ
waitSeconds(2)
enterEntry('#gameBoard .entry', '0')
waitSeconds(0.1)
enterEntry('#gameBoard .entry', '0')
waitSeconds(0.1)
enterEntry('#gameBoard .entry', '0')
waitSeconds(0.1)
enterEntry('#gameBoard .entry', '4')
waitSeconds(0.1)
answ := getAnswer()
if answ = 'tooLow':
enterEntry('#gameBoard .entry', '6')
waitSeconds(0.1)
answ := getAnswer()
if answ = 'tooLow':
enterEntry('#gameBoard .entry', '7')
if answ = 'tooHigh':
enterEntry('#gameBoard .entry', '5')
if answ = 'tooHigh':
enterEntry('#gameBoard .entry', '2')
waitSeconds(0.1)
answ := getAnswer()
if answ = 'tooLow':
enterEntry('#gameBoard .entry', '3')
if answ = 'tooHigh':
enterEntry('#gameBoard .entry', '1')