Coder Social home page Coder Social logo

benweese / java_automation Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 0.0 27.38 MB

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

License: MIT License

Java 81.94% Gherkin 9.03% PureBasic 8.16% Dockerfile 0.87%
cucumber java-automation benweese circleci selenium scenarios docker dockerfile rest-assured api-testing

java_automation's Introduction

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 Actions Docker Hub

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

java_automation's People

Contributors

benweese avatar dependabot-preview[bot] avatar snyk-bot avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

java_automation's Issues

no such element: Unable to locate element: {"method":"css selector","selector":"div.et_pb_contact_form_0 div.et-pb-contact-message p"}

Issue

CSS Selector works when imputed directly but not when in pom for test on Scenario: Do the math Captcha.

Stack Trace

Starting ChromeDriver 74.0.3729.6 (255758eccf3d244491b8a1317aa76e1ce10d57e9-refs/branch-heads/3729@{#29}) on port 12960
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
Jun 11, 2019 8:24:22 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
...F--

org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"css selector","selector":"div.et_pb_contact_form_0 div.et-pb-contact-message p"}
  (Session info: chrome=74.0.3729.169)
  (Driver info: chromedriver=74.0.3729.6 (255758eccf3d244491b8a1317aa76e1ce10d57e9-refs/branch-heads/3729@{#29}),platform=Mac OS X 10.14.5 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds
For documentation on this error, please visit: https://www.seleniumhq.org/exceptions/no_such_element.html
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'bens-mbp.lan', ip: '2605:6000:1b02:60d2:945c:46e2:1b36:9c90%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.14.5', java.version: '11.0.2'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities {acceptInsecureCerts: false, acceptSslCerts: false, applicationCacheEnabled: false, browserConnectionEnabled: false, browserName: chrome, chrome: {chromedriverVersion: 74.0.3729.6 (255758eccf3d24..., userDataDir: /var/folders/74/r3z6mt2d0dx...}, cssSelectorsEnabled: true, databaseEnabled: false, goog:chromeOptions: {debuggerAddress: localhost:61696}, handlesAlerts: true, hasTouchScreen: false, javascriptEnabled: true, locationContextEnabled: true, mobileEmulationEnabled: false, nativeEvents: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: MAC, platformName: MAC, proxy: Proxy(), rotatable: false, setWindowRect: true, strictFileInteractability: false, takesHeapSnapshot: true, takesScreenshot: true, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unexpectedAlertBehaviour: ignore, unhandledPromptBehavior: ignore, version: 74.0.3729.169, webStorageEnabled: true}
Session ID: 6a8ccc667873c17e719702851622686b
*** Element info: {Using=css selector, value=div.et_pb_contact_form_0 div.et-pb-contact-message p}

	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
	at java.base/java.lang.reflect.Constructor.newInstance(Unknown Source)
	at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:214)
	at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:166)
	at org.openqa.selenium.remote.http.JsonHttpResponseCodec.reconstructValue(JsonHttpResponseCodec.java:40)
	at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:80)
	at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:44)
	at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
	at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
	at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
	at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:323)
	at org.openqa.selenium.remote.RemoteWebDriver.findElementByCssSelector(RemoteWebDriver.java:420)
	at org.openqa.selenium.By$ByCssSelector.findElement(By.java:431)
	at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:315)
	at StepDefinition.complicatedPage.i_calculate_the_answer(complicatedPage.java:201)
	at ✽.I calculate the answer(file:src/test/resources/Features/complicated-page.feature:67)

[DepShield] (CVSS 9.8) Vulnerability due to usage of org.eclipse.jetty:jetty-http:9.4.9.v20180320

Vulnerabilities

DepShield reports that this application's usage of org.eclipse.jetty:jetty-http:9.4.9.v20180320 results in the following vulnerability(s):


Occurrences

org.eclipse.jetty:jetty-http:9.4.9.v20180320 is a transitive dependency introduced by the following direct dependency(s):

org.seleniumhq.selenium:htmlunit-driver:2.30.0
        └─ net.sourceforge.htmlunit:htmlunit:2.30
              └─ org.eclipse.jetty.websocket:websocket-client:9.4.9.v20180320
                    └─ org.eclipse.jetty:jetty-client:9.4.9.v20180320
                          └─ org.eclipse.jetty:jetty-http:9.4.9.v20180320

