├── module-4-page-objects ├── thucydides.properties ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── src │ ├── main │ │ └── java │ │ │ └── com │ │ │ └── parleys │ │ │ └── training │ │ │ └── exercises │ │ │ └── package-info.java │ └── test │ │ └── java │ │ └── com │ │ └── parleys │ │ └── training │ │ ├── solutions │ │ ├── home │ │ │ └── DisplayingTheHomePageTest.java │ │ ├── pages │ │ │ ├── HomePage.java │ │ │ ├── ItemDetailsPage.java │ │ │ └── SearchResultsPage.java │ │ └── search │ │ │ └── SearchingByKeywordTest.java │ │ └── exercises │ │ ├── home │ │ └── DisplayingTheHomePageTest.java │ │ └── search │ │ └── SearchingByKeywordTest.java ├── README.TXT ├── build.gradle ├── gradlew.bat ├── pom.xml └── gradlew ├── module-5-test-organization ├── thucydides.properties ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── src │ ├── main │ │ └── java │ │ │ └── com │ │ │ └── parleys │ │ │ └── training │ │ │ └── exercises │ │ │ └── package-info.java │ └── test │ │ └── java │ │ └── com │ │ └── parleys │ │ └── training │ │ ├── exercises │ │ ├── home │ │ │ └── DisplayingTheHomePageTest.java │ │ ├── pages │ │ │ ├── HomePage.java │ │ │ ├── SearchResultsPage.java │ │ │ └── ItemDetailsPage.java │ │ └── search │ │ │ └── SearchingByKeywordTest.java │ │ └── solutions │ │ ├── pages │ │ ├── HomePage.java │ │ ├── SearchResultsPage.java │ │ └── ItemDetailsPage.java │ │ ├── home │ │ └── DisplayingTheHomePageTest.java │ │ ├── search │ │ └── SearchingByKeywordTest.java │ │ └── steps │ │ └── EtsyBuyer.java ├── README.TXT ├── build.gradle ├── gradlew.bat ├── pom.xml └── gradlew ├── settings.gradle ├── module-1-getting-started ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── src │ ├── main │ │ └── java │ │ │ └── com │ │ │ └── parleys │ │ │ └── training │ │ │ └── exercises │ │ │ └── package-info.java │ └── test │ │ └── java │ │ └── com │ │ └── parleys │ │ └── training │ │ ├── exercises │ │ └── SimpleSearchTest.java │ │ └── solutions │ │ └── SimpleSearchTest.java ├── README.TXT ├── build.gradle ├── gradlew.bat ├── pom.xml └── gradlew ├── module-3-webdriver-fundamentals ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── src │ ├── main │ │ └── java │ │ │ └── com │ │ │ └── parleys │ │ │ └── training │ │ │ └── exercises │ │ │ └── package-info.java │ └── test │ │ └── java │ │ └── com │ │ └── parleys │ │ └── training │ │ ├── exercises │ │ └── home │ │ │ └── DisplayingTheEtsyHomePageTest.java │ │ └── solutions │ │ └── home │ │ └── DisplayingTheEtsyHomePageTest.java ├── README.TXT ├── build.gradle ├── gradlew.bat ├── pom.xml └── gradlew ├── .gitignore └── README.md /module-4-page-objects/thucydides.properties: -------------------------------------------------------------------------------- 1 | thucydides.test.root=com.parleys.training.solutions 2 | -------------------------------------------------------------------------------- /module-5-test-organization/thucydides.properties: -------------------------------------------------------------------------------- 1 | thucydides.test.root=com.parleys.training.solutions 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include 'module-1-getting-started','module-3-webdriver-fundamentals', 'module-4-page-objects','module-5-test-organization' -------------------------------------------------------------------------------- /module-4-page-objects/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wakaleo/webdriver-fundamentals-exercises/HEAD/module-4-page-objects/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /module-1-getting-started/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wakaleo/webdriver-fundamentals-exercises/HEAD/module-1-getting-started/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /module-5-test-organization/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wakaleo/webdriver-fundamentals-exercises/HEAD/module-5-test-organization/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /module-3-webdriver-fundamentals/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wakaleo/webdriver-fundamentals-exercises/HEAD/module-3-webdriver-fundamentals/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /module-4-page-objects/src/main/java/com/parleys/training/exercises/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This package will contain any reusable web test components. 3 | */ 4 | package com.parleys.training.exercises; 5 | -------------------------------------------------------------------------------- /module-1-getting-started/src/main/java/com/parleys/training/exercises/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This package will contain any reusable web test components. 3 | */ 4 | package com.parleys.training.exercises; 5 | -------------------------------------------------------------------------------- /module-5-test-organization/src/main/java/com/parleys/training/exercises/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This package will contain any reusable web test components. 3 | */ 4 | package com.parleys.training.exercises; 5 | -------------------------------------------------------------------------------- /module-3-webdriver-fundamentals/src/main/java/com/parleys/training/exercises/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This package will contain any reusable web test components. 3 | */ 4 | package com.parleys.training.exercises; 5 | -------------------------------------------------------------------------------- /module-5-test-organization/README.TXT: -------------------------------------------------------------------------------- 1 | Module 5 - Test Organization - Exercises 2 | --------------------------------------------- 3 | 4 | Exercise 1. Refactor the existing tests to use Serenity step libraries. 5 | 6 | 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | pom.xml.tag 3 | pom.xml.releaseBackup 4 | pom.xml.versionsBackup 5 | pom.xml.next 6 | release.properties 7 | .gradle 8 | .classpath 9 | .settings 10 | build/ 11 | gradle-app.setting 12 | *.project 13 | *.iml 14 | *.ipr 15 | *.iws 16 | out 17 | *.zip 18 | .idea -------------------------------------------------------------------------------- /module-4-page-objects/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Thu Dec 11 08:10:44 EST 2014 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.1-bin.zip 7 | -------------------------------------------------------------------------------- /module-1-getting-started/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Thu Dec 11 08:10:44 EST 2014 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.1-bin.zip 7 | -------------------------------------------------------------------------------- /module-5-test-organization/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Thu Dec 11 08:10:44 EST 2014 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.1-bin.zip 7 | -------------------------------------------------------------------------------- /module-3-webdriver-fundamentals/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Thu Dec 11 08:10:44 EST 2014 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.1-bin.zip 7 | -------------------------------------------------------------------------------- /module-1-getting-started/README.TXT: -------------------------------------------------------------------------------- 1 | Module 1 - Getting Started - Exercises 2 | -------------------------------------- 3 | 4 | Exercise 1. Import the project into your IDE and run the tests. 5 | 6 | Exercise 2. Open the com.parleys.training.exercises.SimpleSearchTest and add a new test that searches the Wikipedia site for 'fireflies'. 7 | 8 | -------------------------------------------------------------------------------- /module-4-page-objects/README.TXT: -------------------------------------------------------------------------------- 1 | Module 4 - Page Objects - Exercises 2 | --------------------------------------------- 3 | 4 | Exercise 1. Implement the four tests from the previous exercise to use Page Objects. 5 | 6 | Exercise 2. Add a new test that searches for "shoes", clicks on the first item, and checks that the title matches the 7 | description in the listing. 8 | 9 | -------------------------------------------------------------------------------- /module-3-webdriver-fundamentals/README.TXT: -------------------------------------------------------------------------------- 1 | Module 3 - WebDriver fundamentals - Exercises 2 | --------------------------------------------- 3 | 4 | Exercise 1. Implement a test that searches for 'shoes' on the Etsy home page. 5 | 6 | Exercise 2. Implement another test that searches for 'shoes' and then refines the search by 'Item Type' to 'vintage shoes' 7 | 8 | Exercise 3. Implement a test that searches for 'shoes' and checks that each displayed result relates to shoes. 9 | -------------------------------------------------------------------------------- /module-1-getting-started/build.gradle: -------------------------------------------------------------------------------- 1 | repositories { 2 | mavenLocal() 3 | jcenter() 4 | } 5 | 6 | buildscript { 7 | repositories { 8 | mavenLocal() 9 | jcenter() 10 | } 11 | dependencies { 12 | classpath("net.serenity-bdd:serenity-gradle-plugin:1.0.16") 13 | } 14 | } 15 | 16 | apply plugin: 'java' 17 | apply plugin: 'eclipse' 18 | apply plugin: 'idea' 19 | apply plugin: 'net.serenity-bdd.aggregator' 20 | 21 | sourceCompatibility = 1.8 22 | targetCompatibility = 1.8 23 | 24 | dependencies { 25 | compile 'org.slf4j:slf4j-api:1.7.5' 26 | testCompile 'junit:junit:4.11' 27 | testCompile 'org.assertj:assertj-core:1.7.0' 28 | testCompile 'net.serenity-bdd:core:1.0.16' 29 | testCompile 'net.serenity-bdd:serenity-junit:1.0.16' 30 | } 31 | 32 | task wrapper(type: Wrapper) { 33 | gradleVersion = '2.1' 34 | } -------------------------------------------------------------------------------- /module-4-page-objects/build.gradle: -------------------------------------------------------------------------------- 1 | repositories { 2 | mavenLocal() 3 | jcenter() 4 | } 5 | 6 | buildscript { 7 | repositories { 8 | mavenLocal() 9 | jcenter() 10 | } 11 | dependencies { 12 | classpath("net.serenity-bdd:serenity-gradle-plugin:1.0.16") 13 | } 14 | } 15 | 16 | apply plugin: 'java' 17 | apply plugin: 'eclipse' 18 | apply plugin: 'idea' 19 | apply plugin: 'net.serenity-bdd.aggregator' 20 | 21 | sourceCompatibility = 1.8 22 | targetCompatibility = 1.8 23 | 24 | dependencies { 25 | compile 'org.slf4j:slf4j-api:1.7.5' 26 | testCompile 'junit:junit:4.11' 27 | testCompile 'org.assertj:assertj-core:1.7.0' 28 | testCompile 'net.serenity-bdd:core:1.0.16' 29 | testCompile 'net.serenity-bdd:serenity-junit:1.0.16' 30 | } 31 | 32 | task wrapper(type: Wrapper) { 33 | gradleVersion = '2.1' 34 | } -------------------------------------------------------------------------------- /module-5-test-organization/build.gradle: -------------------------------------------------------------------------------- 1 | repositories { 2 | mavenLocal() 3 | jcenter() 4 | } 5 | 6 | buildscript { 7 | repositories { 8 | mavenLocal() 9 | jcenter() 10 | } 11 | dependencies { 12 | classpath("net.serenity-bdd:serenity-gradle-plugin:1.0.16") 13 | } 14 | } 15 | 16 | apply plugin: 'java' 17 | apply plugin: 'eclipse' 18 | apply plugin: 'idea' 19 | apply plugin: 'net.serenity-bdd.aggregator' 20 | 21 | sourceCompatibility = 1.8 22 | targetCompatibility = 1.8 23 | 24 | dependencies { 25 | compile 'org.slf4j:slf4j-api:1.7.5' 26 | testCompile 'junit:junit:4.11' 27 | testCompile 'org.assertj:assertj-core:1.7.0' 28 | testCompile 'net.serenity-bdd:core:1.0.16' 29 | testCompile 'net.serenity-bdd:serenity-junit:1.0.16' 30 | } 31 | 32 | task wrapper(type: Wrapper) { 33 | gradleVersion = '2.1' 34 | } -------------------------------------------------------------------------------- /module-5-test-organization/src/test/java/com/parleys/training/exercises/home/DisplayingTheHomePageTest.java: -------------------------------------------------------------------------------- 1 | package com.parleys.training.exercises.home; 2 | 3 | import com.parleys.training.solutions.pages.HomePage; 4 | import net.thucydides.core.annotations.Managed; 5 | import net.thucydides.junit.runners.SerenityRunner; 6 | import org.junit.Test; 7 | import org.junit.runner.RunWith; 8 | import org.openqa.selenium.WebDriver; 9 | 10 | import static org.assertj.core.api.Assertions.assertThat; 11 | 12 | @RunWith(SerenityRunner.class) 13 | public class DisplayingTheHomePageTest { 14 | 15 | @Managed 16 | WebDriver driver; 17 | 18 | HomePage homePage; 19 | 20 | @Test 21 | public void shouldShowRecentFavoritesSection() { 22 | homePage.open(); 23 | assertThat(homePage.getTrendingTitle()).isIn("Recent Favorites","Recent Favourites"); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /module-3-webdriver-fundamentals/build.gradle: -------------------------------------------------------------------------------- 1 | repositories { 2 | mavenLocal() 3 | jcenter() 4 | } 5 | 6 | buildscript { 7 | repositories { 8 | mavenLocal() 9 | jcenter() 10 | } 11 | dependencies { 12 | classpath("net.serenity-bdd:serenity-gradle-plugin:1.0.16") 13 | } 14 | } 15 | 16 | apply plugin: 'java' 17 | apply plugin: 'eclipse' 18 | apply plugin: 'idea' 19 | apply plugin: 'net.serenity-bdd.aggregator' 20 | 21 | sourceCompatibility = 1.8 22 | targetCompatibility = 1.8 23 | 24 | dependencies { 25 | compile 'org.slf4j:slf4j-api:1.7.5' 26 | testCompile 'junit:junit:4.11' 27 | testCompile 'org.assertj:assertj-core:1.7.0' 28 | testCompile 'net.serenity-bdd:core:1.0.16' 29 | testCompile 'net.serenity-bdd:serenity-junit:1.0.16' 30 | } 31 | 32 | task wrapper(type: Wrapper) { 33 | gradleVersion = '2.1' 34 | } -------------------------------------------------------------------------------- /module-5-test-organization/src/test/java/com/parleys/training/exercises/pages/HomePage.java: -------------------------------------------------------------------------------- 1 | package com.parleys.training.exercises.pages; 2 | 3 | import net.thucydides.core.annotations.DefaultUrl; 4 | import net.thucydides.core.pages.PageObject; 5 | import org.openqa.selenium.WebElement; 6 | import org.openqa.selenium.support.CacheLookup; 7 | import org.openqa.selenium.support.FindBy; 8 | 9 | @DefaultUrl("http://www.etsy.com") 10 | public class HomePage extends PageObject { 11 | 12 | @CacheLookup 13 | @FindBy(id = "search-query") 14 | WebElement searchQuery; 15 | 16 | @FindBy(css = "button[value='Search']") 17 | WebElement searchButton; 18 | 19 | public void searchFor(String keywords) { 20 | searchQuery.sendKeys(keywords); 21 | searchButton.click(); 22 | } 23 | 24 | public String getTrendingTitle() { 25 | return $("#trending h2").getText(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /module-5-test-organization/src/test/java/com/parleys/training/solutions/pages/HomePage.java: -------------------------------------------------------------------------------- 1 | package com.parleys.training.solutions.pages; 2 | 3 | import net.thucydides.core.annotations.DefaultUrl; 4 | import net.thucydides.core.pages.PageObject; 5 | import org.openqa.selenium.WebElement; 6 | import org.openqa.selenium.support.CacheLookup; 7 | import org.openqa.selenium.support.FindAll; 8 | import org.openqa.selenium.support.FindBy; 9 | 10 | import java.util.List; 11 | 12 | @DefaultUrl("http://www.etsy.com") 13 | public class HomePage extends PageObject { 14 | 15 | @CacheLookup 16 | @FindBy(id = "search-query") 17 | WebElement searchQuery; 18 | 19 | @FindBy(css = "button[value='Search']") 20 | WebElement searchButton; 21 | 22 | public void searchFor(String keywords) { 23 | searchQuery.sendKeys(keywords); 24 | searchButton.click(); 25 | } 26 | 27 | public String getTrendingTitle() { 28 | return $("#trending h2").getText(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /module-4-page-objects/src/test/java/com/parleys/training/solutions/home/DisplayingTheHomePageTest.java: -------------------------------------------------------------------------------- 1 | package com.parleys.training.solutions.home; 2 | 3 | import com.parleys.training.solutions.pages.HomePage; 4 | import net.thucydides.core.annotations.Managed; 5 | import net.thucydides.junit.runners.SerenityRunner; 6 | import org.junit.After; 7 | import org.junit.Before; 8 | import org.junit.Test; 9 | import org.junit.runner.RunWith; 10 | import org.openqa.selenium.By; 11 | import org.openqa.selenium.WebDriver; 12 | import org.openqa.selenium.firefox.FirefoxDriver; 13 | 14 | import static org.assertj.core.api.Assertions.assertThat; 15 | 16 | @RunWith(SerenityRunner.class) 17 | public class DisplayingTheHomePageTest { 18 | 19 | @Managed 20 | WebDriver driver; 21 | 22 | HomePage homePage; 23 | 24 | @Test 25 | public void shouldShowRecentFavoritesSection() { 26 | homePage.open(); 27 | assertThat(homePage.getTrendingTitle()).isIn("Recent Favorites", "Recent Favourites"); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /module-1-getting-started/src/test/java/com/parleys/training/exercises/SimpleSearchTest.java: -------------------------------------------------------------------------------- 1 | package com.parleys.training.exercises; 2 | 3 | import org.junit.Test; 4 | import org.openqa.selenium.By; 5 | import org.openqa.selenium.WebDriver; 6 | import org.openqa.selenium.firefox.FirefoxDriver; 7 | 8 | import static org.assertj.core.api.Assertions.assertThat; 9 | 10 | public class SimpleSearchTest { 11 | 12 | @Test 13 | public void shouldFindInformationAboutSelenium() { 14 | 15 | WebDriver driver = new FirefoxDriver(); 16 | driver.get("http://www.wikipedia.org"); 17 | 18 | driver.findElement(By.name("search")).sendKeys("selenium"); 19 | driver.findElement(By.name("go")).click(); 20 | 21 | assertThat(driver.getTitle()).startsWith("Selenium"); 22 | 23 | driver.close(); 24 | } 25 | 26 | /** 27 | * EXERCISE 1 28 | */ 29 | @Test 30 | public void shouldFindInformationAboutFireflies() { 31 | // TODO: Write a test similar to the one above, but that searches for information about fireflies 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /module-4-page-objects/src/test/java/com/parleys/training/solutions/pages/HomePage.java: -------------------------------------------------------------------------------- 1 | package com.parleys.training.solutions.pages; 2 | 3 | import net.thucydides.core.annotations.DefaultUrl; 4 | import net.thucydides.core.pages.PageObject; 5 | import org.openqa.selenium.WebElement; 6 | import org.openqa.selenium.support.CacheLookup; 7 | import org.openqa.selenium.support.FindAll; 8 | import org.openqa.selenium.support.FindBy; 9 | import org.openqa.selenium.support.ui.ExpectedConditions; 10 | 11 | import java.util.List; 12 | 13 | @DefaultUrl("http://www.etsy.com") 14 | public class HomePage extends PageObject { 15 | 16 | @CacheLookup 17 | @FindBy(id = "search-query") 18 | WebElement searchQuery; 19 | 20 | @FindBy(css = "button[value='Search']") 21 | WebElement searchButton; 22 | 23 | public void searchFor(String keywords) { 24 | searchQuery.sendKeys(keywords); 25 | searchButton.click(); 26 | waitFor("#search-header"); 27 | } 28 | 29 | public String getTrendingTitle() { 30 | return $("#trending h2").getText(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /module-4-page-objects/src/test/java/com/parleys/training/exercises/home/DisplayingTheHomePageTest.java: -------------------------------------------------------------------------------- 1 | package com.parleys.training.exercises.home; 2 | 3 | import org.junit.After; 4 | import org.junit.Before; 5 | import org.junit.Test; 6 | import org.openqa.selenium.By; 7 | import org.openqa.selenium.WebDriver; 8 | import org.openqa.selenium.firefox.FirefoxDriver; 9 | 10 | import static org.assertj.core.api.Assertions.assertThat; 11 | 12 | public class DisplayingTheHomePageTest { 13 | 14 | WebDriver driver; 15 | 16 | @Before 17 | public void openEtsyHomePage() { 18 | driver = new FirefoxDriver(); 19 | driver.get("http://www.etsy.com"); 20 | } 21 | 22 | public void shouldShowRecentFavoritesSection() { 23 | // TODO: Refactor this to use a Serenity Page Object 24 | 25 | String trendingTitle = driver.findElement(By.cssSelector("#trending h2")).getText(); 26 | assertThat(trendingTitle).isIn("Recent Favourites", "Recent Favorites"); 27 | } 28 | 29 | @After 30 | public void closeDriver() { 31 | driver.quit(); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /module-4-page-objects/src/test/java/com/parleys/training/solutions/pages/ItemDetailsPage.java: -------------------------------------------------------------------------------- 1 | package com.parleys.training.solutions.pages; 2 | 3 | import net.thucydides.core.pages.PageObject; 4 | import org.openqa.selenium.By; 5 | import org.openqa.selenium.WebElement; 6 | import org.openqa.selenium.interactions.Actions; 7 | import org.openqa.selenium.support.FindBy; 8 | import org.openqa.selenium.support.FindBys; 9 | import org.openqa.selenium.support.ui.ExpectedConditions; 10 | import org.openqa.selenium.support.ui.Wait; 11 | import org.openqa.selenium.support.ui.WebDriverWait; 12 | 13 | /** 14 | * Created by john on 18/11/14. 15 | */ 16 | public class ItemDetailsPage extends PageObject { 17 | 18 | @FindBys({@FindBy(id="listing-page-cart"), @FindBy(tagName = "h1")}) 19 | WebElement itemName; 20 | 21 | @FindBy(css=".add-to-cart-form .btn-transaction") 22 | WebElement addToCartButton; 23 | 24 | @FindBy(id="description") 25 | WebElement descriptionTab; 26 | 27 | public String getItemName() { 28 | return itemName.getText(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /module-5-test-organization/src/test/java/com/parleys/training/solutions/home/DisplayingTheHomePageTest.java: -------------------------------------------------------------------------------- 1 | package com.parleys.training.solutions.home; 2 | 3 | import com.parleys.training.solutions.pages.HomePage; 4 | import com.parleys.training.solutions.steps.EtsyBuyer; 5 | import net.thucydides.core.annotations.Managed; 6 | import net.thucydides.core.annotations.Steps; 7 | import net.thucydides.junit.runners.SerenityRunner; 8 | import org.junit.After; 9 | import org.junit.Before; 10 | import org.junit.Test; 11 | import org.junit.runner.RunWith; 12 | import org.openqa.selenium.By; 13 | import org.openqa.selenium.WebDriver; 14 | import org.openqa.selenium.firefox.FirefoxDriver; 15 | 16 | import static org.assertj.core.api.Assertions.assertThat; 17 | 18 | @RunWith(SerenityRunner.class) 19 | public class DisplayingTheHomePageTest { 20 | 21 | @Managed 22 | WebDriver driver; 23 | 24 | HomePage homePage; 25 | 26 | @Steps 27 | EtsyBuyer buyer; 28 | 29 | @Test 30 | public void shouldShowRecentFavoritesSection() { 31 | buyer.opens_home_page(); 32 | buyer.should_see_trending_title("Recent Favourites", "Recent Favorites"); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /module-1-getting-started/src/test/java/com/parleys/training/solutions/SimpleSearchTest.java: -------------------------------------------------------------------------------- 1 | package com.parleys.training.solutions; 2 | 3 | import org.junit.Test; 4 | import org.openqa.selenium.By; 5 | import org.openqa.selenium.WebDriver; 6 | import org.openqa.selenium.firefox.FirefoxDriver; 7 | 8 | import static org.assertj.core.api.Assertions.assertThat; 9 | 10 | public class SimpleSearchTest { 11 | 12 | @Test 13 | public void shouldFindInformationAboutSelenium() { 14 | 15 | WebDriver driver = new FirefoxDriver(); 16 | driver.get("http://www.wikipedia.org"); 17 | 18 | driver.findElement(By.name("search")).sendKeys("selenium"); 19 | driver.findElement(By.name("go")).click(); 20 | 21 | assertThat(driver.getTitle()).startsWith("Selenium"); 22 | 23 | driver.close(); 24 | } 25 | 26 | @Test 27 | public void shouldFindInformationAboutFireflies() { 28 | WebDriver driver = new FirefoxDriver(); 29 | driver.get("http://www.wikipedia.org"); 30 | 31 | driver.findElement(By.name("search")).sendKeys("firefly"); 32 | driver.findElement(By.name("go")).click(); 33 | 34 | assertThat(driver.getTitle()).startsWith("Firefly"); 35 | 36 | driver.close(); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /module-4-page-objects/src/test/java/com/parleys/training/solutions/pages/SearchResultsPage.java: -------------------------------------------------------------------------------- 1 | package com.parleys.training.solutions.pages; 2 | 3 | import net.thucydides.core.pages.PageObject; 4 | import org.openqa.selenium.By; 5 | import org.openqa.selenium.WebElement; 6 | import org.openqa.selenium.support.FindBy; 7 | 8 | import java.util.List; 9 | import java.util.stream.Collectors; 10 | 11 | /** 12 | * Created by john on 18/11/14. 13 | */ 14 | public class SearchResultsPage extends PageObject { 15 | 16 | @FindBy(css=".listing-card") 17 | List listingCards; 18 | 19 | public void selectItem(int itemNumber) { 20 | listingCards.get(itemNumber - 1) 21 | .findElement(By.tagName("a")).click(); 22 | } 23 | 24 | public List getResultTitles() { 25 | return listingCards.stream() 26 | .map(element -> element.getText()) 27 | .collect(Collectors.toList()); 28 | } 29 | 30 | public String getSearchHeader() { 31 | return $("#search-header h1").getText(); 32 | } 33 | 34 | public void refineByType(String type) { 35 | $("#filter-marketplace").then(By.partialLinkText(type)).click(); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /module-5-test-organization/src/test/java/com/parleys/training/solutions/pages/SearchResultsPage.java: -------------------------------------------------------------------------------- 1 | package com.parleys.training.solutions.pages; 2 | 3 | import net.thucydides.core.pages.PageObject; 4 | import org.openqa.selenium.By; 5 | import org.openqa.selenium.WebElement; 6 | import org.openqa.selenium.support.FindBy; 7 | 8 | import java.util.List; 9 | import java.util.stream.Collectors; 10 | 11 | /** 12 | * Created by john on 18/11/14. 13 | */ 14 | public class SearchResultsPage extends PageObject { 15 | 16 | @FindBy(css=".listing-card") 17 | List listingCards; 18 | 19 | public void selectItem(int itemNumber) { 20 | listingCards.get(itemNumber - 1) 21 | .findElement(By.tagName("a")).click(); 22 | } 23 | 24 | public List getResultTitles() { 25 | return listingCards.stream() 26 | .map(element -> element.getText()) 27 | .collect(Collectors.toList()); 28 | } 29 | 30 | public String getSearchHeader() { 31 | return $("#search-header h1").getText(); 32 | } 33 | 34 | public void refineByType(String type) { 35 | $("#filter-marketplace").then(By.partialLinkText(type)).click(); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Automated Web Testing with WebDriver - Exercises 2 | ================================================ 3 | 4 | Lab exercises for the [Parleys Automated Web Testing with Webdriver](https://parleys.com/course/54687f2de4b0926f4d452598) course. 5 | 6 | This course will get you up and running with Selenium WebDriver, going from fundamental principles to more advanced automation techniques, and always with an emphasis on how to write your tests in a clean, maintainable manner that will be easy to understand and easy to change in the future. 7 | 8 | The course covers: 9 | - Fundamental principles of automated web testing 10 | - The Selenium architecture 11 | - How (and when) to use Selenium IDE for record/replay style web test automation 12 | - WebDriver fundamentals 13 | - Identifying elements using CSS, XPath 14 | - Working with HTML forms 15 | - Working with AJAX and asynchronous page elements 16 | - Using the Page Objects pattern 17 | - Structuring and reporting on your test results with the Serenity library 18 | - Setting up a Selenium Server Grid 19 | 20 | These are fundamental principles that are important to master for any serious web tester. Even if you are already familiar the basics of WebDriver, you will benefit from the later modules where we cover more advanced techniques, and learn how to use Serenity for easier web testing and better reporting. 21 | -------------------------------------------------------------------------------- /module-5-test-organization/src/test/java/com/parleys/training/exercises/pages/SearchResultsPage.java: -------------------------------------------------------------------------------- 1 | package com.parleys.training.exercises.pages; 2 | 3 | import net.thucydides.core.pages.PageObject; 4 | import org.openqa.selenium.By; 5 | import org.openqa.selenium.WebElement; 6 | import org.openqa.selenium.support.FindBy; 7 | 8 | import java.util.List; 9 | import java.util.stream.Collectors; 10 | 11 | /** 12 | * Created by john on 18/11/14. 13 | */ 14 | public class SearchResultsPage extends PageObject { 15 | 16 | @FindBy(css=".listing-card") 17 | List listingCards; 18 | 19 | public void selectItem(int itemNumber) { 20 | listingCards.get(itemNumber - 1) 21 | .findElement(By.tagName("a")).click(); 22 | } 23 | 24 | public String getItemDescription(int itemNumber) { 25 | return listingCards.get(itemNumber - 1).findElement(By.cssSelector(".title")).getText(); 26 | } 27 | 28 | public List getResultTitles() { 29 | return listingCards.stream() 30 | .map(element -> element.getText()) 31 | .collect(Collectors.toList()); 32 | } 33 | 34 | public String getSearchHeader() { 35 | return $("#search-header h1").getText(); 36 | } 37 | 38 | public void refineByType(String type) { 39 | $("#filter-marketplace").then(By.partialLinkText(type)).click(); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /module-5-test-organization/src/test/java/com/parleys/training/exercises/pages/ItemDetailsPage.java: -------------------------------------------------------------------------------- 1 | package com.parleys.training.exercises.pages; 2 | 3 | import net.thucydides.core.pages.PageObject; 4 | import org.openqa.selenium.By; 5 | import org.openqa.selenium.WebElement; 6 | import org.openqa.selenium.interactions.Actions; 7 | import org.openqa.selenium.support.FindBy; 8 | import org.openqa.selenium.support.FindBys; 9 | import org.openqa.selenium.support.ui.ExpectedConditions; 10 | import org.openqa.selenium.support.ui.Wait; 11 | import org.openqa.selenium.support.ui.WebDriverWait; 12 | 13 | /** 14 | * Created by john on 18/11/14. 15 | */ 16 | public class ItemDetailsPage extends PageObject { 17 | 18 | @FindBys({@FindBy(id="listing-page-cart"), @FindBy(tagName = "h1")}) 19 | WebElement itemName; 20 | 21 | @FindBy(css=".add-to-cart-form .btn-transaction") 22 | WebElement addToCartButton; 23 | 24 | @FindBy(id="description") 25 | WebElement descriptionTab; 26 | 27 | public String getItemName() { 28 | return itemName.getText(); 29 | } 30 | 31 | public void addToCart() { 32 | Actions actions = new Actions(getDriver()); 33 | actions.moveToElement(descriptionTab).perform(); 34 | 35 | addToCartButton.click(); 36 | 37 | Wait wait = new WebDriverWait(getDriver(), 5); 38 | wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector(".checkout-action"))); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /module-5-test-organization/src/test/java/com/parleys/training/solutions/pages/ItemDetailsPage.java: -------------------------------------------------------------------------------- 1 | package com.parleys.training.solutions.pages; 2 | 3 | import net.thucydides.core.pages.PageObject; 4 | import org.openqa.selenium.By; 5 | import org.openqa.selenium.WebElement; 6 | import org.openqa.selenium.interactions.Actions; 7 | import org.openqa.selenium.support.FindBy; 8 | import org.openqa.selenium.support.FindBys; 9 | import org.openqa.selenium.support.ui.ExpectedConditions; 10 | import org.openqa.selenium.support.ui.Wait; 11 | import org.openqa.selenium.support.ui.WebDriverWait; 12 | 13 | /** 14 | * Created by john on 18/11/14. 15 | */ 16 | public class ItemDetailsPage extends PageObject { 17 | 18 | @FindBys({@FindBy(id="listing-page-cart"), @FindBy(tagName = "h1")}) 19 | WebElement itemName; 20 | 21 | @FindBy(css=".add-to-cart-form .btn-transaction") 22 | WebElement addToCartButton; 23 | 24 | @FindBy(id="description") 25 | WebElement descriptionTab; 26 | 27 | public String getItemName() { 28 | return itemName.getText(); 29 | } 30 | 31 | public void addToCart() { 32 | Actions actions = new Actions(getDriver()); 33 | actions.moveToElement(descriptionTab).perform(); 34 | 35 | addToCartButton.click(); 36 | 37 | Wait wait = new WebDriverWait(getDriver(), 5); 38 | wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector(".checkout-action"))); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /module-3-webdriver-fundamentals/src/test/java/com/parleys/training/exercises/home/DisplayingTheEtsyHomePageTest.java: -------------------------------------------------------------------------------- 1 | package com.parleys.training.exercises.home; 2 | 3 | import org.junit.After; 4 | import org.junit.Before; 5 | import org.junit.Test; 6 | import org.openqa.selenium.By; 7 | import org.openqa.selenium.WebDriver; 8 | import org.openqa.selenium.firefox.FirefoxDriver; 9 | 10 | import static org.assertj.core.api.Assertions.assertThat; 11 | 12 | public class DisplayingTheEtsyHomePageTest { 13 | 14 | WebDriver driver; 15 | 16 | @Before 17 | public void openEtsyHomePage() { 18 | driver = new FirefoxDriver(); 19 | driver.get("http://www.etsy.com"); 20 | } 21 | 22 | @Test 23 | public void shouldShowRecentFavoritesSection() { 24 | String trendingTitle = driver.findElement(By.cssSelector("#trending h2")).getText(); 25 | assertThat(trendingTitle).isIn("Recent Favorites", "Recent Favourites"); 26 | } 27 | 28 | @Test 29 | public void shouldBeAbleToSearchByKeyword() { 30 | // TODO: 1) Implement a search that enters 'shoes' into the search field and clicks on the search button 31 | // TODO: 2) Check that the word "shoes" appears in the 'Show results for:' text 32 | } 33 | 34 | @Test 35 | public void shouldBeAbleToSearchByKeywordAndRefineByItemType() { 36 | // TODO: 1) Implement a search that enters 'shoes' into the search field and clicks on the search button 37 | // TODO: 2) On the results page, filter by Item Type 'Vintage' 38 | // TODO: 3) Check that the word "shoes" appears in the 'Show results for:' text 39 | } 40 | 41 | @Test 42 | public void shouldOnlyDisplayRelatedItemsInSearchResults() { 43 | // TODO: 1) Implement a search that enters 'shoes' into the search field and clicks on the search button 44 | // TODO: 2) Ensure that each item in the search results contains the word 'shoes' in the title 45 | } 46 | 47 | @After 48 | public void closeDriver() { 49 | driver.quit(); 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /module-4-page-objects/src/test/java/com/parleys/training/solutions/search/SearchingByKeywordTest.java: -------------------------------------------------------------------------------- 1 | package com.parleys.training.solutions.search; 2 | 3 | import com.parleys.training.solutions.pages.HomePage; 4 | import com.parleys.training.solutions.pages.ItemDetailsPage; 5 | import com.parleys.training.solutions.pages.SearchResultsPage; 6 | import net.thucydides.core.annotations.Managed; 7 | import net.thucydides.junit.runners.SerenityRunner; 8 | import org.junit.After; 9 | import org.junit.Before; 10 | import org.junit.Test; 11 | import org.junit.runner.RunWith; 12 | import org.openqa.selenium.By; 13 | import org.openqa.selenium.WebDriver; 14 | 15 | import static org.assertj.core.api.Assertions.assertThat; 16 | 17 | @RunWith(SerenityRunner.class) 18 | public class SearchingByKeywordTest { 19 | 20 | @Managed 21 | WebDriver driver; 22 | 23 | HomePage homePage; 24 | SearchResultsPage searchResultsPage; 25 | ItemDetailsPage detailsPage; 26 | 27 | @Before 28 | public void openEtsyHomePage() { 29 | homePage.open(); 30 | } 31 | 32 | @Test 33 | public void shouldBeAbleToSearchByKeyword() { 34 | homePage.searchFor("shoes"); 35 | assertThat(searchResultsPage.getSearchHeader()).contains("shoes"); 36 | } 37 | 38 | @Test 39 | public void shouldBeAbleToSearchByKeywordAndRefineByItemType() { 40 | 41 | homePage.searchFor("shoes"); 42 | searchResultsPage.refineByType("Vintage"); 43 | assertThat(searchResultsPage.getSearchHeader()).contains("shoes"); 44 | } 45 | 46 | @Test 47 | public void shouldOnlyDisplayRelatedItemsInSearchResults() { 48 | 49 | homePage.searchFor("shoes"); 50 | 51 | searchResultsPage.getResultTitles().stream() 52 | .forEach(title -> assertThat(title.contains("shoes"))); 53 | } 54 | 55 | 56 | @Test 57 | public void shouldOpenCorrespondingItemFromSearchListUsingPageObjects() { 58 | homePage.searchFor("wool"); 59 | searchResultsPage.selectItem(1); 60 | assertThat(detailsPage.getItemName()).containsIgnoringCase("wool"); 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /module-5-test-organization/src/test/java/com/parleys/training/exercises/search/SearchingByKeywordTest.java: -------------------------------------------------------------------------------- 1 | package com.parleys.training.exercises.search; 2 | 3 | import com.parleys.training.solutions.pages.HomePage; 4 | import com.parleys.training.solutions.pages.ItemDetailsPage; 5 | import com.parleys.training.solutions.pages.SearchResultsPage; 6 | import net.thucydides.core.annotations.Managed; 7 | import net.thucydides.junit.runners.SerenityRunner; 8 | import org.junit.After; 9 | import org.junit.Before; 10 | import org.junit.Test; 11 | import org.junit.runner.RunWith; 12 | import org.openqa.selenium.By; 13 | import org.openqa.selenium.WebDriver; 14 | 15 | import static org.assertj.core.api.Assertions.assertThat; 16 | 17 | @RunWith(SerenityRunner.class) 18 | public class SearchingByKeywordTest { 19 | 20 | @Managed 21 | WebDriver driver; 22 | 23 | HomePage homePage; 24 | SearchResultsPage searchResultsPage; 25 | ItemDetailsPage detailsPage; 26 | 27 | @Before 28 | public void openEtsyHomePage() { 29 | homePage.open(); 30 | } 31 | 32 | @Test 33 | public void shouldBeAbleToSearchByKeyword() { 34 | homePage.searchFor("shoes"); 35 | assertThat(searchResultsPage.getSearchHeader()).contains("shoes"); 36 | } 37 | 38 | @Test 39 | public void shouldBeAbleToSearchByKeywordAndRefineByItemType() { 40 | 41 | homePage.searchFor("shoes"); 42 | searchResultsPage.refineByType("Vintage"); 43 | assertThat(searchResultsPage.getSearchHeader()).contains("shoes"); 44 | } 45 | 46 | @Test 47 | public void shouldOnlyDisplayRelatedItemsInSearchResults() { 48 | 49 | homePage.searchFor("shoes"); 50 | 51 | searchResultsPage.getResultTitles().stream() 52 | .forEach(title -> assertThat(title.contains("shoes"))); 53 | } 54 | 55 | 56 | @Test 57 | public void shouldOpenCorrespondingItemFromSearchListUsingPageObjects() { 58 | homePage.searchFor("wool"); 59 | searchResultsPage.selectItem(1); 60 | assertThat(detailsPage.getItemName()).containsIgnoringCase("wool"); 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /module-5-test-organization/src/test/java/com/parleys/training/solutions/search/SearchingByKeywordTest.java: -------------------------------------------------------------------------------- 1 | package com.parleys.training.solutions.search; 2 | 3 | import com.parleys.training.solutions.pages.HomePage; 4 | import com.parleys.training.solutions.pages.ItemDetailsPage; 5 | import com.parleys.training.solutions.pages.SearchResultsPage; 6 | import com.parleys.training.solutions.steps.EtsyBuyer; 7 | import net.thucydides.core.annotations.Managed; 8 | import net.thucydides.core.annotations.Steps; 9 | import net.thucydides.junit.runners.SerenityRunner; 10 | import org.junit.After; 11 | import org.junit.Before; 12 | import org.junit.Test; 13 | import org.junit.runner.RunWith; 14 | import org.openqa.selenium.By; 15 | import org.openqa.selenium.WebDriver; 16 | 17 | import static org.assertj.core.api.Assertions.assertThat; 18 | 19 | @RunWith(SerenityRunner.class) 20 | public class SearchingByKeywordTest { 21 | 22 | @Managed 23 | WebDriver driver; 24 | 25 | HomePage homePage; 26 | SearchResultsPage searchResultsPage; 27 | ItemDetailsPage detailsPage; 28 | 29 | @Steps 30 | EtsyBuyer buyer; 31 | 32 | @Before 33 | public void openEtsyHomePage() { 34 | buyer.opens_home_page(); 35 | } 36 | 37 | @Test 38 | public void shouldBeAbleToSearchByKeyword() { 39 | buyer.searches_for_items_containing("shoes"); 40 | buyer.should_see_search_header_containing("shoes"); 41 | } 42 | 43 | @Test 44 | public void shouldBeAbleToSearchByKeywordAndRefineByItemType() { 45 | buyer.searches_for_items_containing("shoes"); 46 | buyer.refines_search_by_type("Vintage"); 47 | buyer.should_see_search_header_containing("shoes"); 48 | } 49 | 50 | @Test 51 | public void shouldOnlyDisplayRelatedItemsInSearchResults() { 52 | buyer.searches_for_items_containing("shoes"); 53 | buyer.should_see_items_related_to("shoes"); 54 | } 55 | 56 | 57 | @Test 58 | public void shouldOpenCorrespondingItemFromSearchListUsingPageObjects() { 59 | buyer.searches_for_items_containing("shoes"); 60 | buyer.selects_item_number(1); 61 | buyer.should_see_matching_details(); 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /module-5-test-organization/src/test/java/com/parleys/training/solutions/steps/EtsyBuyer.java: -------------------------------------------------------------------------------- 1 | package com.parleys.training.solutions.steps; 2 | 3 | import com.parleys.training.exercises.pages.ItemDetailsPage; 4 | import com.parleys.training.exercises.pages.SearchResultsPage; 5 | import com.parleys.training.solutions.pages.HomePage; 6 | import net.thucydides.core.annotations.Step; 7 | import net.thucydides.core.annotations.Steps; 8 | import net.thucydides.core.steps.ScenarioSteps; 9 | 10 | import java.util.List; 11 | 12 | import static org.assertj.core.api.Assertions.assertThat; 13 | 14 | /** 15 | * Created by john on 11/12/14. 16 | */ 17 | public class EtsyBuyer extends ScenarioSteps { 18 | 19 | HomePage homePage; 20 | SearchResultsPage searchResultsPage; 21 | ItemDetailsPage detailsPage; 22 | 23 | @Step 24 | public void opens_home_page() { 25 | homePage.open(); 26 | } 27 | 28 | @Step 29 | public void should_see_trending_title(String... allowedExpectedTitles) { 30 | assertThat(homePage.getTrendingTitle()).isIn(allowedExpectedTitles); 31 | 32 | } 33 | 34 | @Step 35 | public void searches_for_items_containing(String keywords) { 36 | homePage.searchFor(keywords); 37 | 38 | } 39 | 40 | @Step 41 | public void should_see_search_header_containing(String keywords) { 42 | assertThat(searchResultsPage.getSearchHeader()).contains(keywords); 43 | 44 | } 45 | 46 | @Step 47 | public void refines_search_by_type(String type) { 48 | searchResultsPage.refineByType(type); 49 | } 50 | 51 | @Step 52 | public void should_see_items_related_to(String keywords) { 53 | List resultTitles = searchResultsPage.getResultTitles(); 54 | resultTitles.stream().forEach(title -> assertThat(title.contains(keywords))); 55 | } 56 | 57 | String selectedItemDescription; 58 | 59 | @Step 60 | public void selects_item_number(int number) { 61 | selectedItemDescription = searchResultsPage.getItemDescription(number); 62 | searchResultsPage.selectItem(number); 63 | } 64 | 65 | @Step 66 | public void should_see_matching_details() { 67 | assertThat(detailsPage.getItemName()).containsIgnoringCase(selectedItemDescription); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /module-4-page-objects/src/test/java/com/parleys/training/exercises/search/SearchingByKeywordTest.java: -------------------------------------------------------------------------------- 1 | package com.parleys.training.exercises.search; 2 | 3 | import org.junit.After; 4 | import org.junit.Before; 5 | import org.junit.Test; 6 | import org.openqa.selenium.By; 7 | import org.openqa.selenium.WebDriver; 8 | import org.openqa.selenium.firefox.FirefoxDriver; 9 | 10 | import static org.assertj.core.api.Assertions.assertThat; 11 | 12 | public class SearchingByKeywordTest { 13 | 14 | WebDriver driver; 15 | 16 | @Before 17 | public void openEtsyHomePage() { 18 | driver = new FirefoxDriver(); 19 | driver.get("http://www.etsy.com"); 20 | } 21 | 22 | @Test 23 | public void shouldBeAbleToSearchByKeyword() { 24 | // TODO: Refactor this to use two Serenity Page Objects 25 | 26 | driver.findElement(By.id("search-query")).sendKeys("shoes"); 27 | driver.findElement(By.cssSelector(".btn-primary[value='Search']")).click(); 28 | 29 | String summaryText = driver.findElement(By.cssSelector("#search-header h1")).getText(); 30 | assertThat(summaryText).contains("shoes"); 31 | } 32 | 33 | @Test 34 | public void shouldBeAbleToSearchByKeywordAndRefineByItemType() { 35 | // TODO: Refactor this to use two Serenity Page Objects 36 | 37 | driver.findElement(By.id("search-query")).sendKeys("shoes"); 38 | driver.findElement(By.cssSelector(".btn-primary[value='Search']")).click(); 39 | 40 | driver.findElement(By.id("filter-marketplace")).findElement(By.partialLinkText("Vintage")).click(); 41 | 42 | String summaryText = driver.findElement(By.cssSelector("#search-header h1")).getText(); 43 | assertThat(summaryText).contains("shoes"); 44 | } 45 | 46 | @Test 47 | public void shouldOnlyDisplayRelatedItemsInSearchResults() { 48 | // TODO: Refactor this to use two Serenity Page Objects 49 | 50 | driver.findElement(By.id("search-query")).sendKeys("shoes"); 51 | driver.findElement(By.cssSelector(".btn-primary[value='Search']")).click(); 52 | 53 | driver.findElements(By.cssSelector(".listing-card")).stream() 54 | .forEach(element -> assertThat(element.getText().contains("shoes"))); 55 | } 56 | 57 | @After 58 | public void closeDriver() { 59 | driver.quit(); 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /module-3-webdriver-fundamentals/src/test/java/com/parleys/training/solutions/home/DisplayingTheEtsyHomePageTest.java: -------------------------------------------------------------------------------- 1 | package com.parleys.training.solutions.home; 2 | 3 | import org.junit.After; 4 | import org.junit.Before; 5 | import org.junit.Test; 6 | import org.openqa.selenium.By; 7 | import org.openqa.selenium.WebDriver; 8 | import org.openqa.selenium.firefox.FirefoxDriver; 9 | 10 | import static org.assertj.core.api.Assertions.assertThat; 11 | 12 | public class DisplayingTheEtsyHomePageTest { 13 | 14 | WebDriver driver; 15 | 16 | @Before 17 | public void openEtsyHomePage() { 18 | driver = new FirefoxDriver(); 19 | driver.get("http://www.etsy.com"); 20 | } 21 | 22 | @Test 23 | public void shouldShowRecentFavoritesSection() { 24 | String trendingTitle = driver.findElement(By.cssSelector("#trending h2")).getText(); 25 | assertThat(trendingTitle).isIn("Recent Favorites","Recent Favourites"); 26 | } 27 | 28 | @Test 29 | public void shouldBeAbleToSearchByKeyword() { 30 | driver.findElement(By.id("search-query")).sendKeys("shoes"); 31 | driver.findElement(By.cssSelector(".btn-primary[value='Search']")).click(); 32 | 33 | String summaryText = driver.findElement(By.cssSelector("#search-header h1")).getText(); 34 | assertThat(summaryText).contains("shoes"); 35 | } 36 | 37 | @Test 38 | public void shouldBeAbleToSearchByKeywordAndRefineByItemType() { 39 | driver.findElement(By.id("search-query")).sendKeys("shoes"); 40 | driver.findElement(By.cssSelector(".btn-primary[value='Search']")).click(); 41 | 42 | driver.findElement(By.id("filter-marketplace")).findElement(By.partialLinkText("Vintage")).click(); 43 | 44 | String summaryText = driver.findElement(By.cssSelector("#search-header h1")).getText(); 45 | assertThat(summaryText).contains("shoes"); 46 | } 47 | 48 | @Test 49 | public void shouldOnlyDisplayRelatedItemsInSearchResults() { 50 | driver.findElement(By.id("search-query")).sendKeys("shoes"); 51 | driver.findElement(By.cssSelector(".btn-primary[value='Search']")).click(); 52 | 53 | driver.findElements(By.cssSelector(".listing-card")).stream() 54 | .forEach(element -> assertThat(element.getText().contains("shoes"))); 55 | } 56 | 57 | @After 58 | public void closeDriver() { 59 | driver.quit(); 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /module-4-page-objects/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /module-1-getting-started/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /module-5-test-organization/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /module-3-webdriver-fundamentals/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /module-4-page-objects/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.parleys.training.webdriver 7 | esty-tester 8 | 0.0.1-SNAPSHOT 9 | jar 10 | 11 | Etsy test suite 12 | 13 | 14 | UTF-8 15 | 1.0.16 16 | 1.0.16 17 | firefox 18 | 19 | 20 | 21 | 22 | 23 | net.serenity-bdd 24 | core 25 | ${serenity.version} 26 | 27 | 28 | net.serenity-bdd 29 | serenity-junit 30 | ${serenity.version} 31 | 32 | 33 | org.slf4j 34 | slf4j-simple 35 | 1.6.1 36 | 37 | 38 | junit 39 | junit 40 | 4.11 41 | test 42 | 43 | 44 | org.assertj 45 | assertj-core 46 | 1.7.0 47 | test 48 | 49 | 50 | 51 | 52 | 53 | 54 | org.apache.maven.plugins 55 | maven-compiler-plugin 56 | 3.2 57 | 58 | 1.8 59 | 1.8 60 | 61 | 62 | 63 | 64 | 65 | maven-surefire-plugin 66 | 67 | true 68 | 69 | 70 | 71 | 72 | 73 | maven-failsafe-plugin 74 | 2.18 75 | 76 | 77 | **/*Test.java 78 | **/When*.java 79 | 80 | 81 | 82 | 83 | 84 | integration-test 85 | verify 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | net.serenity-bdd.maven.plugins 94 | serenity-maven-plugin 95 | ${serenity.maven.version} 96 | 97 | 98 | serenity-reports 99 | post-integration-test 100 | 101 | aggregate 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | -------------------------------------------------------------------------------- /module-1-getting-started/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.parleys.training.webdriver 7 | esty-tester 8 | 0.0.1-SNAPSHOT 9 | jar 10 | 11 | Etsy test suite 12 | 13 | 14 | UTF-8 15 | 1.0.16 16 | 1.0.16 17 | firefox 18 | 19 | 20 | 21 | 22 | 23 | net.serenity-bdd 24 | core 25 | ${serenity.version} 26 | 27 | 28 | net.serenity-bdd 29 | serenity-junit 30 | ${serenity.version} 31 | 32 | 33 | org.slf4j 34 | slf4j-simple 35 | 1.6.1 36 | 37 | 38 | junit 39 | junit 40 | 4.11 41 | test 42 | 43 | 44 | org.assertj 45 | assertj-core 46 | 1.7.0 47 | test 48 | 49 | 50 | 51 | 52 | 53 | 54 | org.apache.maven.plugins 55 | maven-compiler-plugin 56 | 3.2 57 | 58 | 1.8 59 | 1.8 60 | 61 | 62 | 63 | 64 | 65 | maven-surefire-plugin 66 | 67 | true 68 | 69 | 70 | 71 | 72 | 73 | maven-failsafe-plugin 74 | 2.18 75 | 76 | 77 | **/*Test.java 78 | **/When*.java 79 | 80 | 81 | 82 | 83 | 84 | integration-test 85 | verify 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | net.serenity-bdd.maven.plugins 94 | serenity-maven-plugin 95 | ${serenity.maven.version} 96 | 97 | 98 | serenity-reports 99 | post-integration-test 100 | 101 | aggregate 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | -------------------------------------------------------------------------------- /module-5-test-organization/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.parleys.training.webdriver 7 | esty-tester 8 | 0.0.1-SNAPSHOT 9 | jar 10 | 11 | Etsy test suite 12 | 13 | 14 | UTF-8 15 | 1.0.16 16 | 1.0.16 17 | firefox 18 | 19 | 20 | 21 | 22 | 23 | net.serenity-bdd 24 | core 25 | ${serenity.version} 26 | 27 | 28 | net.serenity-bdd 29 | serenity-junit 30 | ${serenity.version} 31 | 32 | 33 | org.slf4j 34 | slf4j-simple 35 | 1.6.1 36 | 37 | 38 | junit 39 | junit 40 | 4.11 41 | test 42 | 43 | 44 | org.assertj 45 | assertj-core 46 | 1.7.0 47 | test 48 | 49 | 50 | 51 | 52 | 53 | 54 | org.apache.maven.plugins 55 | maven-compiler-plugin 56 | 3.2 57 | 58 | 1.8 59 | 1.8 60 | 61 | 62 | 63 | 64 | 65 | maven-surefire-plugin 66 | 67 | true 68 | 69 | 70 | 71 | 72 | 73 | maven-failsafe-plugin 74 | 2.18 75 | 76 | 77 | **/*Test.java 78 | **/When*.java 79 | 80 | 81 | 82 | 83 | 84 | integration-test 85 | verify 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | net.serenity-bdd.maven.plugins 94 | serenity-maven-plugin 95 | ${serenity.maven.version} 96 | 97 | 98 | serenity-reports 99 | post-integration-test 100 | 101 | aggregate 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | -------------------------------------------------------------------------------- /module-3-webdriver-fundamentals/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.parleys.training.webdriver 7 | esty-tester 8 | 0.0.1-SNAPSHOT 9 | jar 10 | 11 | Etsy test suite 12 | 13 | 14 | UTF-8 15 | 1.0.16 16 | 1.0.16 17 | firefox 18 | 19 | 20 | 21 | 22 | 23 | net.serenity-bdd 24 | core 25 | ${serenity.version} 26 | 27 | 28 | net.serenity-bdd 29 | serenity-junit 30 | ${serenity.version} 31 | 32 | 33 | org.slf4j 34 | slf4j-simple 35 | 1.6.1 36 | 37 | 38 | junit 39 | junit 40 | 4.11 41 | test 42 | 43 | 44 | org.assertj 45 | assertj-core 46 | 1.7.0 47 | test 48 | 49 | 50 | 51 | 52 | 53 | 54 | org.apache.maven.plugins 55 | maven-compiler-plugin 56 | 3.2 57 | 58 | 1.8 59 | 1.8 60 | 61 | 62 | 63 | 64 | 65 | maven-surefire-plugin 66 | 67 | true 68 | 69 | 70 | 71 | 72 | 73 | maven-failsafe-plugin 74 | 2.18 75 | 76 | 77 | **/*Test.java 78 | **/When*.java 79 | 80 | 81 | 82 | 83 | 84 | integration-test 85 | verify 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | net.serenity-bdd.maven.plugins 94 | serenity-maven-plugin 95 | ${serenity.maven.version} 96 | 97 | 98 | serenity-reports 99 | post-integration-test 100 | 101 | aggregate 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | -------------------------------------------------------------------------------- /module-1-getting-started/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # For Cygwin, ensure paths are in UNIX format before anything is touched. 46 | if $cygwin ; then 47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 48 | fi 49 | 50 | # Attempt to set APP_HOME 51 | # Resolve links: $0 may be a link 52 | PRG="$0" 53 | # Need this for relative symlinks. 54 | while [ -h "$PRG" ] ; do 55 | ls=`ls -ld "$PRG"` 56 | link=`expr "$ls" : '.*-> \(.*\)$'` 57 | if expr "$link" : '/.*' > /dev/null; then 58 | PRG="$link" 59 | else 60 | PRG=`dirname "$PRG"`"/$link" 61 | fi 62 | done 63 | SAVED="`pwd`" 64 | cd "`dirname \"$PRG\"`/" >&- 65 | APP_HOME="`pwd -P`" 66 | cd "$SAVED" >&- 67 | 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69 | 70 | # Determine the Java command to use to start the JVM. 71 | if [ -n "$JAVA_HOME" ] ; then 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73 | # IBM's JDK on AIX uses strange locations for the executables 74 | JAVACMD="$JAVA_HOME/jre/sh/java" 75 | else 76 | JAVACMD="$JAVA_HOME/bin/java" 77 | fi 78 | if [ ! -x "$JAVACMD" ] ; then 79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80 | 81 | Please set the JAVA_HOME variable in your environment to match the 82 | location of your Java installation." 83 | fi 84 | else 85 | JAVACMD="java" 86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87 | 88 | Please set the JAVA_HOME variable in your environment to match the 89 | location of your Java installation." 90 | fi 91 | 92 | # Increase the maximum file descriptors if we can. 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 94 | MAX_FD_LIMIT=`ulimit -H -n` 95 | if [ $? -eq 0 ] ; then 96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97 | MAX_FD="$MAX_FD_LIMIT" 98 | fi 99 | ulimit -n $MAX_FD 100 | if [ $? -ne 0 ] ; then 101 | warn "Could not set maximum file descriptor limit: $MAX_FD" 102 | fi 103 | else 104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105 | fi 106 | fi 107 | 108 | # For Darwin, add options to specify how the application appears in the dock 109 | if $darwin; then 110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111 | fi 112 | 113 | # For Cygwin, switch paths to Windows format before running java 114 | if $cygwin ; then 115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 158 | function splitJvmOpts() { 159 | JVM_OPTS=("$@") 160 | } 161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 163 | 164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 165 | -------------------------------------------------------------------------------- /module-4-page-objects/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # For Cygwin, ensure paths are in UNIX format before anything is touched. 46 | if $cygwin ; then 47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 48 | fi 49 | 50 | # Attempt to set APP_HOME 51 | # Resolve links: $0 may be a link 52 | PRG="$0" 53 | # Need this for relative symlinks. 54 | while [ -h "$PRG" ] ; do 55 | ls=`ls -ld "$PRG"` 56 | link=`expr "$ls" : '.*-> \(.*\)$'` 57 | if expr "$link" : '/.*' > /dev/null; then 58 | PRG="$link" 59 | else 60 | PRG=`dirname "$PRG"`"/$link" 61 | fi 62 | done 63 | SAVED="`pwd`" 64 | cd "`dirname \"$PRG\"`/" >&- 65 | APP_HOME="`pwd -P`" 66 | cd "$SAVED" >&- 67 | 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69 | 70 | # Determine the Java command to use to start the JVM. 71 | if [ -n "$JAVA_HOME" ] ; then 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73 | # IBM's JDK on AIX uses strange locations for the executables 74 | JAVACMD="$JAVA_HOME/jre/sh/java" 75 | else 76 | JAVACMD="$JAVA_HOME/bin/java" 77 | fi 78 | if [ ! -x "$JAVACMD" ] ; then 79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80 | 81 | Please set the JAVA_HOME variable in your environment to match the 82 | location of your Java installation." 83 | fi 84 | else 85 | JAVACMD="java" 86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87 | 88 | Please set the JAVA_HOME variable in your environment to match the 89 | location of your Java installation." 90 | fi 91 | 92 | # Increase the maximum file descriptors if we can. 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 94 | MAX_FD_LIMIT=`ulimit -H -n` 95 | if [ $? -eq 0 ] ; then 96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97 | MAX_FD="$MAX_FD_LIMIT" 98 | fi 99 | ulimit -n $MAX_FD 100 | if [ $? -ne 0 ] ; then 101 | warn "Could not set maximum file descriptor limit: $MAX_FD" 102 | fi 103 | else 104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105 | fi 106 | fi 107 | 108 | # For Darwin, add options to specify how the application appears in the dock 109 | if $darwin; then 110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111 | fi 112 | 113 | # For Cygwin, switch paths to Windows format before running java 114 | if $cygwin ; then 115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 158 | function splitJvmOpts() { 159 | JVM_OPTS=("$@") 160 | } 161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 163 | 164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 165 | -------------------------------------------------------------------------------- /module-5-test-organization/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # For Cygwin, ensure paths are in UNIX format before anything is touched. 46 | if $cygwin ; then 47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 48 | fi 49 | 50 | # Attempt to set APP_HOME 51 | # Resolve links: $0 may be a link 52 | PRG="$0" 53 | # Need this for relative symlinks. 54 | while [ -h "$PRG" ] ; do 55 | ls=`ls -ld "$PRG"` 56 | link=`expr "$ls" : '.*-> \(.*\)$'` 57 | if expr "$link" : '/.*' > /dev/null; then 58 | PRG="$link" 59 | else 60 | PRG=`dirname "$PRG"`"/$link" 61 | fi 62 | done 63 | SAVED="`pwd`" 64 | cd "`dirname \"$PRG\"`/" >&- 65 | APP_HOME="`pwd -P`" 66 | cd "$SAVED" >&- 67 | 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69 | 70 | # Determine the Java command to use to start the JVM. 71 | if [ -n "$JAVA_HOME" ] ; then 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73 | # IBM's JDK on AIX uses strange locations for the executables 74 | JAVACMD="$JAVA_HOME/jre/sh/java" 75 | else 76 | JAVACMD="$JAVA_HOME/bin/java" 77 | fi 78 | if [ ! -x "$JAVACMD" ] ; then 79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80 | 81 | Please set the JAVA_HOME variable in your environment to match the 82 | location of your Java installation." 83 | fi 84 | else 85 | JAVACMD="java" 86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87 | 88 | Please set the JAVA_HOME variable in your environment to match the 89 | location of your Java installation." 90 | fi 91 | 92 | # Increase the maximum file descriptors if we can. 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 94 | MAX_FD_LIMIT=`ulimit -H -n` 95 | if [ $? -eq 0 ] ; then 96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97 | MAX_FD="$MAX_FD_LIMIT" 98 | fi 99 | ulimit -n $MAX_FD 100 | if [ $? -ne 0 ] ; then 101 | warn "Could not set maximum file descriptor limit: $MAX_FD" 102 | fi 103 | else 104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105 | fi 106 | fi 107 | 108 | # For Darwin, add options to specify how the application appears in the dock 109 | if $darwin; then 110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111 | fi 112 | 113 | # For Cygwin, switch paths to Windows format before running java 114 | if $cygwin ; then 115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 158 | function splitJvmOpts() { 159 | JVM_OPTS=("$@") 160 | } 161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 163 | 164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 165 | -------------------------------------------------------------------------------- /module-3-webdriver-fundamentals/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # For Cygwin, ensure paths are in UNIX format before anything is touched. 46 | if $cygwin ; then 47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 48 | fi 49 | 50 | # Attempt to set APP_HOME 51 | # Resolve links: $0 may be a link 52 | PRG="$0" 53 | # Need this for relative symlinks. 54 | while [ -h "$PRG" ] ; do 55 | ls=`ls -ld "$PRG"` 56 | link=`expr "$ls" : '.*-> \(.*\)$'` 57 | if expr "$link" : '/.*' > /dev/null; then 58 | PRG="$link" 59 | else 60 | PRG=`dirname "$PRG"`"/$link" 61 | fi 62 | done 63 | SAVED="`pwd`" 64 | cd "`dirname \"$PRG\"`/" >&- 65 | APP_HOME="`pwd -P`" 66 | cd "$SAVED" >&- 67 | 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69 | 70 | # Determine the Java command to use to start the JVM. 71 | if [ -n "$JAVA_HOME" ] ; then 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73 | # IBM's JDK on AIX uses strange locations for the executables 74 | JAVACMD="$JAVA_HOME/jre/sh/java" 75 | else 76 | JAVACMD="$JAVA_HOME/bin/java" 77 | fi 78 | if [ ! -x "$JAVACMD" ] ; then 79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80 | 81 | Please set the JAVA_HOME variable in your environment to match the 82 | location of your Java installation." 83 | fi 84 | else 85 | JAVACMD="java" 86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87 | 88 | Please set the JAVA_HOME variable in your environment to match the 89 | location of your Java installation." 90 | fi 91 | 92 | # Increase the maximum file descriptors if we can. 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 94 | MAX_FD_LIMIT=`ulimit -H -n` 95 | if [ $? -eq 0 ] ; then 96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97 | MAX_FD="$MAX_FD_LIMIT" 98 | fi 99 | ulimit -n $MAX_FD 100 | if [ $? -ne 0 ] ; then 101 | warn "Could not set maximum file descriptor limit: $MAX_FD" 102 | fi 103 | else 104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105 | fi 106 | fi 107 | 108 | # For Darwin, add options to specify how the application appears in the dock 109 | if $darwin; then 110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111 | fi 112 | 113 | # For Cygwin, switch paths to Windows format before running java 114 | if $cygwin ; then 115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 158 | function splitJvmOpts() { 159 | JVM_OPTS=("$@") 160 | } 161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 163 | 164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 165 | --------------------------------------------------------------------------------