I am trying to scroll to element which is not visible on screen
The following code i am using
WebElement abc = driver.findElement(By.id(“elemnt1”));
int x = abc.getLocation().getX();
int y = abc.getLocation().getY();
TouchAction action = new TouchAction((MobileDriver) driver);
action.press(x,y).moveTo(x+90,y).release().perform();
the sample code says
TouchAction action = new TouchAction(performsTouchActions); action.press(element).waitAction(300).moveTo(element1).release().perform();
I am getting this exception
java.lang.IllegalArgumentException: The class org.openqa.selenium.remote.RemoteWebDriver of the given context doesn’t implement io.appium.java_client.FindsByAndroidUIAutomator nor io.appium.java_client.FindsByFluentSelector. Sorry. It is impossible to find something.
for the code
WebElement abc = driver.findElement(MobileBy.AndroidUIAutomator(“new UiScrollable(” + scrollViewContainer_finder + “)” +
“.scrollIntoView(” + neededElement_finder + “)”));
I got this error
java.lang.IllegalArgumentException: The class org.openqa.selenium.remote.RemoteWebDriver of the given context doesn’t implement io.appium.java_client.FindsByAndroidUIAutomator nor io.appium.java_client.FindsByFluentSelector. Sorry. It is impossible to find something.
for the code
WebElement el = driver.findElement(MobileBy.AndroidUIAutomator(“new UiSelector().resourceIdMatches(”.*id/title_vungle")"));
Thanks for your help let me explain what i really want
I have textview element (Not list view item) which is not visible . It is visible only when i swipe/scroll up. I am unable to click it as it is not visible. How can i scroll up and click on that item
Please explain me how can i scroll to that item and click it
Also if you can provide full code/ class it will be great help
first approach is use UiSelector which is not working with your config by some reason (you still did not write anything about your appium version and java-client version).
second is your first approach when you scroll and check… scroll and check.
Sorry for late reply please find my total code
My java version 1.8 ( I am using android studio jdk)
appium version 1.6.5 (appium -v)
i am trying to click using
driver.findElement(By.id(“com.appredeem.apptrailers:id/textview5”)).click();
but it is not in mobile screen it is only visible once i scroll to bottom
the code
public class AppTrailersTest {
WebDriver driver;
long minute_delay = 60000 ;
AppiumServerJava appiumServerJava;
@Before
public void setUp() throws MalformedURLException {
appiumServerJava = new AppiumServerJava();
// start appium appiumServer
appiumServerJava.startServer();
// Created object of DesiredCapabilities class.
DesiredCapabilities capabilities = new DesiredCapabilities();
// Set android deviceName desired capability. Set your device name.
capabilities.setCapability("deviceName", "LC51GY642544");
// capabilities.setCapability("deviceName", "V20270160320032782");
// Set BROWSER_NAME desired capability. It's Android in our case here.
capabilities.setCapability(CapabilityType.BROWSER_NAME, "Android");
// Set android VERSION desired capability. Set your mobile device's OS version.
capabilities.setCapability(CapabilityType.VERSION, "4.4.2");
// Set android platformName desired capability. It's Android in our case here.
capabilities.setCapability("platformName", "Android");
// this willnot delet app data and app registration details
capabilities.setCapability("noReset", "true");
// set timeout to 5minutes
capabilities.setCapability("newCommandTimeout", 300);
// Set android appPackage desired capability. It is
// com.android.calculator2 for calculator application.
// Set your application's appPackage if you are using any other app.
// capabilities.setCapability("appPackage", "com.google.android.calculator");
capabilities.setCapability("appPackage", "com.appredeem.apptrailers");
// Set android appActivity desired capability. It is
// com.android.calculator2.Calculator for calculator application.
// Set your application's appPackage if you are using any other app.
// capabilities.setCapability("appActivity", "com.google.android.calculator.Calculator");
capabilities.setCapability("appActivity", "com.appredeem.apptrailers.AppTrailers");
// Created object of RemoteWebDriver will all set capabilities.
// Set appium server address and port number in URL string.
// It will launch calculator app in android device.
driver = new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
driver.manage().timeouts().implicitlyWait(150, TimeUnit.SECONDS);
}
@Test
public void testFirstCalculator() {
driver.findElement(By.id("com.appredeem.apptrailers:id/textview5")).click();
driver.manage().timeouts().implicitlyWait(15,TimeUnit.SECONDS);
}
@After
public void End() {
// driver.manage().timeouts().wait(300,TimeUnit.SECONDS);
// driver.quit();
try {
Thread.sleep(minute_delay * 5);
}catch(Exception e) {
e.printStackTrace();
}
driver.quit();
appiumServerJava.stopServer();
}
Hi @Aleksei, any idea if this works on horizontal scroll? I tried it on a horizontal scroll where it didn’t work. But the same logic worked when I used it on a vertical scroll.
While trying to use it on a horizontal scroll, it tried to scroll it vertically rather than horizontally.
I have textview element (Not list view item) which is not visible . It is visible only when i swipe/scroll up. I am unable to click it as it is not visible. How can i scroll up and click on that item
Please explain me how can i scroll to that item and click it.
Appium 1.7.1
java 1.8.0
My framework is Serenity based POM model
I am using below code : @AndroidFindBy(uiAutomator=“new UiScrollable(new UiSelector()).scrollIntoView(text(” NPO3"));")
private WebElement scrollUntillDisneyChannel;
Hi, @Aleksei
I am familiarising myself with UiSelector and UiScrollable and at this point it seems like this approach is great when you know some element is there for sure. When you are not sure about the state (or content of ListView), you are just forced to scroll and check using TouchAction which is tedious. I wonder if there is any trick available to scroll the whole ListView or RecyclerView to get it’s content? So far, I am not sure it’s possible since I can get only elements visible on the screen. Do you have any thoughts or workarounds on how to get content of ListView not displayed on screen ?