Automation testing: Selenium + Cucumber – Lesson 4 (Page Object)

Automation testing: Selenium + Cucumber – Lesson 4 (Page Object)

Hello friends!

Welcome to lesson 4!

Today we will have a short lesson and I’m gonna show You one of the ways of how to use Page Object (simple example) with Automotion. There are many different approaches in usage of Page Object and it is hard to say what is better and what is less good. We will use Automotion library to define web elements with fluent waiters correctly. The example that will be showed is based on the web-site https://www.facey.top. We will add 5 elements into our HomePage class. There are: Logo, tabs “NEWEST”, “TOP”, “MY” and footer.

First of all we will create new package “pages” in directory “src/main/java”. Correct naming of the packages is not some strict rule, but this is a part of a clean code that is very important for test maintenance. After creating package “pages” let’s create Java class “HomePage”. All next steps and tricks You can find on the video.

Have a nice watching!

So,  huh! You know already how to create new Maven project, add Cucumber scenario, extend scenario, create first steps for Selenium tests, what is pattern Page Object and how to use it. Now You have enough skills to create some simple automation testing solution. But this is only beginning. And in the next lessons You will find much more interesting information about advanced automation testing.

Learn how to create advanced verifications in the next lesson.

Thanks for watching and reading my lessons!

Have a good automation!

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!

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!