Skip to content

netnet270/selenium-java-basic

 
 

Repository files navigation

Wha is this repo for?

This repository is demonstration on how to interact with most basic web elements and technique in Selenium with Java. The original challenge was from: https://github.com/Dotdashcom/take-home-webdriver-test

You can use Docker like the instruction or use this page directly for testing: https://the-internet.herokuapp.com/

Environment

  • Maven is installed

Run test

  • First testNG suite: testng.xml will handle test cases those need to run in a single thread.
  • Second testNG suite: testng-parallel.xml will handle test cases those can be executed in parallel.

Because the DnD test case need to be executed in a single thread. We use Robot class to handle DnD actions so any other movements (from other test cases) interupt it.

Run from IDE

  • Right click on the target .xml file then run (depends on your IDE)

Run from commandline

mvn clean test -DsuiteXmlFile=the-target-test-suite.xml

Example: mvn clean test -DsuiteXmlFile=testng-parallel.xml

  • If you wanna run more than 1 testNG suite, please use: mvn clean test -DsuiteXmlFile=testng-01.xml,testng-02.xml

Webdriver Tests

Prerequisites

  • Docker
  • Git
  • Java
  • Webdriver
  • ChromeDriver
  • IDE such as IntelliJ

Steps

  1. Pull Docker image for the-internet app:

    docker pull gprestes/the-internet

  2. Run the following command:

    docker run -d -p 7080:5000 gprestes/the-internet

  3. Set the following BaseUrl for your tests:

    http://localhost:7080

  4. Use ChromeDriver to write Tests for the following scenarios in Java:

  5. Open a Pull Request for Code Review.

Submission Rubrics

General Requirements

  1. All tests should contain @Test annotation.
  2. All tests should provide a setup and tear down mechanism that closes the browser.
  3. All tests should run successfully from IDE. Provide a way to run tests on unix based OS.

Test Specific Rubrics

  1. Login Success

    • Page Object Model for the login page should be provided.
    • Test is able to login successfully.
    • Test uses an assertion to make sure User has logged in.
  2. Login Failure

    • Page Object Model for the login page should be used.
    • Test is not able to login with wrong credentials.
    • Test uses assertions to check Login failed for incorrect user and password.
  3. Checkboxes

    • Test checks and unchecks checkboxes.
    • Test uses assertions to make sure boxes were properly checked and unchecked.
  4. Context Menu

    • Test right clicks on the context menu.
    • Test asserts the alert menu text.
  5. Drag and Drop

    • Test drags element A to element B.
    • Test asserts that the text on element A and B are switched.
  6. Dropdown

    • Test selects Option 1 and Option 2 from the drop down menu.
    • Test asserts Option 1 and Option 2 are selected.
  7. Dynamic Content

    • Test refreshes the page a couple of times.
    • Test asserts that the content changes on each refresh.
  8. Dynamic Controls

    • Test clicks on the Remove Button and uses explicit wait.
    • Test asserts that the checkbox is gone.
    • Test clicks on Add Button and uses explicit wait.
    • Test asserts that the checkbox is present.
    • Test clicks on the Enable Button and uses explicit wait.
    • Test asserts that the text box is enabled.
    • Test clicks on the Disable Button and uses explicit wait.
    • Test asserts that the text box is disabled.
  9. Dynamic Loading

    • Test clicks the start button and uses explicit wait.
    • Test asserts that “Hello World!” text is displayed.
  10. File Download

    • Test clicks on the file.
    • Test asserts that the file is downloaded.
  11. Floating Menu

    • Test scrolls the page.
    • Test asserts that the floating menu is still displayed.
  12. Iframe

    • Test switches to Iframe and types some text.
    • Test asserts that the typed text is as expected.
  13. Mouse Hover

    • Test does a mouse hover on each image.
    • Test asserts that additional information is displayed for each image.
  14. JavaScript Alerts

    • Test Clicks on JS Alert Button.
    • Test asserts alert message.
    • Test clicks on JS confirm Button and clicks ok on alert.
    • Test asserts the alert message.
    • Test clicks on JS Prompt Button and types a message on Prompt.
    • Test asserts that the alert message contains the typed message.
  15. JavaScript Error

    • Test finds the JavaScript error on the page.
    • Test asserts that the page contains error: Cannot read property 'xyz' of undefined.
  16. Open in New Tab

    • Test clicks on the Click Here link.
    • Test asserts that a new tab is opened with text New Window.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%