java.net.SocketException: Software caused connection abort: socket write error错误解决方法(selenium)

一、问题描述:使用eclipse运行测试用例,报如下错误

java.net.SocketException: Software caused connection abort: socket write error
    at java.net.SocketOutputStream.socketWrite0(Native Method)
    at java.net.SocketOutputStream.socketWrite(Unknown Source)
    at java.net.SocketOutputStream.write(Unknown Source)
    at sun.nio.cs.StreamEncoder.writeBytes(Unknown Source)
    at sun.nio.cs.StreamEncoder.implFlushBuffer(Unknown Source)
    at sun.nio.cs.StreamEncoder.implFlush(Unknown Source)
    at sun.nio.cs.StreamEncoder.flush(Unknown Source)
    at java.io.OutputStreamWriter.flush(Unknown Source)
    at java.io.BufferedWriter.flush(Unknown Source)
    at org.testng.remote.strprotocol.JsonMessageSender.sendMessage(JsonMessageSender.java:41)
    at org.testng.remote.strprotocol.MessageHub.sendMessage(MessageHub.java:42)
    at org.testng.remote.strprotocol.RemoteTestListener1.onTestStart(RemoteTestListener1.java:49)
    at org.testng.internal.Invoker.runTestListeners(Invoker.java:1904)
    at org.testng.internal.Invoker.runTestListeners(Invoker.java:1879)
    at org.testng.internal.Invoker.invokeMethod(Invoker.java:685)
    at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
    at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
    at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
    at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
    at org.testng.TestRunner.privateRun(TestRunner.java:767)
    at org.testng.TestRunner.run(TestRunner.java:617)
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
    at org.testng.SuiteRunner.run(SuiteRunner.java:240)
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1198)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1123)
    at org.testng.TestNG.run(TestNG.java:1031)
    at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:114)
    at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)
[SeleniumAutoConsole] INFO [main] com.cases.KfglTest.kfgl_0001_LoginSucc(36) | kfgl_0001_LoginSucc is running !
[SeleniumAutoConsole] INFO [main] com.cases.KfglTest.kfgl_0001_LoginSucc(40) | DB value is  --- : zhangsan
数据库结果是:zhangsan//有两条数据,英文数据读取正确,中文数据读取失败
java.net.SocketException: Software caused connection abort: socket write error
    at java.net.SocketOutputStream.socketWrite0(Native Method)
    at java.net.SocketOutputStream.socketWrite(Unknown Source)
    at java.net.SocketOutputStream.write(Unknown Source)
    at sun.nio.cs.StreamEncoder.writeBytes(Unknown Source)
    at sun.nio.cs.StreamEncoder.implFlushBuffer(Unknown Source)
    at sun.nio.cs.StreamEncoder.implFlush(Unknown Source)
    at sun.nio.cs.StreamEncoder.flush(Unknown Source)
    at java.io.OutputStreamWriter.flush(Unknown Source)
    at java.io.BufferedWriter.flush(Unknown Source)
    at org.testng.remote.strprotocol.JsonMessageSender.sendMessage(JsonMessageSender.java:41)
    at org.testng.remote.strprotocol.MessageHub.sendMessage(MessageHub.java:42)
    at org.testng.remote.strprotocol.RemoteTestListener1.onTestSuccess(RemoteTestListener1.java:88)
    at org.testng.internal.Invoker.runTestListeners(Invoker.java:1899)
    at org.testng.internal.Invoker.runTestListeners(Invoker.java:1879)
    at org.testng.internal.Invoker.invokeMethod(Invoker.java:778)
    at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
    at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
    at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
    at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
    at org.testng

二、问题原因

测试数据含有中文导致

三、解决方法

修改eclipse.ini,设置系统属性为utf-8
-Dfile.encoding=UTF-8

你可能感兴趣的:(selenium)