有没有办法让Appium服务器登录测试脚本,如
driver.manage().logs().get("appium server");
或将appium服务器日志重定向到控制台
我的主要目的是单独获取Instrumentation Logs而不是所有日志
info: [debug] [INST] instrument logs
答案 0 :(得分:4)
正如@Kirill Zhukov所说。
您也可以使用标记-G
或--webhook
将日志输出发送到HTTP侦听器:--webhook localhost:9876
。
如果您正在使用UI,则必须启用此日志以进行webhook
我创建了一个简单的Socket服务器来监听日志,它运行正常。使用此服务器根据需要获取日志。下面的代码将在控制台中打印日志
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.logging.Level;
import java.util.logging.Logger;
public class Server extends Thread {
private static ServerSocket socket;
private static String home = "./";
private static int port = 9876;
private static boolean isAlive = true;
private static final Server server = new Server();
public static Server getServer(String[] args) {
if (args.length == 2) {
home = args[1];
}
port = Integer.parseInt(args[0]);
return server;
}
private Server() {
}
public static Server getServer() {
return server;
}
@Override
public void run() {
try {
if (socket != null) {
if (!socket.isClosed()) {
if (port == getPort()) {
System.err.println("Server active at the Same Port! ");
} else {
close();
}
}
}
socket = new ServerSocket(port);
port = socket.getLocalPort();
System.out.println("Server accepting connections on port :" + port);
socket.setReceiveBufferSize(146988);
handlleRequest();
} catch (IOException e) {
System.err.println("Could not start server: " + e.getMessage());
port = 0;
run();
}
}
public int getPort() {
return socket == null ? 0 : port;
}
public String getPortS() {
return String.valueOf(port);
}
public void Stop() {
isAlive = false;
}
public void handlleRequest() {
while (isAlive) {
System.out.println("Test");
try (Socket connection = socket.accept()) {
display(connection);
} catch (IOException e) {
System.err.println(e);
}
}
}
public void display(Socket connection) {
try (BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()))) {
String line = in.readLine();
while (in.ready() && line != null) {
System.out.println(line);
line = in.readLine();
}
} catch (IOException ex) {
Logger.getLogger(Server.class.getName()).log(Level.SEVERE, null, ex);
}
}
public void close() throws IOException {
if (socket != null && !socket.isClosed()) {
isAlive = false;
socket.close();
}
}
public static void main(String[] args) {
args = new String[]{"9876", "./"};
Server f = Server.getServer(args);
f.start();
}
}
答案 1 :(得分:2)
来自官方documentation:
Server Error in Application "DEFAULT WEB SITE"
Internet Information Services 7.5
Error Summary
HTTP Error 500.24 - Internal Server Error
An ASP.NET setting has been detected that does not apply in
Integrated managed pipeline mode.
Detailed Error Information
ModuleConfigurationValidationModule NotificationBeginRequest HandlerExtensionlessUrlHandler-Integrated-4.0
Error Code0x80070032
Requested URL http://localhost:80/Token
Physical Path C:\inetpub\wwwroot\Token
Logon Method Not yet determined
Logon User Not yet determined
Failed Request
Tracing Log Directory C:\inetpub\logs\FailedReqLogFiles
Most likely causes: system.web/identity@impersonate is set to true.
Things you can try: If the application supports it, disable client impersonation.
If you are certain that it is OK to ignore this error, it can
be disabled by setting system.webServer/validation@validateIntegratedModeConfiguration to false.
Move this application to an application pool using Classic .NET mode
- for example, %SystemRoot%\system32\inetsrv\appcmd set app "Default Web Site/" /applicationPool:"Classic .NET AppPool"
(You can set "Classic .NET AppPool" to the name of another application pool running in Classic managed pipeline mode)
或-g
指定要存储日志的文件路径,然后可以按--log
过滤它? [INST]
或-G
将日志输出发送到HTTP侦听器:--webhook
。我不知道它是如何工作的,但想知道!--webhook localhost:9876
可以打开控制台输出中的时间戳(默认为--log-timestamp
)。我建议启用它:)答案 2 :(得分:0)
只需编写一个可能的解决方案,而无需使用我们手边的代码,请注意这是我们在Windows机器上运行的节点上所做的,但它也适用于Appium。 AFAIK有一个IOSDriver你实例,该驱动程序从RemoteWebDriver扩展而来,它有一个可覆盖的日志方法(不记得名字)。您可以扩展IOSDriver类并覆盖该日志记录方法,以便您可以使用您喜欢的日志库在任何地方进行日志记录。