Install and Invoke App.
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.remote.DesiredCapabilities;
import io.appium.java_client.MobileElement;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.remote.AndroidMobileCapabilityType;
import io.appium.java_client.remote.MobileCapabilityType;
public class InstallApp {
static AndroidDriver driver;
public static void main(String[] args) throws MalformedURLException {
// TODO Auto-generated method stub
File app = new File("F:/Workspace/Apks", "selendroid-test-app-0.17.0.apk");
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability(MobileCapabilityType.DEVICE_NAME, "0797818a87d4f5cb");
cap.setCapability(MobileCapabilityType.VERSION, "8.0");
cap.setCapability(MobileCapabilityType.PLATFORM_NAME, "Android");
cap.setCapability("app", app.getAbsolutePath());
/*
* cap.setCapability(AndroidMobileCapabilityType.APP_PACKAGE,
* "io.selendroid.testapp");
* cap.setCapability(AndroidMobileCapabilityType.APP_ACTIVITY,
* ".HomeScreenActivity");
*/
driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), cap);
driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
}
}
import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.remote.DesiredCapabilities;
import io.appium.java_client.MobileElement;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.remote.AndroidMobileCapabilityType;
import io.appium.java_client.remote.MobileCapabilityType;
public class InstallApp {
static AndroidDriver driver;
public static void main(String[] args) throws MalformedURLException {
// TODO Auto-generated method stub
File app = new File("F:/Workspace/Apks", "selendroid-test-app-0.17.0.apk");
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability(MobileCapabilityType.DEVICE_NAME, "0797818a87d4f5cb");
cap.setCapability(MobileCapabilityType.VERSION, "8.0");
cap.setCapability(MobileCapabilityType.PLATFORM_NAME, "Android");
cap.setCapability("app", app.getAbsolutePath());
/*
* cap.setCapability(AndroidMobileCapabilityType.APP_PACKAGE,
* "io.selendroid.testapp");
* cap.setCapability(AndroidMobileCapabilityType.APP_ACTIVITY,
* ".HomeScreenActivity");
*/
driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), cap);
driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
}
}
after use this code i am getting this error
ReplyDeleteplz help me
Exception in thread "main" java.lang.IncompatibleClassChangeError: Class io.appium.java_client.remote.AppiumCommandExecutor$$Lambda$5/370869802 does not implement the requested interface java.util.function.Supplier
at java.util.Optional.orElseGet(Unknown Source)
at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:100)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:644)
at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:42)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
at io.appium.java_client.android.AndroidDriver.execute(AndroidDriver.java:1)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:249)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:131)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:144)
at io.appium.java_client.DefaultGenericMobileDriver.(DefaultGenericMobileDriver.java:38)
at io.appium.java_client.AppiumDriver.(AppiumDriver.java:83)
at io.appium.java_client.AppiumDriver.(AppiumDriver.java:93)
at io.appium.java_client.android.AndroidDriver.(AndroidDriver.java:72)
at appium1.InstallApp.main(InstallApp.java:43)
hi
ReplyDeleteI have faced the error, while launching the amazon apk files.
my code
package appium;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.remote.AndroidMobileCapabilityType;
import io.appium.java_client.remote.MobileCapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
public class InstallApp {
static AndroidDriver driver;
public static void main(String[] args)throws MalformedURLException {
File app = new File("D:/Apk", "amazon.apk");
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability(MobileCapabilityType.DEVICE_NAME, "0797818a87d4f5cb");
cap.setCapability(MobileCapabilityType.VERSION, "8.0");
cap.setCapability(MobileCapabilityType.PLATFORM_NAME, "Android");
cap.setCapability("app", app.getAbsolutePath());
cap.setCapability(AndroidMobileCapabilityType.APP_PACKAGE,"appium");
cap.setCapability(AndroidMobileCapabilityType.APP_ACTIVITY,"com.amazon.mShop.home.HomeActivity");
driver = new AndroidDriver(new URL("http://localhost:4723/wd/hub"), cap);
//driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
}
}
Amazon is restricting to automate.
ReplyDelete