1
votes

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. All I am trying is to just to launch for now.

Steps I did:

  1. Started Appium
  2. Run the below written code in Eclipse as 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

Tests run: 0, Failures: 0, Skips: 0

Also a message on the top bar: 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??? I dont know. I am lost. Please help.

1
Rewritting the message that I got on the top bar of the Console section:<terminated>LauchandLogin[TestNg]C:\Program Files\Java\jre1.8.101\ bin\javaw.exe. - Hema
TestNG was running but there is no tests in your class. The method annotated with @Before is not considered as test it is a preparation step. If you want reported tests you have to annotate some methods with @Test. - Balázs Nemes
Hi, I think I found what what went wrong. I Used Import java.junit and then tried to run TESTNG and it did not recognize the @Before annotation. Stupid me! :( , Changed that to testng.before and it worked. But now I am getting an error that says - "Responding to client that we did not find a valid resource" on the appium log... Looking into other Questions to find an answer. Hope I can fix it. The URL did not map to a valid JSONWP resource. - Hema

1 Answers

0
votes

For the actual problem reported, I found that I was using the wrong syntax for 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. It seems there is an issue when trying to execute the code on Android version N. So, there is no issue in my code. I was successfully able to execute it on a cloud device or Android version lesser than 7. Thank you.