Nowadays Automation has grown so much, that even working in an environment of just ‘Manual Testing‘, it’s really important to ensure and improve the testing process to include a percentage of ‘Automation‘.
It’s important to mention that there’s impossible to cover 100 % of Automated Test Cases because automation has its limits like the abilities and knowledge about coding in a language programming of the Testers, the most used are Java, Python, and JavaScript, which not all actual Testers have.
Another important key is that not all the types of testing are able to automate like look and feel test.
So to keep it simple, if you want to automate a test you have to take the following points at least to start automating:
1. There are Regression Test Cases that you need to run always before a release.
2. There are flows that are just too large but also repetitive.
3. The scope of the Company is implement Continuous Integration (CI).
There are a lot of automation tools for different platforms like Android, IOS, and Web, but also for different scopes like Selenium, Mocha, Jazmine and Espresso.
Let’s start with Mobile (Android & IOS) using Selenium and TestNG with Java.
Create a Maven Project in Eclipse
For the next example, we’ll be using Eclipse as IDE and Maven of libraries management.
1. Create a Maven Project, it’ll look something like this.
2. In Folder “src/main/java“, create the packages “example.enviroment“, “example.pages” “example.test.base” and “example.pages.base“. This packages will contain our code.
3. Now let’s create the class “Setup” for the package “example.environment“, the class “BasePage” for the package “example.pages.base” and the class “BaseTest” for the package “example.test.base”.
4. It’s necessary to add de dependencies to the “pom.xml” file.
5. In Setup class we create de AppiumDriver that will interact with the device and our test.
6. Let’s use ADB to obtain the previous capabilities.
Create our First Test using TestNg
1. In class “BaseTest” we are going to call our driver (Setup class) each time a test is executed that’s why it is going to be called in BaseTest is going to be base for all the tests. With the tag @BeforeMethod, we assure that the Setup class and its method are always called before our tests. Also with the tag @AfterMethod we are going to set the close of the objects open, each time a test finishes. The tag @Parameters is going to help us to send the values from the xml file of TestNG.
2. Now let’s run Appiumto inspect the elements of our app.
3. Let’s click “Start inspection Session“.
4. Insert the next capabilities, click the button “Start Session“, and then we’ll see the app main activity, in this example the “Radio app“.
5. This main activity it’s going to be the “Principal Page“.
6. Let’s inspect and get the locators of the elements of “Principal Page“.
7. Now let’s create our methods in the class “PrincipalPage“, create a package called “example.pages.java” and the class “PrincipalPage“.
8. Let’s define the actions in BasePage.
9. Let’s create the last package where our Test Suites will be called as package “example.test.java” and class “FirstTest“.
10. The main test script resides in FirstTest.
11. Finally, let’s create the “PossitiveTests.xml” that TestNG will use to execute the tests and also is where the input parameters are defined.
Any help is welcome to help us keeping this effort alive!PayPal AccountBTC (Bech32): bc1qx6f8nczr5ram6d57svlnsfmk5mhu6lsr9q7mxw BTC: 1DDcWbphm1bKMvWruotNKLSM8ypVaHg5Nv ETH: 0x58D137fb142D946bCD815f0ded0fa3b3fE5AB3BF
Angélica Viridiana Rebolloza
Computing Engineer specialized in Automation, working with different tools for Mobile and Web, using languages, tools, and platforms like JAVA, VBScript, JavaScript, C#, Appium, Protractor, UFT (QTP), Selenium, WinAppDriver, Jenkins among others.
Viridiana also has been working using practices like TDD & BDD under Cascade and Agile approaches.
Some certifications include: ISTQB Foundations Certification, SeU Selenium Certified, ITIL Foundations Certification.
Hello Luis, I’ve just added the code of BaseTest.java to the entry, it’s at the beginning of the entry, please feel free to contact me again if you have some more issues.
I can not finish the example because I can not see the code of the class BaseTest.Java, could you please send it to me?
Hello Luis, I’ve just added the code of BaseTest.java to the entry, it’s at the beginning of the entry, please feel free to contact me again if you have some more issues.