Skip to content

Commit

Permalink
Update the tests to match the miniwob-plusplus repo
Browse files Browse the repository at this point in the history
  • Loading branch information
Panupong Pasupat committed Mar 25, 2018
1 parent f4c4b71 commit 0ddcaad
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 23 deletions.
47 changes: 26 additions & 21 deletions wge/tests/miniwob/test_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,8 @@ def get_action(self, state, step):
if element.tag == 'input_text':
assert element.focused
break
assert False, 'Input text not found'
else:
assert False, 'Input text not found'
# Type the text
target = state.fields['target']
if len(target) > 2:
Expand Down Expand Up @@ -360,33 +361,37 @@ class TestEnterTime(RepeatedTester):

def get_action(self, state, step):
if step == 0:
target = state.fields['target']
if target.startswith('1:'):
target = '0' + target # Typing '14' will change the number to 2
for element in state.dom_elements:
if element.tag == 'input_time':
return self.create_focus_and_type_action(element, state.fields['target'])
return self.create_focus_and_type_action(element, target)
assert False, 'Input text not found'
elif step == 1:
return self.click_button(state, 'Submit')


class TestChooseList(RepeatedTester):
TASK_NAME = 'choose-list'
MAX_STEPS = 3
FRAGILE = 'delay'

def get_action(self, state, step):
if step == 0:
for element in state.dom_elements:
if element.tag == 'select':
return self.create_element_click_action(element)
assert False, 'Select not found'
elif step == 1:
print state.dom.visualize()
for element in state.dom_elements:
if element.text == state.fields['target']:
return self.create_element_click_action(element)
assert False, 'Correct entry not found'
elif step == 2:
return self.click_button(state, 'Submit')
# IMPOSSIBLE TO DO RIGHT NOW, since the select items have wrong coordinates
#class TestChooseList(RepeatedTester):
# TASK_NAME = 'choose-list'
# MAX_STEPS = 3
# FRAGILE = 'delay'
#
# def get_action(self, state, step):
# if step == 0:
# for element in state.dom_elements:
# if element.tag == 'select':
# return self.create_element_click_action(element)
# assert False, 'Select not found'
# elif step == 1:
# print state.dom.visualize()
# for element in state.dom_elements:
# if element.text == state.fields['target']:
# return self.create_element_click_action(element)
# assert False, 'Correct entry not found'
# elif step == 2:
# return self.click_button(state, 'Submit')


class TestClickPie(RepeatedTester):
Expand Down
4 changes: 2 additions & 2 deletions wge/tests/miniwob/test_environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def test_run(self, env):
print [x.utterance for x in states]
assert all(x.utterance == 'Click the button.' for x in states)
print [x.fields for x in states]
assert all(not x.fields for x in states)
assert all(x.fields.keys == ['dummy'] for x in states)
print [x.dom for x in states]
print states[0].dom_elements
print states[0].dom.visualize()
Expand Down Expand Up @@ -318,7 +318,7 @@ def test_fields(self, env):
for state in states:
print state.utterance
print state.fields
assert not state.fields.keys
assert state.fields.keys == ['dummy']
assert state.utterance
# Training time
states = env.reset(mode='train')
Expand Down

0 comments on commit 0ddcaad

Please sign in to comment.