IEDriverServer Log配置和解析

获得Log

对于Internet Explorer Driver,有一些很重要的System Properties,例如:

1
2
3
* webdriver.ie.driver - the location of the IE driver.
* webdriver.ie.driver.loglevel - the level at which loging messages are output.
* webdriver.ie.driver.logfile - full path and file name of the log file.

配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
@BeforeMethod(alwaysRun = true)
public static WebDriver openBrowser() throws Exception
{

int browserType = GlobalSetting.browserType;
switch (browserType)
{
case 1:
System.setProperty("webdriver.ie.driver", "resource\\IEDriverServer.exe");
System.setProperty("webdriver.ie.driver.logfile", "c:/bb.txt");
System.setProperty("webdriver.ie.driver.loglevel", "TRACE");

DesiredCapabilities ieCapabilities = DesiredCapabilities.internetExplorer();
ieCapabilities.setCapability("ignoreZoomSetting", true);
ieCapabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,true);
driver = new InternetExplorerDriver(ieCapabilities);
Reporter.log(logTime + " Launch browser: IE.");

break;
}
return driver;
}

其他地方无需再做任何配置和变动。
运行完测试之后,会在设定的C盘下生成bb.txt Log文件,内容如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
I 2015-10-20 10:04:59:258 server.cc(53) Starting WebDriver server on port: '12700' on host: ''
T 2015-10-20 10:04:59:259 server.cc(624) Entering Server::PopulateCommandRepository
T 2015-10-20 10:04:59:259 IEServer.cpp(25) Entering IEServer::IEServer
T 2015-10-20 10:04:59:259 server.cc(83) Entering Server::Start
D 2015-10-20 10:04:59:259 server.cc(104) Mongoose ACL is -0.0.0.0/0,+127.0.0.1
T 2015-10-20 10:04:59:878 server.cc(62) Entering Server::OnHttpEvent
T 2015-10-20 10:04:59:878 server.cc(128) Entering Server::ProcessRequest
T 2015-10-20 10:04:59:878 server.cc(137) Process request with: URI: /status HTTP verb: GET
body: {}
T 2015-10-20 10:04:59:878 server.cc(230) Entering Server::DispatchCommand
T 2015-10-20 10:04:59:878 server.cc(530) Entering Server::LookupCommand
D 2015-10-20 10:04:59:879 server.cc(239) Command: GET /status {}
T 2015-10-20 10:04:59:879 IEServer.cpp(43) Entering IEServer::GetStatus
T 2015-10-20 10:04:59:879 response.cc(55) Entering Response::SetSuccessResponse
T 2015-10-20 10:04:59:879 response.cc(61) Entering Response::SetResponse
T 2015-10-20 10:04:59:879 response.cc(43) Entering Response::Serialize
D 2015-10-20 10:04:59:879 server.cc(308) Response: {"sessionId":"","status":0,"value":{"build":{"version":"2.42.0.0"},"os":{"arch":"x86","name":"windows","version":"6.1.7601"}}}

解析Log

从上边的Log中我们可以看到,Log分4部分:

  1. 类型
    • I - Info
    • D - Debug
    • T - Trace
    • W - Warning
  2. 时间
  3. 代码行数
  4. 日志信息
    这里只是对Log文件的一些简单说明,知道每一部分是什么意思。对于详细的东东,driver的常用命令了,每一行是什么意思了,有兴趣的朋友自己去看吧。
唐胡璐 wechat
欢迎您扫一扫上面的微信公众号,订阅我的博客!
分享创造价值,您的支持将鼓励我继续前行!