I have to scroll on a specific character on the screen. Can anybody help me out?
created
Aug '17
last reply
Feb '19
- 21
replies
- 1.3k
views
- 7
users
- 4
links
I have to scroll on a specific character on the screen. Can anybody help me out?
@jitenderbhardwaj you mean e.g. with input text string like “Test” put cursor into between “e” and “s” for example?
@Aleksei
Actually, it a date picker and i need to scroll it up in order to choose the date and time.
I tried with all other possible ways but didn’t get succeed.
The only way left is to scroll on the point where the date selector is present.
@jitenderbhardwaj send screenshot of your day picker to easier understand everyone
@Aleksei
The marked area is the date picker.
Here is the screenshot:-
@jitenderbhardwaj aga! so you have custom picker. did you try just tap up/down and check picker value?
@jitenderbhardwaj no i mean e.g. tap on “WED Aug 23” and check that current value changed correctly to same?
@Aleksei Tried but not working!
@jitenderbhardwaj can you be more specific please? what not working? you cant tap? not changing visually value? not changing value in code?
@jitenderbhardwaj so we have problem in tap can you share pageSource to check at https://gist.github.com/4 ? you can hide all your specific in it just leave ids and whole structure.
@jitenderbhardwaj your tap code script itself will be usefull but we need:
System.out.println(driver.getPageSource())
on this screen to see it elements.
I have added the page source file. And here is the URL:- https://gist.github.com/anonymous/4dfbf7037d8f4040702fa5e769c19ef38
@jitenderbhardwaj here is code to try:
Page object itself:
package com.zzzzz.pages.android;
import com.zzzz.base.Page;
import io.appium.java_client.MobileDriver;
import io.appium.java_client.MobileElement;
import io.appium.java_client.TouchAction;
import io.appium.java_client.android.AndroidElement;
import io.appium.java_client.pagefactory.AndroidFindBy;
import io.appium.java_client.pagefactory.HowToUseLocators;
import io.appium.java_client.pagefactory.LocatorGroupStrategy;
import org.openqa.selenium.WebDriver;
import java.time.Duration;
import java.util.List;
public class TestPage extends Page {
@HowToUseLocators(androidAutomation = LocatorGroupStrategy.CHAIN)
@AndroidFindBy(id = "picker_container")
@AndroidFindBy(id = "numberpicker_input")
private List<AndroidElement> pickerInputs;
@HowToUseLocators(androidAutomation = LocatorGroupStrategy.CHAIN)
@AndroidFindBy(id = "picker_container")
@AndroidFindBy(className = "android.widget.Button")
private List<AndroidElement> pickerButtons;
public TestPage(WebDriver driver) {
super(driver);
}
public boolean tapPickerButton(int num) {
System.out.println(" tapPickerButton(): " + num);
return tapElement(pickerButtons.get(num));
}
public String getPickerInputValue(int num) {
System.out.println(" getPickerInputValue(): " + num);
return pickerInputs.get(num).getText();
}
public boolean setPickerInputValue(int num, String input) {
System.out.println(" getPickerInputValue(): " + num);
try {
pickerInputs.get(num).setValue(input);
return true;
} catch (Exception e) {
// picker input num NOT found
return false;
}
}
public boolean tapElement(MobileElement element) {
try {
new TouchAction((MobileDriver) driver).press(element).waitAction(Duration.ofMillis(70)).release().perform();
return true;
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
}
now test code itself:
TestPage testPage = new testPage(driver);
System.out.println("First picker value is: " + testPage.getPickerInputValue(1));
assertTrue("some error text", testPage.tapPickerButton(1));
System.out.println("First picker value changed to: " + testPage.getPickerInputValue(1));
@Cihangir_Tuna I don’t have to pass static text, i want to scroll two to three values down. how to achieve that?