Plz provide me possible number of alternatives to scroll down android screen up and down without using swipe method and touch action class. I am not able to perform scroll feature in android app version 21. Below is my code.
package com.raaga.demo;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.Test;
import io.appium.java_client.TouchAction;
import io.appium.java_client.android.AndroidDriver;
public class MainTest {
private AndroidDriver<WebElement> driver;
@Test
public void setUp() {
File apkFile = new File("./Raaga.apk");
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability("platform", "Android");
cap.setCapability("deviceName", "Andriod Device");
cap.setCapability("app", apkFile.getAbsolutePath());
cap.setCapability("commandTimeOut", "2*60");
cap.setCapability("appPackage", "com.raaga.android");
cap.setCapability("appActivity", "com.raaga.android.SplashScreen");
try {
driver = new AndroidDriver<WebElement>(new URL("http://ift.tt/1sv2im4"), cap);
} catch (MalformedURLException e) {
e.printStackTrace();
}
try {
driver.manage().timeouts().implicitlyWait(90, TimeUnit.SECONDS);
driver.findElement(By.id("com.raaga.android:id/skip_text")).click();
driver.findElementById("com.raaga.android:id/landing_skip_to_raaga").click();
List<WebElement> ele = driver.findElements(By.className("android.widget.TextView"));
System.out.println(ele.size());
System.out.println(ele.get(1).getText());
ele.get(1).click();
driver.findElementById("com.raaga.android:id/toolbar_logo").click();
System.out.println(driver.findElementById("com.raaga.android:id/menu_music_btn").getSize());
driver.findElementById("com.raaga.android:id/menu_music_btn").click();
System.out.println(driver.findElementById("com.raaga.android:id/slidingmenumain").getSize());
System.out.println(driver.getCapabilities());
Thread.sleep(30000);
// driver.findElement(MobileBy.AndroidUIAutomator("new UiSelector().text()"));
TouchAction ac=new TouchAction(driver);
ac.moveTo(driver.findElement(By.id("com.raaga.android:id/artists_radio_lay1"))).release().perform();
// Boolean result = driver.findElement(By.xpath("//android.widget.TextView[@index='0']")).isDisplayed();
// while (result) {
// driver.swipe(0, 853, 0, 122, 2000);
// if (result==true) {
//
// break;
// }
//
// }
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
Below is the dependency which i used in my project pom.xml file
<project xmlns="http://ift.tt/IH78KX" xmlns:xsi="http://ift.tt/ra1lAU"
xsi:schemaLocation="http://ift.tt/IH78KX http://ift.tt/VE5zRx">
<modelVersion>4.0.0</modelVersion>
<groupId>com.demo</groupId>
<artifactId>RagaAppTesting</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<!-- http://ift.tt/2nt4wbA -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>3.3.1</version>
</dependency>
<!-- http://ift.tt/2aikwdt -->
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20160810</version>
</dependency>
<!-- http://ift.tt/293xQwD -->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>20.0</version>
</dependency>
<dependency>
<groupId>io.appium</groupId>
<artifactId>java-client</artifactId>
<version>5.0.0-BETA7</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.9.10</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Aucun commentaire:
Enregistrer un commentaire