Appium Tutorials

Different way to Scroll in Appium in Android and IOS devices.

Welcome back to Appium tutorials in this post we will discuss how to scroll in Appium.

Recently I got an application where I had to scroll down to click on that element.

I have worked on web application automation extensively so I used to do with JavaScript Executor.

If you have never used Java Script Executor then I would highly recommend to check below the article.

Java Script usage in Selenium

It helped me for Highlighting elements, Scroll into View, Scroll pages and so on.

 

But I become helpless when I switched to Mobile application because above methods were not working for me.

 

Methods for Scroll in Appium

I did some googling and found that AndroidDriver class has inbuilt method which performs scroll till the element not found.

Please check the Appium reference where you can find multiple articles on Appium

Complete Appium guide for IOS and Android

 

Please check below Screenshot.

 

First Method-

As you can see the description this will scroll until element not found with text.

Scroll in Appium

 

 

Second Method

This method also will perform scroll method but this will search for exact text for scrolling.

 

Scroll in Appium

Program for Scroll in Appium

public class TestHybrid5 
{

	private static AndroidDriver driver;
	 
	public static void main(String[] args) throws MalformedURLException, InterruptedException 
	{
	 
	 
	File classpathRoot = new File(System.getProperty("user.dir"));
		
	File appDir = new File(classpathRoot,"/app");
	
	File app = new File(appDir,"appname.apk");

	
	 // Create object of DesiredCapabilities class                             
	 
	DesiredCapabilities capabilities = new DesiredCapabilities();
	 
	capabilities.setCapability("app", app.getAbsolutePath());
	 
	// Optional
	 
	capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
	 
	 
	// Specify the device name (any name)
	 
	capabilities.setCapability("deviceName", "My New Phone");
	 
	 
	// Platform version
	 
	capabilities.setCapability("platformVersion", "6.0");
	 
	 
	// platform name
	 
	capabilities.setCapability("platformName", "Android");
	 
	 
	// specify the application package that we copied from appium                
	
	capabilities.setCapability("appPackage", "app Package name");
	 
	 
	// specify the application activity that we copied from appium                   
	capabilities.setCapability("appActivity", "specify the activity here");
	 
	 
	// Start android driver default it will be 4723
	 
	driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
	 
	 
	// Specify the implicit wait of 5 second
	 
	driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
	 
	
	// scrollTo("") this method will scroll automatically until specific text is not matching.
        // We have two methods so depends on your requirement you can use accordingly.
	driver.scrollTo("SAVE");
	
	driver.findElement(By.id("app_id_screen_save_button")).click();
	
	
	
	 
	}
}

 

This is very small article but a very helpful. Try from your side and let me know if an issue in Appium.

Recently I launched blog for discussion http://forumsforqa.com/

 

author-avatar

About Mukesh Otwani

I am Mukesh Otwani working professional in a beautiful city Bangalore India. I completed by BE from RGPV university Bhopal. I have passion towards automation testing since couple of years I started with Selenium then I got chance to work with other tools like Maven, Ant, Git, GitHub, Jenkins, Sikuli, Selenium Builder etc.