This is an automated GitHub Issue created by Sonatype DepShield. Details on managing GitHub Apps, including DepShield, are available for personal and organization accounts. Please submit questions or feedback about DepShield to the Sonatype DepShield Community.

[DepShield] (CVSS 5.9) Vulnerability due to usage of com.squareup.okhttp3:okhttp:3.11.0

Vulnerabilities

DepShield reports that this application's usage of com.squareup.okhttp3:okhttp:3.11.0 results in the following vulnerability(s):


Occurrences

com.squareup.okhttp3:okhttp:3.11.0 is a transitive dependency introduced by the following direct dependency(s):

org.seleniumhq.selenium:selenium-java:3.141.59
        └─ com.squareup.okhttp3:okhttp:3.11.0

This is an automated GitHub Issue created by Sonatype DepShield. Details on managing GitHub Apps, including DepShield, are available for personal and organization accounts. Please submit questions or feedback about DepShield to the Sonatype DepShield Community.

Refactor API Testing

Refactor the Rest Assured code to be multiple test and not just one long test. Why did you do that?

Learning/easy ¯_(ツ)_/¯

[DepShield] (CVSS 5.9) Vulnerability due to usage of com.google.guava:guava:23.6-jre

Vulnerabilities

DepShield reports that this application's usage of com.google.guava:guava:23.6-jre results in the following vulnerability(s):


Occurrences

com.google.guava:guava:23.6-jre is a transitive dependency introduced by the following direct dependency(s):

org.seleniumhq.selenium:selenium-java:3.11.0
        └─ com.google.guava:guava:23.6-jre

This is an automated GitHub Issue created by Sonatype DepShield. Details on managing GitHub Apps, including DepShield, are available for personal and organization accounts. Please submit questions or feedback about DepShield to the Sonatype DepShield Community.

[DepShield] (CVSS 9.8) Vulnerability due to usage of org.eclipse.jetty:jetty-http:9.4.8.v20171121

Vulnerabilities

DepShield reports that this application's usage of org.eclipse.jetty:jetty-http:9.4.8.v20171121 results in the following vulnerability(s):


Occurrences

org.eclipse.jetty:jetty-http:9.4.8.v20171121 is a transitive dependency introduced by the following direct dependency(s):

org.seleniumhq.selenium:selenium-server:3.11.0
        └─ org.eclipse.jetty:jetty-http:9.4.8.v20171121

This is an automated GitHub Issue created by Sonatype DepShield. Details on managing GitHub Apps, including DepShield, are available for personal and organization accounts. Please submit questions or feedback about DepShield to the Sonatype DepShield Community.

no such element: Unable to locate element: {"method":"css selector","selector":"div.id.search-2 div.id.searchform div.input.id.s"}

Issue

CSS Selector works when imputed directly but not when in pom for test on Scenario: Search for the word holidays

Stack Trace

Starting ChromeDriver 74.0.3729.6 (255758eccf3d244491b8a1317aa76e1ce10d57e9-refs/branch-heads/3729@{#29}) on port 46321
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
Jun 11, 2019 8:24:27 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
F--

org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"css selector","selector":"div.id.search-2 div.id.searchform div.input.id.s"}
  (Session info: chrome=74.0.3729.169)
  (Driver info: chromedriver=74.0.3729.6 (255758eccf3d244491b8a1317aa76e1ce10d57e9-refs/branch-heads/3729@{#29}),platform=Mac OS X 10.14.5 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds
For documentation on this error, please visit: https://www.seleniumhq.org/exceptions/no_such_element.html
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'bens-mbp.lan', ip: '2605:6000:1b02:60d2:945c:46e2:1b36:9c90%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.14.5', java.version: '11.0.2'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities {acceptInsecureCerts: false, acceptSslCerts: false, applicationCacheEnabled: false, browserConnectionEnabled: false, browserName: chrome, chrome: {chromedriverVersion: 74.0.3729.6 (255758eccf3d24..., userDataDir: /var/folders/74/r3z6mt2d0dx...}, cssSelectorsEnabled: true, databaseEnabled: false, goog:chromeOptions: {debuggerAddress: localhost:61761}, handlesAlerts: true, hasTouchScreen: false, javascriptEnabled: true, locationContextEnabled: true, mobileEmulationEnabled: false, nativeEvents: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: MAC, platformName: MAC, proxy: Proxy(), rotatable: false, setWindowRect: true, strictFileInteractability: false, takesHeapSnapshot: true, takesScreenshot: true, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unexpectedAlertBehaviour: ignore, unhandledPromptBehavior: ignore, version: 74.0.3729.169, webStorageEnabled: true}
Session ID: 84ad9bfaaf8cb39ee001adc34797869f
*** Element info: {Using=css selector, value=div.id.search-2 div.id.searchform div.input.id.s}

	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
	at java.base/java.lang.reflect.Constructor.newInstance(Unknown Source)
	at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:214)
	at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:166)
	at org.openqa.selenium.remote.http.JsonHttpResponseCodec.reconstructValue(JsonHttpResponseCodec.java:40)
	at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:80)
	at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:44)
	at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
	at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
	at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
	at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:323)
	at org.openqa.selenium.remote.RemoteWebDriver.findElementByCssSelector(RemoteWebDriver.java:420)
	at org.openqa.selenium.By$ByCssSelector.findElement(By.java:431)
	at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:315)
	at StepDefinition.complicatedPage.iFindTheSearchFunction(complicatedPage.java:226)
	at ✽.I find the search function(file:src/test/resources/Features/complicated-page.feature:72)

