Skip to content

A web application to explore Spring MVC, MyBatis and Selenium Testing - Udacity Java Web Developer Nanodegree Project 1

Notifications You must be signed in to change notification settings

biscaboy/cloudstorage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SuperDuperDrive Cloud Storage

Udacity Java Web Developer Nanodegree Project 1 - Live demo

This project is an exercise to acquaint the developer with Spring, Spring Boot, Thymeleaf the Spring Initializer, the MyBatis ORM (Object-Relational Mapping) framework, the JUnit 5 testing framework, the Selenium WebDriver for integration testing and the IntelliJ IDE.

Table of contents

Requirements

The project's rubric requires the developer to create a website on the Spring Framework that provides authenticated access and allows a user to save a list of files, notes, and website credentials on a server. The developer must create:

  1. The back-end with Spring Boot
  2. The front-end with Thymeleaf
  3. Application tests with Selenium

The instructors provide the student developer with front-end html files, a hashing service class, an encryption service class and a Spring Boot framework using Maven.

Setup

Launch

The project requires IntelliJ IDE and has only tested in that development environment. The Maven project file (pom.xml) provides all dependencies. The main() method is found in:

cloudstorage/src/main/java/com/udacity/jwdnd/course1/cloudstorage/CloudStorageApplication.java

JUnit Tests

Integration tests on Chrome can be found here:

cloudstorage/src/test/java/com/udacity/jwdnd/course1/cloudstorage/CloudStorageApplicationTests.java

There are also JUnit tests for the model layer. They can be found in the cloudstorage/src/test/java/com/udacity/jwdnd/course1/cloudstorage/model/ package.

Resources

I did a lot of reading and reseach for this project after being away from Java, Java Servlets and JUnit testing for a long time. I want to thank all the developers and educators who generously posted documentation, solutions and tutorials online.

Spring Documentation

  • multiple topics including Resources, ResourceLoader and JUnit Testing.

Selenium.dev

  • Multiple topics including Waits

Baeldung

W3Schools.com

Contributors of Answers at Stack Overflow

Contributors to StackExchange

Other Various Resources

Note on Selenium

I found the most difficult aspect of this assignment to be working with the Selenium WebDriver, WebDriverWait and ExpectedConditions classes. In the course the PageFactory pattern was presented, but as I worked though my solution I found that the PageFactory didn't play well with WebDriverWait. There are many examples online of code that didn't work with the driver I was provided in the Maven project provided by the instructors.

I found that this code presented multiple places as a working example would not cause the driver to wait.

WebDriverWait wait = new WebDriverWait(driver, 3);

wait.until(webDriver -> webDriver.findElement(By.id("some-element")));

Passing WebElements created by the PageFactory worked but the WebDriver again would not wait, but immediately returned and not solving race error situations.

WebDriverWait wait = new WebDriverWait(driver, 10);

WebElement elemUsername = wait.until(ExpectedConditions.elementToBeClickable(pageFactoryElement));

elemUsername.sendKeys("xyz");

What worked for me was to include a new call to driver.findElement(By.x()) inside the ExpectedConditions function to provide the proper DOM context for the wait object to call against. This is the code that finally worked for me:

WebDriverWait wait = new WebDriverWait(driver, 10);

WebElement el = wait.until(ExpectedConditions.visibilityOf(
                    driver.findElement(By.id("some-element-id")));

el.sendKeys("abc");

The ExpectedCondition.visibilityOf() was the most consistent method for the tests in this project as others occasionally failed with element not accessable errors.

Thanks

Many thanks to my instructors and code reviewers at Udacity for the time and effort. Special thanks to Peter Zastoupil for developing the course.

Deployment

This project pushes commits to a Jenkins installation in the AWS Cloud which deploys the application to a Docker container.

About

A web application to explore Spring MVC, MyBatis and Selenium Testing - Udacity Java Web Developer Nanodegree Project 1

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published