Screen Scolling For find the Element in Appium.

int loop_terminateCount = 0;
int element_number = 0;
int task_totalCount = 0;
ArrayList tasks_data = new ArrayList();

task_iterate_loop:
while (true){
for (int i = 0; i < 15; i++) {
if(driver .findElements(By.xpath(“//android.widget.RelativeLayout[@index=”+
element_number+”]//android.widget.TextView[@index=0]”)).size() != 0 &&
driver.findElements(By.xpath(“//android.widget.RelativeLayout[@index=”+
element_number+”]//android.widget.TextView[@index=1]”)).size() != 0 &&
driver.findElements(By.xpath(“//android.widget.RelativeLayout[@index=”+
element_number+”]//android.widget.TextView[@index=2]”)).size() != 0){
String ticket_subject_Stext = driver .findElement(By.xpath(“//android.widget.RelativeLayout[@index=”+
element_number+”]//android.widget.TextView[@index=0]”)).getText();
String ticket_details_Stext = driver.findElement(By.xpath(“//android.widget.RelativeLayout[@index=”+
element_number+”]//android.widget.TextView[@index=1]”)).getText();
String ticket_date_Stext = driver .findElement(By.xpath(“//android.widget.RelativeLayout[@index=”+
element_number+”]/android.widget.TextView[@index=2]”)).getText();
String tasks_fullText = ticket_subject_Stext+”~”+ticket_details_Stext+”~”+ticket_date_Stext;
System.out.println(element_number+” : >>>>>>>>>>>>>>”+tasks_fullText);
if(!tasks_data.contains(tasks_fullText)){
tasks_data.add(tasks_fullText);
loop_terminateCount = 0;
}else {
loop_terminateCount = loop_terminateCount + 1;
}
if(loop_terminateCount == 15) break task_iterate_loop;
element_number = element_number + 1;
}else{
element_number = 0;
/*Dimension size = driver.manage().window().getSize();
int starty = (int) (size.height * 0.70);
int endy = (int) (size.height * 0.30);
int startx = size.width / 2;
driver.swipe(startx, starty, startx, endy, 300);
Thread.sleep(5000); */
intelliwiz_funObj.scrollUp(driver, 300);
}
}
}

System.out.println(“Task Count >>>>>>>>>>>>> : “+tasks_data.size());
for (int i = 0; i < tasks_data.size(); i++) {
System.out.println(i+” >>>>>: Task Details >>>>>>>>>>>>> : “+tasks_data.get(i).toString());
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s