Command line 从命令行运行testng.xml始终返回“0”;运行的测试总数:0“;
尝试从命令行运行testng.xml时遇到问题,因为它会自动返回: 如果我从eclipse运行testng.xml(ProjectName->testng.xml->右键单击->运行方式->testng套件),所有工作正常: 该类的代码为:`Command line 从命令行运行testng.xml始终返回“0”;运行的测试总数:0“;,command-line,automated-tests,appium,testng-eclipse,Command Line,Automated Tests,Appium,Testng Eclipse,尝试从命令行运行testng.xml时遇到问题,因为它会自动返回: 如果我从eclipse运行testng.xml(ProjectName->testng.xml->右键单击->运行方式->testng套件),所有工作正常: 该类的代码为:` package TestNGZ; import io.appium.java_client.android.AndroidDriver; import java.net.MalformedURLException; import java.net.UR
package TestNGZ;
import io.appium.java_client.android.AndroidDriver;
import java.net.MalformedURLException;
import java.net.URL;
import org.openqa.selenium.By;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.Assert;
import org.testng.annotations.Test;
public class ClassOne {
AndroidDriver dr;
@Test
public void call() throws MalformedURLException{
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("deviceName", "Nexus5");
capabilities.setCapability("platformVersion", "6.0");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("appPackage", "com.age.wgg.appspot");
capabilities.setCapability("appActivity", "com.age.wgg.appspot.Main");
dr = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
}
@Test
public void login() throws InterruptedException {
String buttonCheckLogIn = "Settings";
WebDriverWait wait = new WebDriverWait(dr,30);
//Implicit Wait
// dr.manage().timeouts().implicitlyWait(1,TimeUnit.SECONDS);
//Explicit Wait
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//android.widget.Button[5]")));
//Tap on FB Login
dr.findElement(By.xpath("//android.widget.Button[5]")).click();
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//android.widget.EditText[1]")));
//Insert Username
dr.findElement(By.xpath("//android.widget.EditText[1]")).click();
dr.getKeyboard().sendKeys("waaionel@yahoo.ro");
//Insert Password
dr.findElement(By.xpath("//android.widget.EditText[2]")).click();
dr.getKeyboard().sendKeys("Gameloft2013");
//Tap on Log In button
dr.findElementByAccessibilityId("Log In ").click();
//Explicit Wait
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//android.view.View")));
//Tap OK in Confirmation Prompt
dr.findElementByAccessibilityId("OK ").click();
//Explicit Wait
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//android.widget.Button[5]")));
//Verification if the Login was successfully or not
if (dr.findElement(By.xpath("//android.widget.Button[5]")).getText().equals(buttonCheckLogIn)) {
System.out.println("Log In ===> Success");
} else {
System.out.println("Log In ===> Failed");
}
}
@Test
public void logout() throws InterruptedException {
String buttonCheckLogOut = "Log in";
//Verifying FB Log out functionality
dr.findElement(By.xpath("//android.widget.Button[5]")).click();
dr.findElement(By.name("Logout")).click();
dr.findElement(By.name("YES")).click();
Assert.assertTrue(dr.findElement(By.xpath("//android.widget.Button[5]")).getText().equals(buttonCheckLogOut));
//Verification if the Log out was successfully or not
if (dr.findElement(By.xpath("//android.widget.Button[5]")).getText().equals(buttonCheckLogOut)) {
System.out.println("Log Out ===> Success");
} else {
System.out.println("Log Out ===> Failed");
}
//Kill Session
dr.quit();
}
}`
在命令行中,我执行以下命令:
java -cp "C:\Users\Ionut B\Downloads\eclipse-java-kepler-SR1-win32-x86_64\eclipse\plugins\org.testng.eclipse_6.11.0.201703011520\lib\*;C:\Users\Ionut B\workspace\TestZero\bin" org.testng.TestNG testng.xml
Appium服务器正在运行,Emulator已打开。
我已经搜索了所有的地方,但我没有找到解决这个问题的方法,也许这里的人可以帮助我。
谢谢。我发现了问题所在。
在libs“…\lib*”的路径中,必须是Eclipse中也使用过的所有.JAR,在这个特定的例子中,路径只指向testng.JAR,因此在Projects文件夹中,我创建了一个lib文件夹,其中包含Eclipse中使用的所有JAR文件。
谢谢