104 thoughts on “Different way to Scroll in Appium in Android and IOS devices.

  1. Biswa bhusan Mishra says:

    Nice One Mukesh..Waiting to see some advanced action related script.

    1. Sure Biswa will upload soon

  2. Mukesh Otwani says:

    Test Comment

  3. Mukesh Otwani says:

    Test Comment

  4. Mukesh Otwani says:

    Test Comment

  5. Mukesh Otwani says:

    Test Comment

  6. Mukesh Otwani says:

    Test Comment

  7. Mukesh Otwani says:

    Test Comment

  8. Mukesh Otwani says:

    Test Comment

  9. Mukesh Otwani says:

    Test Comment

  10. Mukesh Otwani says:

    Test Comment

  11. Mukesh Otwani says:

    Test Comment

  12. Mukesh Otwani says:

    Test Comment

  13. Mukesh Otwani says:

    Test Comment

  14. Mukesh Otwani says:

    Test Comment

  15. Mukesh Otwani says:

    Test Comment

  16. Mukesh Otwani says:

    Test Comment

  17. Mukesh Otwani says:

    Test Comment

  18. Mukesh Otwani says:

    Test Comment

  19. Mukesh Otwani says:

    Test Comment

  20. Mukesh Otwani says:

    Test Comment

  21. Mukesh Otwani says:

    Test Comment

  22. Mukesh Otwani says:

    Test Comment

  23. Mukesh Otwani says:

    Test Comment

  24. Mukesh Otwani says:

    Test Comment

  25. Mukesh Otwani says:

    Test Comment

  26. Mukesh Otwani says:

    Test Comment

  27. Mukesh Otwani says:

    Test Comment

  28. Mukesh Otwani says:

    Test Comment

  29. Mukesh Otwani says:

    Test Comment

  30. Mukesh Otwani says:

    Test Comment

  31. Mukesh Otwani says:

    Test Comment

  32. Mukesh Otwani says:

    Test Comment

  33. Mukesh Otwani says:

    Test Comment

  34. Mukesh Otwani says:

    Test Comment

  35. Mukesh Otwani says:

    Test Comment

  36. Mukesh Otwani says:

    Test Comment

  37. Mukesh Otwani says:

    Test Comment

  38. Mukesh Otwani says:

    Test Comment

  39. Mukesh Otwani says:

    Test Comment

  40. Mukesh Otwani says:

    Test Comment

  41. Mukesh Otwani says:

    Test Comment

  42. Mukesh Otwani says:

    Test Comment

  43. Mukesh Otwani says:

    Test Comment

  44. Mukesh Otwani says:

    Test Comment

  45. Mukesh Otwani says:

    Test Comment

  46. Mukesh Otwani says:

    Test Comment

  47. Mukesh Otwani says:

    Test Comment

  48. Mukesh Otwani says:

    Test Comment

  49. Mukesh Otwani says:

    Test Comment

  50. Mukesh Otwani says:

    Test Comment

  51. Mukesh Otwani says:

    Test Comment

  52. Mukesh Otwani says:

    Test Comment

  53. Mukesh Otwani says:

    Test Comment

  54. Mukesh Otwani says:

    Test Comment

  55. Mukesh Otwani says:

    Test Comment

  56. Mukesh Otwani says:

    Test Comment

  57. Mukesh Otwani says:

    Test Comment

  58. Mukesh Otwani says:

    Test Comment

  59. Mukesh Otwani says:

    Test Comment

  60. Mukesh Otwani says:

    Test Comment

  61. Mukesh Otwani says:

    Test Comment

  62. Mukesh Otwani says:

    Test Comment

  63. Mukesh Otwani says:

    Test Comment

  64. Mukesh Otwani says:

    Test Comment

  65. Mukesh Otwani says:

    Test Comment

  66. Mukesh Otwani says:

    Test Comment

  67. Mukesh Otwani says:

    Test Comment

  68. Mukesh Otwani says:

    Test Comment

  69. Mukesh Otwani says:

    Test Comment

  70. Mukesh Otwani says:

    Test Comment

  71. Mukesh Otwani says:

    Test Comment

  72. Mukesh Otwani says:

    Test Comment

  73. Mukesh Otwani says:

    Test Comment

  74. Mukesh Otwani says:

    Test Comment

  75. Mukesh Otwani says:

    Test Comment

  76. Mukesh Otwani says:

    Test Comment

  77. Mukesh Otwani says:

    Test Comment

  78. Mukesh Otwani says:

    Test Comment

  79. Mukesh Otwani says:

    Test Comment

  80. Mukesh Otwani says:

    Test Comment

  81. Mukesh Otwani says:

    Test Comment

  82. Mukesh Otwani says:

    Test Comment

  83. Mukesh Otwani says:

    Test Comment

  84. Mukesh Otwani says:

    Test Comment

  85. Mukesh Otwani says:

    Test Comment

  86. Mukesh Otwani says:

    Test Comment

  87. Mukesh Otwani says:

    Test Comment

  88. Mukesh Otwani says:

    Test Comment

  89. Mukesh Otwani says:

    Test Comment

  90. Mukesh Otwani says:

    Test Comment

  91. Mukesh Otwani says:

    Test Comment

  92. Mukesh Otwani says:

    Test Comment

  93. Mukesh Otwani says:

    Test Comment

  94. Mukesh Otwani says:

    Test Comment

  95. Mukesh Otwani says:

    Test Comment

  96. Mukesh Otwani says:

    Test Comment

  97. Mukesh Otwani says:

    Test Comment

  98. Mukesh Otwani says:

    Test Comment

  99. Mukesh Otwani says:

    Test Comment

  100. Mukesh Otwani says:

    Test Comment

  101. Selenium learner says:

    Thanks Mukesh Nice post.

    1. Thanks Keep visting.

      1. Tarun Tiwari says:

        Can you please update swipe event on mobile.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.