Sunday, 24 April 2016

Setting up selenium webdriver in Android Studio


Now a days almost all web applications have mobile applications and hence testers prefer to write test suits in one common place. We can setup selenium in Android Studio so that we can write and run our mobile application plus web application test suits at one place.The management and execution of test cases becomes very efficient.

If you agree with me and want to know how to setup Selenium in Android Studio then this blog post is for you. Please fallow the steps one by one and you will be able to complete your setup quickly.

Video Tutorial -



Pre-requisites -
2. Java
3. Set ANDROID_HOME and JAVA_HOME

Selenium WebDriver Setup in Android Studio -

1. Download Selenium Webdriver Java Client from This Link. Extract the folder and store all the jars in c:\seleniumjars\


2. Open your Andriod Studio and Click on Create new project 

3. Enter Application Name and Click on Next


4. Then click on Next after selecting Minimum SDK version.


5.  Select Blank Activity and click Next


6. Click on Finish. 


7. Change project structure from Android to Project.


8. Copy the selenium jars to libs folder


9. Select all jars and right click -> click on Add as Library and let it complete the gradle sync successfully.


10. Go to app -> src -> main -> java . Then right click on the package and click on New  -> Java class
Give the class name and click OK


11. Below is the basic selenium test case to open the website in the browser. Copy this code in your java class.


package com.selenium.tests;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class BrowserTests {

 public static void main(String[] args) throws Exception {
  WebDriver driver=new FirefoxDriver();
  driver.get("http://qaautomated.blogspot.in");
  Thread.sleep(3000);
  driver.quit();
 }

}

12. Click on Build Variants on the left side and change Test Artifacts to Unit Test and we are going to are going to write and run junit test.


13. Then right click on your javaclass and click on run.


You can see that Test Case launches firefox browser and opens the given link.  Now you have sucessfully configured Android Studio with Selenium WebDriver and ran your first Test case.

In case if you have any questions or doubts do post in comments. I will try my level best to answer your queries.


Note - Learn More About Android Studio Functionality Usage HERE.

