diff --git a/cypress/e2e/cypress/example.feature b/cypress/e2e/cypress/example/commands/actions.feature similarity index 52% rename from cypress/e2e/cypress/example.feature rename to cypress/e2e/cypress/example/commands/actions.feature index 6a2e20519..828e974dd 100644 --- a/cypress/e2e/cypress/example.feature +++ b/cypress/e2e/cypress/example/commands/actions.feature @@ -1,11 +1,4 @@ -Feature: Cypress example - Scenario: Click and see text - Given I visit "https://example.cypress.io/" - Then I see text "Kitchen Sink" - And I do not see text "cy.get()" - When I click on text "get" - Then I see text "cy.get()" - +Feature: Cypress actions Scenario: See button, heading, link, and label Given I visit "https://example.cypress.io/commands/actions" Then I see heading "Actions" @@ -32,12 +25,6 @@ Feature: Cypress example When I click on label "Email address" And I type "test@example.com" - Scenario: Hidden link - Given I visit "https://example.cypress.io/" - When I find link by text "Cypress.io" - And I set attribute "style" to "visibility: hidden" - Then I do not see link "Cypress.io" - Scenario: Force click Given I visit "https://example.cypress.io/commands/actions" Then I click on button "I'm being covered" @@ -123,39 +110,12 @@ Feature: Cypress example And I find input by label text "Password" Then I see value "" - Scenario: Placeholder - Given I visit "https://example.cypress.io/commands/querying" - When I find elements by placeholder text "Name" - Then I count 1 element - When I find element by placeholder text "Name" - Then I count 1 element - When I find inputs by placeholder text "Name" - Then I count 1 element - When I find input by placeholder text "Name" - Then I count 1 element - - Scenario: Test ID - Given I visit "https://example.cypress.io/commands/querying" - Then I see test ID "test-example" - And I do not see test ID "test-invalid" - When I find elements by test ID "test-example" - Then I count 1 element - When I find element by test ID "test-example" - Then I count 1 element - And I click on test ID "test-example" - Scenario: Blur Given I visit "https://example.cypress.io/commands/actions" And I find element by text "Full Name" And I type "About to blur" And I blur - Scenario: Hidden text - Given I visit "https://example.cypress.io/cypress-api" - Then I do not see visible text "I'm hiding!" - When I find element by text "I'm hiding!" - Then I see element is not visible - Scenario: Scroll window Given I visit "https://example.cypress.io/commands/actions" And I scroll window to 0px and 500px @@ -203,39 +163,6 @@ Feature: Cypress example And I click 150px and 185px And I click 170px and 165px - Scenario: Get nth element - Given I visit "https://example.cypress.io/commands/aliasing" - When I find buttons by text "Change" - And I get first element - And I click "top-right" - Then I find buttons by text "Changed" - And I count 1 element - When I find buttons by text "Change" - And I get 2nd element - And I click "top" - Then I find buttons by text "Changed" - And I count 2 elements - When I find buttons by text "Change" - And I get 3rd element - And I click "bottom-right" - Then I find buttons by text "Changed" - And I count 3 elements - When I find buttons by text "Change" - And I get last element - And I click "bottom-left" - Then I find buttons by text "Changed" - And I count 4 elements - When I find links by text "cypress" - And I get 1st element - And I click "center" - - Scenario: Count elements length - Given I visit "https://example.cypress.io/commands/aliasing" - When I find buttons by text "Get Comment" - Then I count 1 element - When I find buttons by text "Change" - Then I count 4 elements - Scenario: Find and set input value Given I visit "https://example.cypress.io/commands/actions" When I double-click on text "Double click to edit" @@ -265,15 +192,6 @@ Feature: Cypress example And I click on title "" Then I see heading "Popover" - Scenario: Focus on element - Given I visit "https://example.cypress.io/commands/traversal" - When I get element by display value "Submit" - And I focus - And I get focused element - Then I see element has attribute "type" - And I get focused element - And I see element attribute "type" equals "submit" - Scenario: Find and submit form Given I visit "https://example.cypress.io/commands/actions" When I find form @@ -287,114 +205,3 @@ Feature: Cypress example And I find closest element "form" And I submit Then I see text "Your form has been submitted!" - - Scenario: Form with textarea - Given I visit "https://example.cypress.io/commands/misc" - When I find form - And I get children - And I get last element - And I click - And I type "children" - Then I see textarea value "children" - And I see textarea value contains "child" - - Scenario: Assert input value - Given I visit "https://example.cypress.io/commands/misc" - When I find element by label text "Name" - And I type "John Smith" - Then I see input value "John Smith" - And I see input value contains "John" - When I find input by label text "Name" - Then I see value "John Smith" - - Scenario: Timers - Given I visit "https://example.cypress.io/commands/spies-stubs-clocks" - When I use fake timers - And I set system time to 1234567890000 - And I click on text "Click for current time!" - Then I see text "1234567890" - When I reload the page - And I set system time to "2020-02-02" - And I click on text "Click for current time!" - Then I see text "1580601600" - When I advance timers by 300 milliseconds - And I advance timers by 1 millisecond - And I advance timers by 3 seconds - And I advance timers by 1 second - And I use real timers - And I click on text "Click for current time!" - Then I do not see text "15806016000" - - Scenario: Intercept network requests - Given I visit "https://example.cypress.io/commands/network-requests" - When I intercept URL "/comments/1" and stub body '{"body":"Test 1"}' - And I click on button "Get Comment" - Then I see text "Test 1" - When I intercept URL "/comments/1" - | auth | {"username":"user","password":"pass"} | - | body | {"body":"Test 2"} | - | headers | {"X-Requested-With":"exampleClient"} | - | hostname | localhost | - | https | true | - | method | GET | - | middleware | false | - | path | /api/commands/intercept?foo=bar | - | pathname | /api/commands/intercept | - | port | 8080 | - | query | {"foo":"bar"} | - | resourceType | fetch | - | times | 1 | - And I click on button "Get Comment" - Then I see text "Test 2" - - Scenario: Set environment variable - Given I visit "https://example.cypress.io/cypress-api" - When I set environment variable "api_server" to "http://localhost:8888/v2/" - - Scenario: Cookie - Given I visit "https://example.cypress.io/commands/cookies" - When I set cookie "name" to "value" - Then I see cookie "name" - When I clear cookie "name" - Then I do not see cookie "name" - When I set cookie "foo" to "bar" - Then I see cookie "foo" has value "bar" - When I clear cookies - Then I do not see cookie "foo" - When I click on button "Set Cookie" - Then I see cookie "token" contains value "123" - When I clear all cookies - Then I do not see cookie "test" - - Scenario: Local storage - Given I visit "https://example.cypress.io/commands/storage" - When I click on button "Populate localStorage and sessionStorage" - Then I see local storage item "prop1" - And I see local storage item "prop1" equals "red" - And I see local storage item "prop3" contains "gen" - When I clear local storage "prop1" - Then I do not see local storage item "prop1" - When I clear local storage - Then I do not see local storage item "prop2" - When I set local storage item "foo" to "bar" - Then I see local storage item "foo" equals "bar" - When I clear all local storage - Then I do not see local storage item "foo" - - Scenario: Session storage - Given I visit "https://example.cypress.io/commands/storage" - When I click on button "Populate localStorage and sessionStorage" - Then I see session storage item "prop5" - And I see session storage item "prop5" equals "yellow" - And I see session storage item "prop4" contains "cy" - When I clear session storage - Then I do not see local storage item "prop5" - - Scenario: Role - Given I visit "https://example.cypress.io/commands/querying" - When I find elements by role "button" - Then I see element exists - When I find element by role "button" - Then I see element is visible - And I see role "button" - And I do not see role "tooltip" diff --git a/cypress/e2e/cypress/example/commands/aliasing.feature b/cypress/e2e/cypress/example/commands/aliasing.feature new file mode 100644 index 000000000..294adcef8 --- /dev/null +++ b/cypress/e2e/cypress/example/commands/aliasing.feature @@ -0,0 +1,33 @@ +Feature: Cypress aliasing + Scenario: Get nth element + Given I visit "https://example.cypress.io/commands/aliasing" + When I find buttons by text "Change" + And I get first element + And I click "top-right" + Then I find buttons by text "Changed" + And I count 1 element + When I find buttons by text "Change" + And I get 2nd element + And I click "top" + Then I find buttons by text "Changed" + And I count 2 elements + When I find buttons by text "Change" + And I get 3rd element + And I click "bottom-right" + Then I find buttons by text "Changed" + And I count 3 elements + When I find buttons by text "Change" + And I get last element + And I click "bottom-left" + Then I find buttons by text "Changed" + And I count 4 elements + When I find links by text "cypress" + And I get 1st element + And I click "center" + + Scenario: Count elements length + Given I visit "https://example.cypress.io/commands/aliasing" + When I find buttons by text "Get Comment" + Then I count 1 element + When I find buttons by text "Change" + Then I count 4 elements diff --git a/cypress/e2e/cypress/example/commands/cookies.feature b/cypress/e2e/cypress/example/commands/cookies.feature new file mode 100644 index 000000000..7ac0f6e84 --- /dev/null +++ b/cypress/e2e/cypress/example/commands/cookies.feature @@ -0,0 +1,15 @@ +Feature: Cypress cookies + Scenario: Cookie + Given I visit "https://example.cypress.io/commands/cookies" + When I set cookie "name" to "value" + Then I see cookie "name" + When I clear cookie "name" + Then I do not see cookie "name" + When I set cookie "foo" to "bar" + Then I see cookie "foo" has value "bar" + When I clear cookies + Then I do not see cookie "foo" + When I click on button "Set Cookie" + Then I see cookie "token" contains value "123" + When I clear all cookies + Then I do not see cookie "test" diff --git a/cypress/e2e/cypress/example/commands/misc.feature b/cypress/e2e/cypress/example/commands/misc.feature new file mode 100644 index 000000000..feff49aa5 --- /dev/null +++ b/cypress/e2e/cypress/example/commands/misc.feature @@ -0,0 +1,19 @@ +Feature: Cypress misc + Scenario: Form with textarea + Given I visit "https://example.cypress.io/commands/misc" + When I find form + And I get children + And I get last element + And I click + And I type "children" + Then I see textarea value "children" + And I see textarea value contains "child" + + Scenario: Assert input value + Given I visit "https://example.cypress.io/commands/misc" + When I find element by label text "Name" + And I type "John Smith" + Then I see input value "John Smith" + And I see input value contains "John" + When I find input by label text "Name" + Then I see value "John Smith" diff --git a/cypress/e2e/cypress/example/commands/network-requests.feature b/cypress/e2e/cypress/example/commands/network-requests.feature new file mode 100644 index 000000000..cad8c0de8 --- /dev/null +++ b/cypress/e2e/cypress/example/commands/network-requests.feature @@ -0,0 +1,22 @@ +Feature: Cypress network requests + Scenario: Intercept network requests + Given I visit "https://example.cypress.io/commands/network-requests" + When I intercept URL "/comments/1" and stub body '{"body":"Test 1"}' + And I click on button "Get Comment" + Then I see text "Test 1" + When I intercept URL "/comments/1" + | auth | {"username":"user","password":"pass"} | + | body | {"body":"Test 2"} | + | headers | {"X-Requested-With":"exampleClient"} | + | hostname | localhost | + | https | true | + | method | GET | + | middleware | false | + | path | /api/commands/intercept?foo=bar | + | pathname | /api/commands/intercept | + | port | 8080 | + | query | {"foo":"bar"} | + | resourceType | fetch | + | times | 1 | + And I click on button "Get Comment" + Then I see text "Test 2" diff --git a/cypress/e2e/cypress/example/commands/querying.feature b/cypress/e2e/cypress/example/commands/querying.feature new file mode 100644 index 000000000..dc9e2b835 --- /dev/null +++ b/cypress/e2e/cypress/example/commands/querying.feature @@ -0,0 +1,30 @@ +Feature: Cypress querying + Scenario: Placeholder + Given I visit "https://example.cypress.io/commands/querying" + When I find elements by placeholder text "Name" + Then I count 1 element + When I find element by placeholder text "Name" + Then I count 1 element + When I find inputs by placeholder text "Name" + Then I count 1 element + When I find input by placeholder text "Name" + Then I count 1 element + + Scenario: Test ID + Given I visit "https://example.cypress.io/commands/querying" + Then I see test ID "test-example" + And I do not see test ID "test-invalid" + When I find elements by test ID "test-example" + Then I count 1 element + When I find element by test ID "test-example" + Then I count 1 element + And I click on test ID "test-example" + + Scenario: Role + Given I visit "https://example.cypress.io/commands/querying" + When I find elements by role "button" + Then I see element exists + When I find element by role "button" + Then I see element is visible + And I see role "button" + And I do not see role "tooltip" diff --git a/cypress/e2e/cypress/example/commands/spies-stubs-clocks.feature b/cypress/e2e/cypress/example/commands/spies-stubs-clocks.feature new file mode 100644 index 000000000..e2161ab48 --- /dev/null +++ b/cypress/e2e/cypress/example/commands/spies-stubs-clocks.feature @@ -0,0 +1,18 @@ +Feature: Cypress spies, stubs, clocks + Scenario: Timers + Given I visit "https://example.cypress.io/commands/spies-stubs-clocks" + When I use fake timers + And I set system time to 1234567890000 + And I click on text "Click for current time!" + Then I see text "1234567890" + When I reload the page + And I set system time to "2020-02-02" + And I click on text "Click for current time!" + Then I see text "1580601600" + When I advance timers by 300 milliseconds + And I advance timers by 1 millisecond + And I advance timers by 3 seconds + And I advance timers by 1 second + And I use real timers + And I click on text "Click for current time!" + Then I do not see text "15806016000" diff --git a/cypress/e2e/cypress/example/commands/storage.feature b/cypress/e2e/cypress/example/commands/storage.feature new file mode 100644 index 000000000..4abce4fb1 --- /dev/null +++ b/cypress/e2e/cypress/example/commands/storage.feature @@ -0,0 +1,24 @@ +Feature: Cypress storage + Scenario: Local storage + Given I visit "https://example.cypress.io/commands/storage" + When I click on button "Populate localStorage and sessionStorage" + Then I see local storage item "prop1" + And I see local storage item "prop1" equals "red" + And I see local storage item "prop3" contains "gen" + When I clear local storage "prop1" + Then I do not see local storage item "prop1" + When I clear local storage + Then I do not see local storage item "prop2" + When I set local storage item "foo" to "bar" + Then I see local storage item "foo" equals "bar" + When I clear all local storage + Then I do not see local storage item "foo" + + Scenario: Session storage + Given I visit "https://example.cypress.io/commands/storage" + When I click on button "Populate localStorage and sessionStorage" + Then I see session storage item "prop5" + And I see session storage item "prop5" equals "yellow" + And I see session storage item "prop4" contains "cy" + When I clear session storage + Then I do not see local storage item "prop5" diff --git a/cypress/e2e/cypress/example/commands/traversal.feature b/cypress/e2e/cypress/example/commands/traversal.feature new file mode 100644 index 000000000..8373a4ec2 --- /dev/null +++ b/cypress/e2e/cypress/example/commands/traversal.feature @@ -0,0 +1,9 @@ +Feature: Cypress traversal + Scenario: Focus on element + Given I visit "https://example.cypress.io/commands/traversal" + When I get element by display value "Submit" + And I focus + And I get focused element + Then I see element has attribute "type" + And I get focused element + And I see element attribute "type" equals "submit" diff --git a/cypress/e2e/cypress/example/cypress-api.feature b/cypress/e2e/cypress/example/cypress-api.feature new file mode 100644 index 000000000..dce2f166e --- /dev/null +++ b/cypress/e2e/cypress/example/cypress-api.feature @@ -0,0 +1,10 @@ +Feature: Cypress API + Scenario: Hidden text + Given I visit "https://example.cypress.io/cypress-api" + Then I do not see visible text "I'm hiding!" + When I find element by text "I'm hiding!" + Then I see element is not visible + + Scenario: Set environment variable + Given I visit "https://example.cypress.io/cypress-api" + When I set environment variable "api_server" to "http://localhost:8888/v2/" diff --git a/cypress/e2e/cypress/example/example.feature b/cypress/e2e/cypress/example/example.feature new file mode 100644 index 000000000..31246226f --- /dev/null +++ b/cypress/e2e/cypress/example/example.feature @@ -0,0 +1,13 @@ +Feature: Cypress example + Scenario: Click and see text + Given I visit "https://example.cypress.io/" + Then I see text "Kitchen Sink" + And I do not see text "cy.get()" + When I click on text "get" + Then I see text "cy.get()" + + Scenario: Hidden link + Given I visit "https://example.cypress.io/" + When I find link by text "Cypress.io" + And I set attribute "style" to "visibility: hidden" + Then I do not see link "Cypress.io"