本文整理汇总了Python中emulator.Emulator._run_telnet方法的典型用法代码示例。如果您正苦于以下问题:Python Emulator._run_telnet方法的具体用法?Python Emulator._run_telnet怎么用?Python Emulator._run_telnet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类emulator.Emulator
的用法示例。
在下文中一共展示了Emulator._run_telnet方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Marionette
# 需要导入模块: from emulator import Emulator [as 别名]
# 或者: from emulator.Emulator import _run_telnet [as 别名]
#.........这里部分代码省略.........
if self.session:
message['session'] = self.session
if kwargs:
message.update(kwargs)
try:
response = self.client.send(message)
except socket.timeout:
self.session = None
self.window = None
self.client.close()
if self.emulator:
port = self.emulator.restart(self.local_port)
if port is not None:
self.port = self.client.port = port
raise TimeoutException(message='socket.timeout', status=ErrorCodes.TIMEOUT, stacktrace=None)
# Process any emulator commands that are sent from a script
# while it's executing.
while response.get("emulator_cmd"):
response = self._handle_emulator_cmd(response)
if (response_key == 'ok' and response.get('ok') == True) or response_key in response:
return response[response_key]
else:
self._handle_error(response)
def _handle_emulator_cmd(self, response):
cmd = response.get("emulator_cmd")
if not cmd or not self.emulator:
raise MarionetteException(message="No emulator in this test to run "
"command against.")
cmd = cmd.encode("ascii")
result = self.emulator._run_telnet(cmd)
return self.client.send({"type": "emulatorCmdResult",
"id": response.get("id"),
"result": result})
def _handle_error(self, response):
if 'error' in response and isinstance(response['error'], dict):
status = response['error'].get('status', 500)
message = response['error'].get('message')
stacktrace = response['error'].get('stacktrace')
# status numbers come from
# http://code.google.com/p/selenium/wiki/JsonWireProtocol#Response_Status_Codes
if status == ErrorCodes.NO_SUCH_ELEMENT:
raise NoSuchElementException(message=message, status=status, stacktrace=stacktrace)
elif status == ErrorCodes.NO_SUCH_FRAME:
raise NoSuchFrameException(message=message, status=status, stacktrace=stacktrace)
elif status == ErrorCodes.STALE_ELEMENT_REFERENCE:
raise StaleElementException(message=message, status=status, stacktrace=stacktrace)
elif status == ErrorCodes.ELEMENT_NOT_VISIBLE:
raise ElementNotVisibleException(message=message, status=status, stacktrace=stacktrace)
elif status == ErrorCodes.INVALID_ELEMENT_STATE:
raise InvalidElementStateException(message=message, status=status, stacktrace=stacktrace)
elif status == ErrorCodes.UNKNOWN_ERROR:
raise MarionetteException(message=message, status=status, stacktrace=stacktrace)
elif status == ErrorCodes.ELEMENT_IS_NOT_SELECTABLE:
raise ElementNotSelectableException(message=message, status=status, stacktrace=stacktrace)
elif status == ErrorCodes.JAVASCRIPT_ERROR:
raise JavascriptException(message=message, status=status, stacktrace=stacktrace)
elif status == ErrorCodes.XPATH_LOOKUP_ERROR:
raise XPathLookupException(message=message, status=status, stacktrace=stacktrace)
elif status == ErrorCodes.TIMEOUT:
raise TimeoutException(message=message, status=status, stacktrace=stacktrace)
elif status == ErrorCodes.NO_SUCH_WINDOW:
示例2: Marionette
# 需要导入模块: from emulator import Emulator [as 别名]
# 或者: from emulator.Emulator import _run_telnet [as 别名]
#.........这里部分代码省略.........
if not self.session and command not in ('newSession', 'getStatus'):
raise MarionetteException(message="Please start a session")
message = { 'type': command }
if self.session:
message['session'] = self.session
if kwargs:
message.update(kwargs)
try:
response = self.client.send(message)
except socket.timeout:
self.session = None
self.window = None
self.client.close()
raise TimeoutException(message='socket.timeout', status=ErrorCodes.TIMEOUT, stacktrace=None)
# Process any emulator commands that are sent from a script
# while it's executing.
while response.get("emulator_cmd"):
response = self._handle_emulator_cmd(response)
if (response_key == 'ok' and response.get('ok') == True) or response_key in response:
return response[response_key]
else:
self._handle_error(response)
def _handle_emulator_cmd(self, response):
cmd = response.get("emulator_cmd")
if not cmd or not self.emulator:
raise MarionetteException(message="No emulator in this test to run "
"command against.")
cmd = cmd.encode("ascii")
result = self.emulator._run_telnet(cmd)
return self.client.send({"type": "emulatorCmdResult",
"id": response.get("id"),
"result": result})
def _handle_error(self, response):
if 'error' in response and isinstance(response['error'], dict):
status = response['error'].get('status', 500)
message = response['error'].get('message')
stacktrace = response['error'].get('stacktrace')
# status numbers come from
# http://code.google.com/p/selenium/wiki/JsonWireProtocol#Response_Status_Codes
if status == ErrorCodes.NO_SUCH_ELEMENT:
raise NoSuchElementException(message=message, status=status, stacktrace=stacktrace)
elif status == ErrorCodes.NO_SUCH_FRAME:
raise NoSuchFrameException(message=message, status=status, stacktrace=stacktrace)
elif status == ErrorCodes.STALE_ELEMENT_REFERENCE:
raise StaleElementException(message=message, status=status, stacktrace=stacktrace)
elif status == ErrorCodes.ELEMENT_NOT_VISIBLE:
raise ElementNotVisibleException(message=message, status=status, stacktrace=stacktrace)
elif status == ErrorCodes.INVALID_ELEMENT_STATE:
raise InvalidElementStateException(message=message, status=status, stacktrace=stacktrace)
elif status == ErrorCodes.UNKNOWN_ERROR:
raise MarionetteException(message=message, status=status, stacktrace=stacktrace)
elif status == ErrorCodes.ELEMENT_IS_NOT_SELECTABLE:
raise ElementNotSelectableException(message=message, status=status, stacktrace=stacktrace)
elif status == ErrorCodes.JAVASCRIPT_ERROR:
raise JavascriptException(message=message, status=status, stacktrace=stacktrace)
elif status == ErrorCodes.XPATH_LOOKUP_ERROR:
raise XPathLookupException(message=message, status=status, stacktrace=stacktrace)
elif status == ErrorCodes.TIMEOUT:
raise TimeoutException(message=message, status=status, stacktrace=stacktrace)
elif status == ErrorCodes.NO_SUCH_WINDOW:
示例3: Marionette
# 需要导入模块: from emulator import Emulator [as 别名]
# 或者: from emulator.Emulator import _run_telnet [as 别名]
#.........这里部分代码省略.........
if not self.session and command not in ('newSession', 'getStatus'):
raise MarionetteException(message="Please start a session")
message = { 'name': command }
if self.session:
message['sessionId'] = self.session
if kwargs:
message['parameters'] = kwargs
try:
response = self.client.send(message)
except socket.timeout:
self.session = None
self.window = None
self.client.close()
raise TimeoutException(message='socket.timeout', status=ErrorCodes.TIMEOUT, stacktrace=None)
# Process any emulator commands that are sent from a script
# while it's executing.
while response.get("emulator_cmd"):
response = self._handle_emulator_cmd(response)
if (response_key == 'ok' and response.get('ok') == True) or response_key in response:
return response[response_key]
else:
self._handle_error(response)
def _handle_emulator_cmd(self, response):
cmd = response.get("emulator_cmd")
if not cmd or not self.emulator:
raise MarionetteException(message="No emulator in this test to run "
"command against.")
cmd = cmd.encode("ascii")
result = self.emulator._run_telnet(cmd)
return self.client.send({"name": "emulatorCmdResult",
"id": response.get("id"),
"result": result})
def _handle_error(self, response):
if 'error' in response and isinstance(response['error'], dict):
status = response['error'].get('status', 500)
message = response['error'].get('message')
stacktrace = response['error'].get('stacktrace')
# status numbers come from
# http://code.google.com/p/selenium/wiki/JsonWireProtocol#Response_Status_Codes
if status == ErrorCodes.NO_SUCH_ELEMENT:
raise NoSuchElementException(message=message, status=status, stacktrace=stacktrace)
elif status == ErrorCodes.NO_SUCH_FRAME:
raise NoSuchFrameException(message=message, status=status, stacktrace=stacktrace)
elif status == ErrorCodes.STALE_ELEMENT_REFERENCE:
raise StaleElementException(message=message, status=status, stacktrace=stacktrace)
elif status == ErrorCodes.ELEMENT_NOT_VISIBLE:
raise ElementNotVisibleException(message=message, status=status, stacktrace=stacktrace)
elif status == ErrorCodes.INVALID_ELEMENT_STATE:
raise InvalidElementStateException(message=message, status=status, stacktrace=stacktrace)
elif status == ErrorCodes.UNKNOWN_ERROR:
raise MarionetteException(message=message, status=status, stacktrace=stacktrace)
elif status == ErrorCodes.ELEMENT_IS_NOT_SELECTABLE:
raise ElementNotSelectableException(message=message, status=status, stacktrace=stacktrace)
elif status == ErrorCodes.JAVASCRIPT_ERROR:
raise JavascriptException(message=message, status=status, stacktrace=stacktrace)
elif status == ErrorCodes.XPATH_LOOKUP_ERROR:
raise XPathLookupException(message=message, status=status, stacktrace=stacktrace)
elif status == ErrorCodes.TIMEOUT:
raise TimeoutException(message=message, status=status, stacktrace=stacktrace)
elif status == ErrorCodes.NO_SUCH_WINDOW:
示例4: Marionette
# 需要导入模块: from emulator import Emulator [as 别名]
# 或者: from emulator.Emulator import _run_telnet [as 别名]
#.........这里部分代码省略.........
def _send_message(self, command, response_key, **kwargs):
if not self.session and command not in ("newSession", "getStatus"):
raise MarionetteException(message="Please start a session")
message = {"type": command}
if self.session:
message["session"] = self.session
if kwargs:
message.update(kwargs)
try:
response = self.client.send(message)
except socket.timeout:
self.session = None
self.window = None
self.client.close()
raise TimeoutException(message="socket.timeout", status=ErrorCodes.TIMEOUT, stacktrace=None)
# Process any emulator commands that are sent from a script
# while it's executing.
while response.get("emulator_cmd"):
response = self._handle_emulator_cmd(response)
if (response_key == "ok" and response.get("ok") == True) or response_key in response:
return response[response_key]
else:
self._handle_error(response)
def _handle_emulator_cmd(self, response):
cmd = response.get("emulator_cmd")
if not cmd or not self.emulator:
raise MarionetteException(message="No emulator in this test to run " "command against.")
cmd = cmd.encode("ascii")
result = self.emulator._run_telnet(cmd)
return self.client.send({"type": "emulatorCmdResult", "id": response.get("id"), "result": result})
def _handle_error(self, response):
if "error" in response and isinstance(response["error"], dict):
status = response["error"].get("status", 500)
message = response["error"].get("message")
stacktrace = response["error"].get("stacktrace")
# status numbers come from
# http://code.google.com/p/selenium/wiki/JsonWireProtocol#Response_Status_Codes
if status == ErrorCodes.NO_SUCH_ELEMENT:
raise NoSuchElementException(message=message, status=status, stacktrace=stacktrace)
elif status == ErrorCodes.NO_SUCH_FRAME:
raise NoSuchFrameException(message=message, status=status, stacktrace=stacktrace)
elif status == ErrorCodes.STALE_ELEMENT_REFERENCE:
raise StaleElementException(message=message, status=status, stacktrace=stacktrace)
elif status == ErrorCodes.ELEMENT_NOT_VISIBLE:
raise ElementNotVisibleException(message=message, status=status, stacktrace=stacktrace)
elif status == ErrorCodes.INVALID_ELEMENT_STATE:
raise InvalidElementStateException(message=message, status=status, stacktrace=stacktrace)
elif status == ErrorCodes.UNKNOWN_ERROR:
raise MarionetteException(message=message, status=status, stacktrace=stacktrace)
elif status == ErrorCodes.ELEMENT_IS_NOT_SELECTABLE:
raise ElementNotSelectableException(message=message, status=status, stacktrace=stacktrace)
elif status == ErrorCodes.JAVASCRIPT_ERROR:
raise JavascriptException(message=message, status=status, stacktrace=stacktrace)
elif status == ErrorCodes.XPATH_LOOKUP_ERROR:
raise XPathLookupException(message=message, status=status, stacktrace=stacktrace)
elif status == ErrorCodes.TIMEOUT:
raise TimeoutException(message=message, status=status, stacktrace=stacktrace)
elif status == ErrorCodes.NO_SUCH_WINDOW:
raise NoSuchWindowException(message=message, status=status, stacktrace=stacktrace)
elif status == ErrorCodes.INVALID_COOKIE_DOMAIN: