@VikramVI
Hi Vikram,
I tried the above solution shared by you, however I am getting error: Method has not yet been implemented.
I have updated the appium client files as well as selenium client files to the latest but still I am getting the same error.
I have restarted the Eclipse and appium after adding the jar files.
Below is my source code and please help to resolve this issue:
public class Browse {
AndroidDriver dr;
Dimension size;
@BeforeTest
public void loadsettings() throws MalformedURLException
{
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability(MobileCapabilityType.PLATFORM_NAME,"Android");
cap.setCapability(MobileCapabilityType.PLATFORM_VERSION, "7.0");
cap.setCapability(MobileCapabilityType.DEVICE_NAME, "MOTO C Plus");
cap.setCapability("appPackage", "com.motorola.launcher3");
cap.setCapability("appActivity", "com.android.launcher3.GoogleNowPanel");
dr = new AndroidDriver (new URL("http://127.0.0.1:4723/wd/hub"), cap );
}
@Test (priority=1)
public void run() throws InterruptedException
{
size=dr.manage().window().getSize();
System.out.println(size);
//to find the start point of the screen
int starty= (int)(size.height * 0.80);
//to find the end point of the screen
int endy= (int)(size.height * 0.10);
int startx = size.width / 2;
int endx=0;
TouchAction action = new TouchAction((MobileDriver)dr);
WebElement e1= (WebElement)dr.findElement(By.id("all_apps_handle"));
action.longPress(e1).moveTo(startx, endy).release().perform();
}
@Test (priority=2)
public void browsepage() throws InterruptedException
{
WebDriverWait wait = new WebDriverWait(dr, 500);
dr.findElementByAccessibilityId("Chrome").click();
wait.until(ExpectedConditions.elementToBeClickable(By.id("com.android.chrome:id/url_bar"))).sendKeys("https://amazon.in");
dr.pressKeyCode(AndroidKeyCode.KEYCODE_NUMPAD_ENTER );
//Store current window handle
String winHandleBefore = dr.getWindowHandle();
TouchAction action = new TouchAction((MobileDriver)dr);
size=dr.manage().window().getSize();
int starty= (int)(size.height * 0.80);
int endy= (int)(size.height * 0.10);
int startx = size.width / 2;
int endx=0;
//TouchAction action = new TouchAction((MobileDriver)dr);
WebElement e2= (WebElement)dr.findElementByClassName("android.view.View");
action.press(e2).moveTo(startx, endy).release().perform();
Thread.sleep(3000);
action.press(e2).moveTo(endy, starty).release().perform();
wait.until(ExpectedConditions.elementToBeClickable(By.id("com.android.chrome:id/tab_switcher_button"))).click();
wait.until(ExpectedConditions.elementToBeClickable(By.id("com.android.chrome:id/new_tab_button"))).click();
wait.until(ExpectedConditions.elementToBeClickable(By.id("com.android.chrome:id/search_box_text"))).sendKeys("yahoo.com");
dr.pressKeyCode(AndroidKeyCode.ENTER);
for(String winHandle : dr.getWindowHandles()){
dr.switchTo().window(winHandle);
}
dr.switchTo().window(winHandleBefore);
}
}
Thank you in advance.