I'm new to eclipse. I'm trying to start Appium test on Android devices. My preferenses:
So after installing, configuration Appiumserver, Android SDK, Android Device Manager - next step is to start testing in Eclipse IDE I've got problem with defining URL and don't know what to do. jar files:
that's all
import io.appium.java_client.MobileElement;
import io.appium.java_client.android.AndroidDriver;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
public class FirstScript {
private URL serverUrl;
public static AndroidDriver driver;
public String APPIUM_PORT = "4723";
@BeforeClass
public void setUp() throws MalformedURLException{
//Set the Desired Capabilities
DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability("deviceName", "Samsung S7");
caps.setCapability("udid", "******************"); //Give Device ID of your mobile phone
caps.setCapability("platformName", "Android");
caps.setCapability("platformVersion", "8.0");
caps.setCapability("appPackage", "com.***.***");
caps.setCapability("appActivity", "com.***.***.MainActivity");
caps.setCapability("noReset", "true");
try {
serverUrl = new URL("http://127.0.0.1:4723/wd/hub");
} catch (MalformedURLException e) {
e.printStackTrace();
}
driver = new AndroidDriver (serverUrl,caps);
driver.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS);
}
@Test
public void testExample() {***}
@AfterClass
public void tearDown() {driver.closeApp();}
}
The solution to your issue is that you use latest stable version of Selenium i.e. 3.141.5
If you're having Java project then, before adding new latest version of jar's make sure to first remove all selenium related old jar's and then add newly downloaded version of the jar's to build path.
In case of Maven project, update the selenium dependency version to latest and run following on terminal,
$ mvn clean install