简体   繁体   English

用Eclipse编写的Java代码不能与TESTNG一起运行(尝试使用Eclipse和Appium for Android Emulator自动化测试)

[英]Java code written in Eclipse did not run with TESTNG (trying to automate test using Eclipse and Appium for Android Emulator)

I am new to automation testing and I am trying to automate an app developed in my company.I have done all the setup (as per the online instructions) and have written a java code to test if I am able to launch my app through Appium in Android Emulator. 我是自动化测试的新手,我正在尝试自动化我公司开发的应用程序。我已完成所有设置(根据在线说明)并编写了一个java代码来测试我是否能够通过Appium启动我的应用程序在Android模拟器中。 All I am trying is to just to launch for now. 我所要做的就是现在才开始。

Steps I did: 我做的步骤:

  1. Started Appium 开始Appium
  2. Run the below written code in Eclipse as TestNG 在Eclipse中运行以下编写的代码作为TestNG

     import org.junit.Before; import java.net.URL; import java.util.concurrent.TimeUnit; import java.net.MalformedURLException; import org.openqa.selenium.remote.CapabilityType; import org.openqa.selenium.remote.DesiredCapabilities; import org.openqa.selenium.WebDriver; import org.openqa.selenium.remote.RemoteWebDriver; public class Lauchandlogin { WebDriver driver; @Before public void setUp() throws MalformedURLException{ DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setCapability("avd", "NexS1"); capabilities.setCapability(CapabilityType.VERSION,"7.1.1"); capabilities.setCapability("deviceName","Android Emulator"); capabilities.setCapability("platformName","Andriod"); capabilities.setCapability("newCommandTimeout", 1200); capabilities.setCapability("appPackage","com.rhb.mobile"); capabilities.setCapability("appActivity","com.rhb.LandingActivity"); capabilities.setCapability("appWaitDuration",300000); driver = new RemoteWebDriver(new URL("http://127.0.0.1:4723" ,capabilities); } } 

The TestNG runs and I get the following message in Console Default test TestNG运行,我在控制台默认测试中收到以下消息

Tests run: 0, Failures: 0, Skips: 0 测试运行:0,失败:0,跳过:0

Also a message on the top bar: LauchandLogin[TestNg]C:\\Program Files\\Java\\jre1.8.101\\bin\\javaw.exe. 顶部栏上还有一条消息:LauchandLogin [TestNg] C:\\ Program Files \\ Java \\ jre1.8.101 \\ bin \\ javaw.exe。

There is no reaction on Appium, which I think is because of my TestNG is not running at all??? Appium没有任何反应,我认为是因为我的TestNG根本没有运行??? I dont know. 我不知道。 I am lost. 我搞不清楚了。 Please help. 请帮忙。

For the actual problem reported, I found that I was using the wrong syntax for TESTNG. 对于报告的实际问题,我发现我使用了错误的TESTNG语法。 As I mentioned in the comment it has been fixed. 正如我在评论中提到的,它已被修复。 Another problem that I ran into is due to Appium, which was not able to run on the Android Emulator for mobile devices 7.1.1. 我遇到的另一个问题是Appium,它无法在移动设备7.1.1的Android模拟器上运行。 It seems there is an issue when trying to execute the code on Android version N. So, there is no issue in my code. 尝试在Android版本N上执行代码时似乎存在问题。因此,我的代码中没有问题。 I was successfully able to execute it on a cloud device or Android version lesser than 7. Thank you. 我成功地能够在云设备或小于7的Android版本上执行它。谢谢。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM