diff --git a/pom.xml b/pom.xml
index 6b007b1..c97069d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -37,6 +37,12 @@
saucerest
1.0.39
+
+ io.rest-assured
+ rest-assured
+ 3.3.0
+ test
+
diff --git a/src/test/java/io/cucumber/FileHandlerStepDefs.java b/src/test/java/io/cucumber/FileHandlerStepDefs.java
new file mode 100644
index 0000000..68ef487
--- /dev/null
+++ b/src/test/java/io/cucumber/FileHandlerStepDefs.java
@@ -0,0 +1,51 @@
+package io.cucumber;
+import cucumber.api.java.en.Given;
+import cucumber.api.java.en.Then;
+import cucumber.api.java.en.When;
+import io.restassured.response.Response;
+import org.junit.Assert;
+
+import static io.restassured.RestAssured.get;
+import static io.restassured.RestAssured.post;
+
+public class FileHandlerStepDefs
+{
+ private String filePath;
+ private Response webResponse;
+
+ @Given("I have a File")
+ public void iHaveAFile() {
+ filePath = "https://the-internet.herokuapp.com/download/some-file.txt";
+ }
+
+ @When("I download the file")
+ public void iDownloadTheFile() {
+ webResponse = get(filePath);
+ }
+
+ @Then("The file is successfully downloaded")
+ public void theFileIsSuccessfullyDownloaded() {
+ webResponse.then().statusCode(200);
+ }
+
+ @Then("The file is the correct type")
+ public void theFileIsTheCorrectType()
+ {
+ Assert.assertTrue(webResponse.getHeader("Content-Disposition").contains("some-file.txt"));
+ }
+
+ @Given("I have not attached any file")
+ public void iHaveNotAttachedAnyFile() {
+ //do nothing
+ }
+
+ @When("I upload the file")
+ public void iUploadTheFile() {
+ webResponse = post("https://the-internet.herokuapp.com/upload");
+ }
+
+ @Then("The file upload process fails")
+ public void theFileUploadProcessFails() {
+ webResponse.then().statusCode(500);
+ }
+}
diff --git a/src/test/java/io/cucumber/StepDefinitions.java b/src/test/java/io/cucumber/StepDefinitions.java
index b2aca02..f04f341 100644
--- a/src/test/java/io/cucumber/StepDefinitions.java
+++ b/src/test/java/io/cucumber/StepDefinitions.java
@@ -21,6 +21,8 @@
import java.net.URL;
import java.util.stream.IntStream;
+
+
public class StepDefinitions {
private WebDriver driver;
private String sessionId;
@@ -32,7 +34,7 @@ public class StepDefinitions {
private final String BASE_URL = "https://www.saucedemo.com";
private SauceUtils sauceUtils;
- @Before
+ @Before("not @api")
public void setUp(Scenario scenario) throws MalformedURLException {
//Set up the ChromeOptions object, which will store the capabilities for the Sauce run
ChromeOptions caps = new ChromeOptions();
@@ -61,7 +63,7 @@ public void setUp(Scenario scenario) throws MalformedURLException {
sauceUtils = new SauceUtils(sauceREST);
}
- @After
+ @After("not @api")
public void tearDown(Scenario scenario){
driver.quit();
sauceUtils.updateResults(!scenario.isFailed(), sessionId);
diff --git a/src/test/resources/io/cucumber/features/FileDownload.feature b/src/test/resources/io/cucumber/features/FileDownload.feature
new file mode 100644
index 0000000..8830352
--- /dev/null
+++ b/src/test/resources/io/cucumber/features/FileDownload.feature
@@ -0,0 +1,12 @@
+@api
+Feature: File download
+
+ Scenario: Download file
+ Given I have a File
+ When I download the file
+ Then The file is successfully downloaded
+
+ Scenario: Download correct file type
+ Given I have a File
+ When I download the file
+ Then The file is the correct type
\ No newline at end of file
diff --git a/src/test/resources/io/cucumber/features/FileUpload.feature b/src/test/resources/io/cucumber/features/FileUpload.feature
new file mode 100644
index 0000000..bdf017d
--- /dev/null
+++ b/src/test/resources/io/cucumber/features/FileUpload.feature
@@ -0,0 +1,7 @@
+@api
+Feature: File upload
+
+ Scenario: Upload button doesn't work with no file attached
+ Given I have not attached any file
+ When I upload the file
+ Then The file upload process fails
\ No newline at end of file