如何将一台机器appium脚本执行到另一台机器(远程机器)?

How to execute one machine appium script to another machine(Remote machine)?

是否可以在远程机器上安装 Appium 运行ning 并且设备也连接在同一台远程机器上,并且 运行 来自本地机器的测试脚本?

以下代码在具有本地 appium 服务器的本地机器上运行良好。 请帮助我 one.bcaz 我是 appium 的新手。

package com.appiumproj.test;    
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.remote.MobileCapabilityType;
import java.net.MalformedURLException;
import java.net.URL;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.annotations.*;

public class Appium {

AppiumDriver driver;

@BeforeClass
public void setUp() throws MalformedURLException{

     //Set up desired capabilities and pass the Android app-activity and app-package to Appium

   DesiredCapabilities capabilities = new DesiredCapabilities();
   capabilities.setCapability(MobileCapabilityType.VERSION, "5.0.2");
   capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, "Android");
   capabilities.setCapability(MobileCapabilityType.DEVICE_NAME,"ZX1D62FPVQ");
   capabilities.setCapability(MobileCapabilityType.APP_PACKAGE, "com.android.calculatord");
   capabilities.setCapability(MobileCapabilityType.APP_ACTIVITY, "com.android.calculator2.Calculator"); 
   driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
}

@Test
public void testCal(){


   WebElement two=driver.findElement(By.name("2"));
    two.click();
    WebElement plus=driver.findElement(By.name("+"));
    plus.click();
    WebElement four=driver.findElement(By.name("4"));
    four.click();
    WebElement equalTo=driver.findElement(By.name("="));
    equalTo.click();

    WebElement results=driver.findElement(By.className("android.widget.EditText"));

    assert results.getText().equals("6"):"Actual value is : "+results.getText()+" did not match with expected value: 6";

    System.out.println("Inside Test Function");
terClass
public void teardown(){


    driver.closeApp();
}
}

在远程机器上的端口 4723 上启动你的 appium 服务器。然后更改行

driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);

driver = new AndroidDriver(new URL("http://IP OF THE REMOTE MACHINE :4723/wd/hub"), capabilities);