Appium Jenkins测试执行冻结

时间:2016-08-12 17:55:34

标签: android jenkins testng adb appium

Appium预定测试(Jenkins)未能提供此类日志消息:

project.CardManagementTest.setUp FAILED
    org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: Cannot stop and clear com.ao.demo. Original error: Error executing adbExec. Original error: Command '/Users/administrator/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell pm clear com.ao.demo' timed out after 20000ms{"stdout":"","stderr":"","code":null} (WARNING: The server did not provide any stacktrace information)
    Command duration or timeout: 212.78 seconds
    Build info: version: '2.53.1', revision: 'a36b8b1cd5757287168e54b817830adce*****', time: '2016-06-30 19:26:09'
    System info: host: 'macprobuild.corp.com', ip: '153.86,***.***', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.11.4', java.version: '1.8.0_73'
    Driver info: io.appium.java_client.android.AndroidDriver
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
        at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)
        at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
        at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:678)
        at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:51)
        at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
        at io.appium.java_client.android.AndroidDriver.execute(AndroidDriver.java:1)
        at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:249)
        at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131)
        at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:144)
        at io.appium.java_client.DefaultGenericMobileDriver.<init>(DefaultGenericMobileDriver.java:47)
        at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:114)
        at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:132)
        at io.appium.java_client.android.AndroidDriver.<init>(AndroidDriver.java:97)
        at config.DesiredCapabilitiesSetup.startAppiumServer(DesiredCapabilitiesSetup.java:74)
        at foundation.CardManagementTest.setUp(CardManagementTest.java:44)

当我在服务器机器前面时它执行的奇怪的事情。但是,如果我离开服务器机器大约30分钟并远程进行构建,它将失败。

服务器计算机已配置为: - 防止计算机睡觉自动。 - 唤醒网络访问 - 启用电力午睡。

在我的本地计算机测试运行并始终给出成功结果。 在服务器计算机上,有一些测试计划用于其他设备,但没有实际设备通过USB连接到服务器计算机。 我的测试在模拟器上运行。

我想要的能力是:

package config;

import com.***.moo.webcalls.AOEnvironment;
import com.***.moo.webcalls.AOWebClient;
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.AndroidElement;
import io.appium.java_client.remote.MobileCapabilityType;
import io.appium.java_client.remote.MobilePlatform;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.io.FileUtils;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.BeforeClass;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Scanner;
import java.util.UUID;
import java.util.concurrent.TimeUnit;


public class DesiredCapabilitiesSetup {



    @BeforeClass


    public static AndroidDriver<AndroidElement> startAppiumServer() throws IOException {
// Taking App/Device/Link path from *txt file located in the project //
        /*
        String appLink = FileUtils.readFileToString(new File("appConfigurations/appLink.txt"));
        String deviceName = FileUtils.readFileToString(new File("appConfigurations/deviceName.txt"));
        String appName = FileUtils.readFileToString(new File("appConfigurations/appName.txt"));
        */
//                                                               //
        String appLink = FileUtils.readFileToString(new File("appConfigurations/appLink.txt"));
        String deviceName = FileUtils.readFileToString(new File("appConfigurations/deviceName.txt"));
        String appName = FileUtils.readFileToString(new File("appConfigurations/appName.txt"));



        DesiredCapabilities cap = new DesiredCapabilities();
        cap.setCapability(MobileCapabilityType.PLATFORM_NAME, MobilePlatform.ANDROID);
        cap.setCapability(MobileCapabilityType.DEVICE_NAME,deviceName);
        cap.setCapability(MobileCapabilityType.VERSION,"6.0");
        cap.setCapability("avd","nexus");
        File appSource= new File(appLink);
        File app=new File(appSource, appName);
        cap.setCapability(MobileCapabilityType.APP, app.getAbsolutePath());

        AndroidDriver<AndroidElement> driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), cap);
        driver.manage().timeouts().implicitlyWait(80, TimeUnit.SECONDS);




        return driver;
    }



}

现在我不明白这个问题来自哪里。 It It Emulator或Adb或Jenkins或DesiredCap配置。

 org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: Cannot stop and clear com.ao.demo. Original error: Error executing adbExec. Original error: Command '/Users/administrator/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell pm clear com.ao.demo' timed out after 20000ms{"stdout":"","stderr":"","code":null} (WARNING: The server did not provide any stacktrace information)
    Command duration or timeout: 212.78 seconds

设置

@BeforeClass
    public void setUp() throws Exception {

        driver = DesiredCapabilitiesSetup.startAppiumServer();
        aoWebClient = DesiredCapabilitiesSetup.getAOWeb();


        LogIn logIn = new LogIn(driver,aoWebClient);
        logIn.logIn();
    }

1 个答案:

答案 0 :(得分:0)

- 在appium功能下弃用了avd。

public static AndroidDriver<WebElement> ANDROID_DRIVER; 
ANDROID_DRIVER = new AndroidDriver<WebElement>(serverAddress, capabilities);

我将ANDROID_DRIVER定义为全局 另外,您可以粘贴CardManagementTest.setUp代码吗?