Automation testing: Selenium + Cucumber – Lesson 3 (First Selenium test)

Automation testing: Selenium + Cucumber – Lesson 3 (First Selenium test)

Hello friends!

Welcome to lesson 3!

Today we will review how to use Cucumber and Selenium wrapped in Automotion library. You will understand that to automate Your project is super easy.

Automotion is powerful Java library for automation testing that allows us easy start WebDriver without configuration of it. Also this library has many helpful features that will be very useful in the future.

Please, read carefully how to use this library here Automotion. It’s very easy but You need to know some instruction at least.

So, let’s start and to see how it goes!

Firstly, let’s remove not needed scenario that we created in previous lesson to keep our project clean. Also rename our feature file, feature name and scenario name.

We will automate Selenium-Cucumber scenario where we will open web-site

https://www.facey.top and verify that main logo exists.

Before the start be sure that You have installed Firefox and Chrome browsers.

To download the latest Chrome driver visit this web-site:

http://chromedriver.storage.googleapis.com/index.html

Also double check that You have in pom.xml dependency to Automotion library.

All next steps You’ll find in video. Have a nice watching!

Now You now how to create Your first Selenium scenario using Cucumber. It’s really easy, isn’t it?

We’re gonna review how to create and use Page Object in our next lesson. Each of the lessons is very important and helps to understand how everything works. Do not forget to practice.

Thanks for watching my lessons!

Have a good automation!

Automation testing: Selenium + Cucumber – Lesson 2 (Advanced usage of Cucumber)

Automation testing: Selenium + Cucumber – Lesson 2 (Advanced usage of Cucumber)

Hello guys!

Welcome to lesson 2!

It’s a very short lesson. Today we will review how to use tables inside of Cucumber scenarios and what are tags and how to use them. Please, do not skip first lessons to avoid any misunderstanding in the future.

So, what we gonna do today.

  • We will modify our scenario to operate not only values 2 and 3, but much more different numbers.
  • We will create another scenario to show You how to use tags in Cucumber scenario

Have a nice watching!

Now You know how to use Cucumber tables scenarios and how tags Your scenarios. In the next lesson we will start to learn how to use Selenium (Automotion) with Cucumber.

Thanks for watching us!

Have a good automation!

Automation testing: Selenium + Cucumber – Lesson 1 (First Maven project and Cucumber scenario)

Automation testing: Selenium + Cucumber – Lesson 1 (First Maven project and Cucumber scenario)

Hello friends!

It’s a first lesson from the tutorial of how to create new project for automation testing based on Selenium, Automotion and Cucumber.

Preparation of environment

Before starting creation of a new project You need:

1. Download and install IDEA IntelliJ. Community version will be enough.

2. Download and install Java 1.8 JDK latest version. For Windows – setup Env variables for Java home:

  1. Right click on ‘My Computers’ and open ‘Properties’.
  2. In Windows Vista or Windows 7, go to “Advanced System Settings”. …
  3. Go to ‘Advanced Tab’ and click on Environment Variables button.
  4. Select ‘Path’ under the list of ‘System Variables’, and press Edit and add C:\Program Files\java\jdk{version}\bin after a semicolon.

3. Download and install Maven 3. For Windows – setup Env variables. Detailed description is here:

https://www.mkyong.com/maven/how-to-install-maven-in-windows/

To verify that everything is installed correctly You need:

  • for JAVA: open Terminal and type “java -version”. Output should display version of Java installed on Your computer
  • for Maven – open Terminal and type “mvn” and press enter. You need to see in output some dummy build process.

Installing of additional plugins

After You have installed IDEA IntelliJ You need to install additional plugins for IDEA. There are:

1. Cucumber for Java. This plugin will be required to bind Cucumber feature file (scenarios) with Java code.

2. Pipe Table Formatter. This plugin will be required to format tables in Cucumber scenarios.

How to install plugins: Go to IDEA Settings -> Plugins. Click on “Browse repositories…”. Type plugin name and click on green button “Install”. After installing both plugins You need to restart IDEA to activate the plugins.

