Hi guys.
I’m totally new with Appium, apologies if I write something too wrong…
I am struggling to set up Appium + Java + Android Studio:
I have installed Appium and can run the server and the GUI client, I can connect a device, launch an app, get its components… No issues here.
However, when setting up Android Studio, I am having issues importing some libraries. I have downloaded:
-
java-client 7.0.0 with io.appium Group ID (Maven Central Repository Search)
Files:java-client-7.0.0.jar
-
Selenium driver (for Java, 3.141.59, Downloads | Selenium)
Files:byte-buddy-1.8.15.jar
commons-exec-1.3.jar
guava-25.0-jre.jar
okhttp-3.11.0.jar
okio-1.14.0.jar
In Android Studio, I create a basic project, then copy the jar files to the ‘libs’ folder in the ‘app’ folder displayed when in the ‘project’ view. The files are displayed in Android Studio. Then, I selected them and added as libraries to the ‘app’ module’. After rebuilding the project, the files are added to app\build.gradle as dependencies. No errors are returned so far.
Then, I create a new java class (right click in src>main>[project name] ) and added the code displayed in the Appium Inspector after connecting and tapping around the app:
import io.appium.java_client.MobileElement;
import io.appium.java_client.android.AndroidDriver;
import junit.framework.TestCase;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.net.MalformedURLException;
import java.net.URL;
import org.openqa.selenium.remote.DesiredCapabilities;
public class SampleTest {
private AndroidDriver driver;
@Before
public void setUp() throws MalformedURLException {
DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
desiredCapabilities.setCapability("automationName", "UiAutomator2");
desiredCapabilities.setCapability("platformName", "Android");
desiredCapabilities.setCapability("deviceName", "any");
desiredCapabilities.setCapability("appActivity", "com.myapp.testapp.MainActivity");
desiredCapabilities.setCapability("platformVersion", "7.1.1");
desiredCapabilities.setCapability("udid", "18123432A62");
desiredCapabilities.setCapability("fullReset", false);
desiredCapabilities.setCapability("appPackage", "com.myapp.testapp");
URL remoteUrl = new URL("http://localhost:4723/wd/hub");
driver = new AndroidDriver(remoteUrl, desiredCapabilities);
}
@Test
public void sampleTest() {
(new TouchAction(driver)).tap(735, 353).perform()
}
@After
public void tearDown() {
driver.quit();
}
}
Issues:
These dependencies cannot be resolved in Android Studio:
import junit.framework.**TestCase**;
import org.junit.**After**;
import org.junit.**Before**;
import org.junit.**Test**;
import org.openqa.selenium.**remote**.DesiredCapabilities;
The list of jar files look much smaller that some installations guides I have seen in the internet, but these are really old, from around 2016. I have downloaded the files several times and also previous versions and the files are the same ones.
Any help will be really appreciated.
Thanks