Popup test fails sometimes: Cannot Determing Loading status from no such execution context

Issue

Fails sometimes when loading popup during test. This does not only fail.

Stack Trace

Starting ChromeDriver 74.0.3729.6 (255758eccf3d244491b8a1317aa76e1ce10d57e9-refs/branch-heads/3729@{#29}) on port 12523
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
Jun 11, 2019 8:24:17 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
..F

org.openqa.selenium.WebDriverException: unknown error: cannot determine loading status
from no such execution context
  (Session info: chrome=74.0.3729.169)
  (Driver info: chromedriver=74.0.3729.6 (255758eccf3d244491b8a1317aa76e1ce10d57e9-refs/branch-heads/3729@{#29}),platform=Mac OS X 10.14.5 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'bens-mbp.lan', ip: '2605:6000:1b02:60d2:945c:46e2:1b36:9c90%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.14.5', java.version: '11.0.2'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities {acceptInsecureCerts: false, acceptSslCerts: false, applicationCacheEnabled: false, browserConnectionEnabled: false, browserName: chrome, chrome: {chromedriverVersion: 74.0.3729.6 (255758eccf3d24..., userDataDir: /var/folders/74/r3z6mt2d0dx...}, cssSelectorsEnabled: true, databaseEnabled: false, goog:chromeOptions: {debuggerAddress: localhost:61615}, handlesAlerts: true, hasTouchScreen: false, javascriptEnabled: true, locationContextEnabled: true, mobileEmulationEnabled: false, nativeEvents: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: MAC, platformName: MAC, proxy: Proxy(), rotatable: false, setWindowRect: true, strictFileInteractability: false, takesHeapSnapshot: true, takesScreenshot: true, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unexpectedAlertBehaviour: ignore, unhandledPromptBehavior: ignore, version: 74.0.3729.169, webStorageEnabled: true}
Session ID: 28653145ecf8d9d44d4645ac0cb4eb52

	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
	at java.base/java.lang.reflect.Constructor.newInstance(Unknown Source)
	at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:214)
	at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:166)
	at org.openqa.selenium.remote.http.JsonHttpResponseCodec.reconstructValue(JsonHttpResponseCodec.java:40)
	at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:80)
	at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:44)
	at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
	at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
	at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
	at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:609)
	at org.openqa.selenium.remote.RemoteWebDriver.getCurrentUrl(RemoteWebDriver.java:287)
	at StepDefinition.complicatedPage.i_am_shown_a_popup_to_share_on_facebook(complicatedPage.java:175)
	at ✽.I am shown a popup to share on Facebook(file:src/test/resources/Features/complicated-page.feature:61)


[DepShield] (CVSS 5.9) Vulnerability due to usage of com.squareup.okhttp3:okhttp:3.9.1

Vulnerabilities

DepShield reports that this application's usage of com.squareup.okhttp3:okhttp:3.9.1 results in the following vulnerability(s):


Occurrences

com.squareup.okhttp3:okhttp:3.9.1 is a transitive dependency introduced by the following direct dependency(s):

org.seleniumhq.selenium:selenium-java:3.11.0
        └─ com.squareup.okhttp3:okhttp:3.9.1

This is an automated GitHub Issue created by Sonatype DepShield. Details on managing GitHub Apps, including DepShield, are available for personal and organization accounts. Please submit questions or feedback about DepShield to the Sonatype DepShield Community.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.