Creating new project

Ok, now we are ready to start the creation of our first project.

Please, create new project. If You don’t have any projects in IDEA – run IDEA IntelliJ and click on Create new project like on the picture:

screen-shot-2016-10-15-at-11-21-58

If You have already opened IDEA with some projects – follow steps from this picture:

screen-shot-2016-10-15-at-11-23-59

Please, watch next video with detailed tutorial of how to create Maven project, build Maven pom.xml (configuration file for Maven project) and create first Java classes for test running.

Also how to create first Cucumber scenario and run it successfully.

Have a nice watching!

Now You know how to setup environment for automation testing, how to create Your first Maven project and Cucumber scenario. In the next lesson we will review how to use tables in Cucumber scenarios and what are tags and how to use them.

Thanks for watching us!

Have a good automation!

Automotion – final realease

Automotion – final realease

Hello,

I’m very glad to announce that Automotion library is finally released to the central Maven repository http://search.maven.org/#search|ga|1|automotion

Simply add it to the project as a maven dependency:

<dependency>

    <groupId>net.itarray</groupId>

    <artifactId>automotion</artifactId>

    <version>1.2.0</version>

</dependency>

Also You can contribute to the project on GitHub

Read about latest updates of Automotion library on ITArray

Have a good automation!

Advanced usage of Cucumber or Automotion multidriver scenarios

Advanced usage of Cucumber or Automotion multidriver scenarios

Hello guys,

How many times we had a discussion regarding what type of driver is better to use: headless PhantomJSDriver, local WebDriver or RemoteWebdriver.
Now it’s possible to make a configuration of Your project using Cucumber and Automotion library.
Here  is example of Maven project. There are 4 Cucumber feature files that will run the same test scenarios using different drivers: FirefoxDriver, Remote Chrome Driver, Remote Chrome Driver with mobile emulation of iPhone 6 and headless PhantomJSDriver.

Also there is example of how to perform the smart verification that web page has correct language using Automotion.

To run the tests – simply clone the project and run the test_run.sh file.

Thank You for Your attention and as always – have a good testing!

 

Verification of email boxes as a part of automation testing

Verification of email boxes as a part of automation testing

Greetings!

In this article I would like to show some example of how to check email boxes in automation testing using Java instruments.
So, let’s think about how many times You had to develop test scenarios of user registration, activation using Selenium or Appium. And in 90% it’s very important to verify e-mail box that welcome message is received or something like this. Usually engineers use services like Mailinator or similar to check the mailbox. But such services are not free. And not secure.

I will show how to check even private Gmail box in automation testing using IMAP protocol. The main instrument is native java library javax.mail.*

1. Implement login

public void login(String host, int port, String username, String password) throws Exception {
            String fName = getFolderName(folderName);
            URLName url = new URLName(protocol, host, port, fName, username, password);

            if (session == null) {
                        Properties props = null;
                        try {
                                   props = System.getProperties();
                        } catch (SecurityException sex) {
                                   props = new Properties();
                        }
                        session = Session.getInstance(props, null);
             }
             store = session.getStore(url);
             store.connect();
             folder = store.getFolder(url);

            folder.open(Folder.READ_WRITE);
 }
2. Get messages

public Message[] getMessages() throws MessagingException {
             return folder.getMessages();
}

Also it’s possible to verify if user is connected, possible to logout from the session.
The wrapper for using of such mail services  is implemented in Automotion library

The methods that could be accessible from the code are:

MailService mailService = new MailService();
mailService
           .setFolder(MailService.MailFolder.INBOX) // (INBOX, SPAM, TRASH)
           .login(String IMAP_Server, int IMAP_Port, String email, String passwordToEmail);

mailService.isLoggedIn()) - boolean
mailService.getMessageCount() - integer
mailService.getMessages() - Message[]
mailService.getLastMessage() - Message - last message

Now You know how to perform the verification that email was successfully sent and received.

Thanks for reading my articles! Have a good automation!