33 comments:

  1. Excellent sharing. Testing is a wonderful field for IT peoples. Want to learn Selenium Training reach GangBoard. Hadoop Training

    ReplyDelete
  2. We have provided the practical training in the real time scenarios. Our trainers have strong knowledge in this field.
    Android Training in Chennai |
    Android Training in Chennai |
    Android Training in Chennai | Android Training in Chennai |

    ReplyDelete
  3. Thanks for this blog. provided great information. All the details are explained clearly with the great explanation. Thanks for this wonderful blog. Step by step processes execution is given clearly.Know the details about the different thing.
    Selenium Training in Chennai | Selenium Course in Chennai | Selenium Testing Training in Chennai

    ReplyDelete
  4. Hi, I am really happy to found such a helpful and fascinating post that is written in well manner. Thanks for sharing such an informative post. keep update your blog. R Programming Online Training

    ReplyDelete
  5. Hi!Thanks for your post. I would like to change my local test for selenium ones but I'm getting an issue that can't resolve:

    Error:Gradle: warning: Ignoring InnerClasses attribute for an anonymous inner class
    Error:Gradle: (org.apache.commons.el.ImplicitObjects$1) that doesn't come with an

    Does someone know how to solve? Thanks!

    PD: I think that I have follow this post correctly

    ReplyDelete
  6. hi welcome to this blog. really you have post an informative blog. it will be really helpful to many peoples. thank you for sharing this blog.
    java training in chennai

    ReplyDelete
  7. The blog gave me idea to setup selenium web driver in android studio Thanks for sharing it
    Selenium Training in Chennai

    ReplyDelete
  8. Wonderful suggestions and guidance thanks a lot for the useful information's.
    python training in chennai

    ReplyDelete
  9. Hi, like you post its more informative and thanks for sharing with us.
    Graphic design course in chennai

    ReplyDelete
  10. Thank you for Sharing. Brave Technologies is a leading low cost erp software solution providers in chennai. For more details call +91 9677025199. cloud erp in Chennai

    ReplyDelete
  11. please share source code android studio .
    thanks

    ReplyDelete
  12. Amazing blog about the various informative information on the programming languages. Java Training in Chennai

    ReplyDelete
  13. I want to shine in a Selenium field, so I am looking the information related to selenium. Your blog really have some more useful information about testing. Keep your blog with testing updates…
    Regards,
    Selenium Training in Chennai
    Dot Net Training in Chennai

    ReplyDelete
  14. You are doing a great job. You inspire me to write for other. Thank you very much. I would like to appreciate your work for good accuracy and got informative knowledge from here. Selenium Training in Chennai

    ReplyDelete
  15. Thanks for posting useful information.You have provided an nice article, Thank you very much for this one. And i hope this will be useful for many people.. and i am waiting for your next post keep on updating these kinds of knowledgeable things...Really it was an awesome article...very interesting to read..
    please sharing like this information......
    Android training in chennai
    Ios training in chennai


    ReplyDelete
  16. Your blog really have some more useful information about testing. Keep your blog with testing updates…
    Regards,
    Selenium Training in Chennai
    Dot Net Training in Chennai

    ReplyDelete


  17. Thanks for posting useful information.You have provided an nice article, Thank you very much for this one. And i hope this will be useful for many people.. and i am waiting for your next post keep on updating these kinds of knowledgeable things...Really it was an awesome article...very interesting to read..
    please sharing like this information......
    Android training in chennai
    Ios training in chennai

    ReplyDelete
  18. It's interesting that many of the bloggers your tips helped to clarify a few things for me as well as giving.. very specific nice content. And tell people specific ways to live their lives.Sometimes you just have to yell at people and give them a good shake to get your point across.
    Web Design Company
    Web Development Company
    Mobile App Development Company

    ReplyDelete
  19. Thanks for such awesome blog. Your article is very easy to understand, informative and provide complete overview about software testing. Keep sharing... want to learn selenium source reach us Selenium Training in Chennai | Software Testing Training in Chennai

    ReplyDelete
  20. Nice it seems to be good post... It will get readers engagement on the article since readers engagement plays an vital role in every blog.. i am expecting more updated posts from your hands.
    Mobile App Development Company

    ReplyDelete
  21. great and nice blog thanks sharing..I just want to say that all the information you have given here is awesome...Thank you very much for this one.
    web design Company
    web development Company
    web design Company in chennai
    web development Company in chennai
    web design Company in India
    web development Company in India

    ReplyDelete
  22. Hi, the information you provided here is very informative and useful for me. If anyone interested to learn Selenium Training in Bangalore.


    Selenium Training in Bangalore

    ReplyDelete
  23. Really cool post, highly informative and professionally written and I am glad to be a visitor of this perfect blog, thank you for this rare info!

    Android Online Training

    ReplyDelete
  24. This comment has been removed by the author.

    ReplyDelete
  25. Excellent blog really Nice article ,thanks for sharing Android Online Training

    ReplyDelete
  26. I have read your blog and i got a very useful and knowledgeable information from your blog.You have done a great job . If anyone want Android Training in Bangalore , Please visit our page Android Training in Bangalore

    ReplyDelete
  27. great and nice blog thanks sharing..I just want to say that all the information you have given here is awesome...Thank you very much for this one.
    web design Company
    web development Company
    web design Company in chennai
    web development Company in chennai
    web design Company in India
    web development Company in India

    ReplyDelete
  28. Everyone wants to get unique place in the IT industry’s for that you need to upgrade your skills, your blog helps me improvise my skill set to get good career, keep sharing your thoughts with us.

    selenium training in bangalore|
    python training in bangalore|

    ReplyDelete
  29. Needed to compose you a very little word to thank you yet again regarding the nice suggestions you’ve contributed here. Besant technologies Marathahalli

    ReplyDelete
  30. I was curious if you ever considered changing the layout of your site? Its very well written; I love what you’ve got to say. But maybe you could a little more in the way of content so people could connect with it better. You’ve got an awful lot of text for only having one or 2 pictures. Maybe you could space it out better?
    <a href="http://www.traininginmarathahalli.in/selenium-training-in-bangalore/”> Selenium Training in Marathahalli </a>|

    ReplyDelete