appium Software caused connection abort: socket write error

问题描述 投票:0回答:0

我的代码

import java.io.File;
import java.net.URL;

import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.AndroidElement;
import io.appium.java_client.remote.AutomationName;

public class AppStart {

    AndroidDriver<AndroidElement> driver;
    
    @BeforeMethod
    public void setUp() throws Exception {
        String url="http://127.0.0.1:4723/wd/hub";
        //String url="http://0.0.0.0:4723/wd/hub";

        File appDir = new File("F:\\");
        File app = new File(appDir, "selendroid-test-app-0.17.0.apk");//获取文件路径
        
        DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.setCapability("appium:deviceName", "127.0.0.1:62001");
        capabilities.setCapability("appium:app", app.getAbsolutePath());
        capabilities.setCapability("appium:automationName", AutomationName.APPIUM);
        capabilities.setCapability("platformName", "Android");
        capabilities.setCapability("appium:platformVersion", "7.1.2");
        capabilities.setCapability("appPackage", "io.selendroid.testapp");
        capabilities.setCapability("appActivity", ".HomeScreenActivity");

        driver = new AndroidDriver<>(new URL(url), capabilities);
//      driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
//      driver = new AndroidDriver<>(new URL(url), capabilities);
    }
    
    @Test
    public void testWebApp() {
        
    }
    
    @AfterMethod
    public void tearDown() {
        driver.quit();
    }

}

maven 可能 selenium-server-standalone 导致错误,但我需要它。

<dependency>
            <groupId>io.appium</groupId>
            <artifactId>java-client</artifactId>
            <version>7.6.0</version>
        </dependency>
        
        <!-- include testng -->
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-server-standalone</artifactId>
            <version>2.20.0</version>
        </dependency> 
        

这是控制台错误

三月 02, 2023 7:53:05 下午 io.appium.java_client.remote.AppiumCommandExecutor$1 lambda$0
信息: Detected dialect: W3C
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 java.io.ObjectOutputStream$BlockDataOutputStream.drain(Unknown Source)
    at java.io.ObjectOutputStream$BlockDataOutputStream.setBlockDataMode(Unknown Source)
    at java.io.ObjectOutputStream.writeNonProxyDesc(Unknown Source)
    at java.io.ObjectOutputStream.writeClassDesc(Unknown Source)
    at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)
    at java.io.ObjectOutputStream.writeObject0(Unknown Source)
    at java.io.ObjectOutputStream.writeFatalException(Unknown Source)
    at java.io.ObjectOutputStream.writeObject(Unknown Source)
    at org.testng.remote.strprotocol.SerializedMessageSender.sendMessage(SerializedMessageSender.java:21)
    at org.testng.remote.strprotocol.MessageHub.sendMessage(MessageHub.java:44)
    at org.testng.remote.strprotocol.RemoteTestListener.onTestStart(RemoteTestListener.java:49)
    at org.testng.internal.Invoker.runTestListeners(Invoker.java:1805)
    at org.testng.internal.Invoker.runTestListeners(Invoker.java:1780)
    at org.testng.internal.Invoker.invokeMethod(Invoker.java:643)
    at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:846)
    at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1170)
    at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
    at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
    at org.testng.TestRunner.runWorkers(TestRunner.java:1147)
    at org.testng.TestRunner.privateRun(TestRunner.java:749)
    at org.testng.TestRunner.run(TestRunner.java:600)
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:317)
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:312)
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:274)
    at org.testng.SuiteRunner.run(SuiteRunner.java:223)
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1039)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:964)
    at org.testng.TestNG.run(TestNG.java:900)
    at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:110)
    at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:205)
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:174)
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 java.io.ObjectOutputStream$BlockDataOutputStream.drain(Unknown Source)
    at java.io.ObjectOutputStream$BlockDataOutputStream.setBlockDataMode(Unknown Source)
    at java.io.ObjectOutputStream.<init>(Unknown Source)
    at org.testng.remote.strprotocol.SerializedMessageSender.sendMessage(SerializedMessageSender.java:20)
    at org.testng.remote.strprotocol.MessageHub.sendMessage(MessageHub.java:44)
    at org.testng.remote.strprotocol.RemoteTestListener.onTestSuccess(RemoteTestListener.java:88)
    at org.testng.internal.Invoker.runTestListeners(Invoker.java:1800)
    at org.testng.internal.Invoker.runTestListeners(Invoker.java:1780)
    at org.testng.internal.Invoker.invokeMethod(Invoker.java:749)
    at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:846)
    at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1170)
    at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
    at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
    at org.testng.TestRunner.runWorkers(TestRunner.java:1147)
    at org.testng.TestRunner.privateRun(TestRunner.java:749)
    at org.testng.TestRunner.run(TestRunner.java:600)
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:317)
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:312)
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:274)
    at org.testng.SuiteRunner.run(SuiteRunner.java:223)
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1039)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:964)
    at org.testng.TestNG.run(TestNG.java:900)
    at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:110)
    at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:205)
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:174)
java.net.SocketException: Software caused connection abort: socket write errorPASSED: testWebApp

===============================================
    Default test
    Tests run: 1, Failures: 0, Skips: 0
===============================================


    at java.net.SocketOutputStream.socketWrite0(Native Method)
    at java.net.SocketOutputStream.socketWrite(Unknown Source)
    at java.net.SocketOutputStream.write(Unknown Source)
    at java.io.ObjectOutputStream$BlockDataOutputStream.drain(Unknown Source)
    at java.io.ObjectOutputStream$BlockDataOutputStream.setBlockDataMode(Unknown Source)
    at java.io.ObjectOutputStream.<init>(Unknown Source)
    at org.testng.remote.strprotocol.SerializedMessageSender.sendMessage(SerializedMessageSender.java:20)
    at org.testng.remote.strprotocol.MessageHub.sendMessage(MessageHub.java:44)
    at org.testng.remote.strprotocol.RemoteTestListener.onFinish(RemoteTestListener.java:34)
    at org.testng.TestRunner.fireEvent(TestRunner.java:1428)
    at org.testng.TestRunner.afterRun(TestRunner.java:1174)
    at org.testng.TestRunner.run(TestRunner.java:604)
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:317)
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:312)
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:274)
    at org.testng.SuiteRunner.run(SuiteRunner.java:223)
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1039)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:964)
    at org.testng.TestNG.run(TestNG.java:900)
    at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:110)
    at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:205)
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:174)
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 java.io.ObjectOutputStream$BlockDataOutputStream.drain(Unknown Source)
    at java.io.ObjectOutputStream$BlockDataOutputStream.setBlockDataMode(Unknown Source)
    at java.io.ObjectOutputStream.<init>(Unknown Source)
    at org.testng.remote.strprotocol.SerializedMessageSender.sendMessage(SerializedMessageSender.java:20)
    at org.testng.remote.strprotocol.MessageHub.sendMessage(MessageHub.java:44)
    at org.testng.remote.RemoteTestNG$RemoteSuiteListener.onFinish(RemoteTestNG.java:251)
    at org.testng.SuiteRunner.invokeListeners(SuiteRunner.java:182)
    at org.testng.SuiteRunner.run(SuiteRunner.java:226)
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1039)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:964)
    at org.testng.TestNG.run(TestNG.java:900)
    at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:110)
    at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:205)
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:174)

我该怎么办?谢谢

我认为这句话“软件导致连接中止:套接字写入错误”不应该被阻止。如果我在没有testng的情况下运行主函数,没关系。但是当我将代码放入testng时,错误就会发生。

testng appium
© www.soinside.com 2019 - 2024. All rights reserved.