MCPcopy Create free account
hub / github.com/THUDM/AutoWebGLM / step

Method step

webarena/browser_env/envs.py:236–278  ·  view source on GitHub ↗
(
        self, action: Action
    )

Source from the content-addressed store, hash-verified

234 self.context_manager.__exit__()
235
236 def step(
237 self, action: Action
238 ) -> tuple[dict[str, Observation], float, bool, bool, dict[str, Any]]:
239 if not self.reset_finished:
240 raise RuntimeError("Call reset first before calling step.")
241
242 success = False
243 fail_error = ""
244 try:
245 self.page = execute_action(
246 action,
247 self.page,
248 self.context,
249 self.observation_handler.action_processor,
250 )
251 success = True
252 except Exception as e:
253 fail_error = str(e)
254
255 # hard sleep TODO[shuyanzh] suboptimal, may need to check network
256 if self.sleep_after_execution > 0:
257 time.sleep(self.sleep_after_execution)
258
259 images = self.modify_page()
260
261 observation = self._get_obs()
262 observation_metadata = self._get_obs_metadata()
263
264 info = {
265 "page": DetachedPage(self.page.url, self.page.content()),
266 "fail_error": fail_error,
267 "observation_metadata": observation_metadata,
268 "images": images,
269 }
270
271 msg = (
272 observation,
273 float(success), # reward
274 False, # terminated
275 False, # truncated
276 info,
277 )
278 return msg
279
280 def modify_page(self):
281 self.page.wait_for_timeout(500)

Callers 15

testFunction · 0.95
get_observationFunction · 0.95
test_auth_cookieFunction · 0.95
testMethod · 0.45
minimal_example.pyFile · 0.45
step_onceFunction · 0.45
test_frame_locatorFunction · 0.45
test_basicFunction · 0.45
test_hoverFunction · 0.45
test_select_optionFunction · 0.45
test_xpathFunction · 0.45
test_script_browser_envFunction · 0.45

Calls 5

modify_pageMethod · 0.95
_get_obsMethod · 0.95
_get_obs_metadataMethod · 0.95
execute_actionFunction · 0.85
DetachedPageClass · 0.85

Tested by 15

test_auth_cookieFunction · 0.76
test_frame_locatorFunction · 0.36
test_basicFunction · 0.36
test_hoverFunction · 0.36
test_select_optionFunction · 0.36
test_xpathFunction · 0.36
test_script_browser_envFunction · 0.36
test_accessibility_treeFunction · 0.36