page scroll is not happening appium java client

Viewed 258

I am doing automation mobile testing for my application .In login page after entering username & password,keyboard pops up and blocks everything down in the screen . So it's throws An element could not be located on the page using the given search parameters org.openqa.selenium.NoSuchElementException: To Enable scroll or screen touch i had tried many ways .

1)
WebElement element1 = driver.findElement(MobileBy.AccessibilityId("btnLogin"));
      int x = element1.getLocation().getX();
      int y = element1.getLocation().getY();
    TouchAction action = new TouchAction((PerformsTouchActions) driver);
   action.press(x,y).moveTo(x,y-90).release().perform();
    
    2)
    WebElement element1 = driver.findElement(MobileBy.AccessibilityId("btnLogin"));
   ((JavascriptExecutor)driver).executeScript("arguments[0].scrollIntoView(true);",element1);
    
    3)
    
     TouchAction action = new TouchAction((PerformsTouchActions) driver);
   WebElement element1 = driver.findElement(MobileBy.AccessibilityId("com.a.b:id/imageView"));
   WebElement element2 = driver.findElement(MobileBy.AccessibilityId("com.a.b:id/btnLogin"));
   action.press(element1).moveTo(element2).release();
    
    4)
    JavascriptExecutor js = (JavascriptExecutor) driver;
   HashMap<String, String> scrollObject = new HashMap<String, String>();
   scrollObject.put("direction", "up");
   scrollObject.put("element", "btnLogin");
   js.executeScript("mobile: scroll", scrollObject);
    
    5)
    ((AndroidDriver) driver).context("NATIVE_APP");
   WebElement element = driver.findElementById("btnLogin");
   int x = element.getSize().getWidth();
    int xEnd = 0;
   int yStart = element.getSize().getHeight()/2;
   ((AndroidDriver) driver).swipe(x, yStart, xEnd, yStart, 500);

I am not able to resolve this issue .. can you please suggest me with some sample code to resolve this problem .

2 Answers
Related