View on GitHub

Java_Automation

This is for practicing, learning, and teaching Java, Selenium, and Cucumber

BenWeese.Dev

Java Automation

This project is for practiceing Cucumber, Selenuim, and Java. You can find the link for the template above for creating your own automation. To learn more you can check out the Wiki for this repo where I document what I have learned.

Badges

CircleCI GitHub Quality Gate Status Known Vulnerabilities GitHub issues StackShare

Motivation

This is to keep my automations skills sharp.

Notification

This automation is happy path only and does not test for failures. It is an example and learning on how it can done. If you wish to test more thoroughly then I would suggest using Cucumber and Scenario Outlines to test many different scenarios including failures.

Tools

BDD framework used

Built with

Testing Language

Continuous Intergration

Depandacy Maintenance

Security

Downloads

Features

With testing our Circle-CI runner will use maven to run our automation scripts in Command line.

Code Example

Setup

    void setDriver() {

        System.setProperty("webdriver.chrome.driver", System.getProperty("user.dir") + "/src/main/resources/chromedriver");

        ChromeOptions options = new ChromeOptions();
        options.addArguments("--no-sandbox");
        options.addArguments("--headless");
        options.addArguments("--disable-gpu");
        options.addArguments("--window-size=1200x1100");
        options.addArguments("--disable-extensions");

        driver = new ChromeDriver(options);

    }

Page Object

  public class complicatedPOM {
    WebDriver driver;

    By button0 = By.className("et_pb_button_0");
    By button1 = By.className("et_pb_button_1");
    By button2 = By.className("et_pb_button_2");
    ...
    By socialM0 = By.className("et_pb_social_media_follow_network_0");
    By socialM1 = By.className("et_pb_social_media_follow_network_1");
    By socialM2 = By.className("et_pb_social_media_follow_network_2");
    ...
    public complicatedPOM(WebDriver driver){
        this.driver = driver;
    }
    

Cucumber

    Given I find a button
    When I click the button with <id>
    Then I am taken back to the page

Java/Cucumber

@Given("^I find a button$")
    public void i_find_a_button() {
        Assert.assertEquals(url, driver.getCurrentUrl());
        WebElement button = driver.findElement(comPOM.button0);
        Assert.assertTrue(button.isDisplayed());
    }

    @When("^I click the button with (\\d+)$")
    public void i_click_the_button_at_and(int arg) {
        By[] button = comPOM.getButton();

        driver.findElement(button[arg]).click();

Runner

	//This is the JUnit Runner for our test.
	//We are using both Cucumber.
	@RunWith(Cucumber.class)
	//We define where the Cucumber framework is located and where our code is.
	@CucumberOptions(features="src/test/resources/Features",glue={"StepDefinition"})

	public class runner {

	}

Documentation

Credits

Ben Weese