SHARE
TWEET

Untitled

a guest Mar 20th, 2016 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. package acceptancetest;
  3.  
  4. import acceptancetest.helpers.InputHelper;
  5. import acceptancetest.helpers.LoginHelper;
  6. import org.junit.After;
  7. import org.junit.Assert;
  8. import org.junit.Before;
  9. import org.junit.Test;
  10. import org.openqa.selenium.By;
  11. import org.openqa.selenium.WebDriver;
  12. import org.openqa.selenium.WebElement;
  13. import org.openqa.selenium.chrome.ChromeDriver;
  14. import org.openqa.selenium.support.ui.WebDriverWait;
  15.  
  16. import java.util.List;
  17.  
  18. public class ATCompleteFlow {
  19.     private String baseUrl;
  20.     private String username = "user";
  21.     private String password = "pass";
  22.     private String organizationName = "Karel De Grote";
  23.     private String categoryName = "Toegepaste Informatica";
  24.     private String topicName = "Naschoolse activiteit";
  25.     private String cardName1 = "Pretpark";
  26.     private String cardName2="Zee";
  27.     private String cardName3="Vakantie";
  28.     private String cardName4="Boekenbeurs";
  29.     WebDriver driver;
  30.  
  31.     @Before
  32.     public void setup() {
  33.         baseUrl = System.getProperty("app.baseUrl");
  34.         driver = new ChromeDriver();
  35.         LoginHelper.login(driver, username, password);
  36.         driver.get(String.format("%s/#/organization/create", baseUrl));
  37.     }
  38.  
  39.     @Test
  40.     public void testCreateNewOrganization() {
  41.         //Create Organization
  42.  
  43.         (new WebDriverWait(driver, 5)).until(
  44.                 (WebDriver d) -> d.findElement(By.name("new-organization")) != null
  45.         );
  46.         WebElement newOrganizationButton = driver.findElement(By.name("new-organization"));
  47.         newOrganizationButton.click();
  48.  
  49.  
  50.         (new WebDriverWait(driver, 5)).until(
  51.                 (WebDriver d) -> d.findElement(By.name("form-new-organization")) != null
  52.         );
  53.  
  54.         WebElement nameElement = driver.findElement(By.name("organization-name"));
  55.         InputHelper.sendKeys(driver, nameElement, organizationName);
  56.  
  57.         driver.findElement(By.name("add-organization")).click();
  58.  
  59.  
  60.         (new WebDriverWait(driver, 5)).until(
  61.                 (WebDriver d) -> d.findElement(By.name("my-organizations")) != null
  62.         );
  63.         driver.findElement(By.name("my-organizations")).click();
  64.  
  65.         (new WebDriverWait(driver, 5)).until(
  66.                 (WebDriver d) -> d.findElement(By.className(organizationName)) != null
  67.         );
  68.  
  69.         driver.findElement(By.name(organizationName)).click();
  70.  
  71.         //Create Category
  72.         driver.findElement(By.name("new-category")).click();
  73.  
  74.         WebElement catNameElement = driver.findElement(By.name("category-name"));
  75.         InputHelper.sendKeys(driver, catNameElement, categoryName);
  76.  
  77.         WebElement descriptionElement = driver.findElement(By.name("category-description"));
  78.         InputHelper.sendKeys(driver, descriptionElement, "This is a description for the category Toegepaste Informatica in the organization Karel de grote");
  79.  
  80.         driver.findElement(By.name("add-category")).click();
  81.  
  82.  
  83.         List<WebElement> blockElements = driver.findElements(By.cssSelector(".black-block"));
  84.         blockElements.get(1).click();
  85.  
  86.         //Create Topic
  87.         (new WebDriverWait(driver, 5)).until(
  88.                 (WebDriver d) -> d.findElement(By.name("new-topic")) != null
  89.         );
  90.         driver.findElement(By.name("new-topic")).click();
  91.  
  92.         WebElement topicNameElement = driver.findElement(By.name("topic-name"));
  93.         InputHelper.sendKeys(driver, topicNameElement, topicName);
  94.  
  95.         WebElement topicDescriptionElement = driver.findElement(By.name("topic-description"));
  96.         InputHelper.sendKeys(driver, topicDescriptionElement, "This is a description for the topic naschoolse activiteit in toegepaste informatica");
  97.  
  98.         (new WebDriverWait(driver, 5)).until(
  99.                 (WebDriver d) -> d.findElement(By.name("add-topic")) != null
  100.         );
  101.         driver.findElement(By.name("add-topic")).click();
  102.  
  103.         //Create Cards in Category
  104.         (new WebDriverWait(driver, 5)).until(
  105.                 (WebDriver d) -> d.findElement(By.name("new-card")) != null
  106.         );
  107.         driver.findElement(By.name("new-card")).click();
  108.         WebElement cardNameElement = driver.findElement(By.name("card-text"));
  109.         InputHelper.sendKeys(driver, cardNameElement, cardName1);
  110.         WebElement cardImageElement = driver.findElement(By.name("card-image"));
  111.         InputHelper.sendKeys(driver, cardImageElement, "http://lastminutesnederland.nl/wp-content/uploads/2012/11/pretpark.jpg");
  112.         (new WebDriverWait(driver, 5)).until(
  113.                 (WebDriver d) -> d.findElement(By.name("add-card")) != null
  114.         );
  115.         driver.findElement(By.name("add-card")).click();
  116.  
  117.         (new WebDriverWait(driver, 5)).until(
  118.                 (WebDriver d) -> d.findElement(By.name("new-card")) != null
  119.         );
  120.         driver.findElement(By.name("new-card")).click();
  121.         WebElement cardName2Element = driver.findElement(By.name("card-text"));
  122.         InputHelper.sendKeys(driver, cardName2Element, cardName2);
  123.         WebElement cardImage2Element = driver.findElement(By.name("card-image"));
  124.         InputHelper.sendKeys(driver, cardImage2Element, "http://www.photofacts.nl/fotografie/foto/et/arjan-de-wit-zeeschap.jpg");
  125.         (new WebDriverWait(driver, 5)).until(
  126.                 (WebDriver d) -> d.findElement(By.name("add-card")) != null
  127.         );
  128.         driver.findElement(By.name("add-card")).click();
  129.  
  130.         (new WebDriverWait(driver, 5)).until(
  131.                 (WebDriver d) -> d.findElement(By.name("new-card")) != null
  132.         );
  133.         driver.findElement(By.name("new-card")).click();
  134.         WebElement cardName3Element = driver.findElement(By.name("card-text"));
  135.         InputHelper.sendKeys(driver, cardName3Element, cardName3);
  136.         WebElement cardImage3Element = driver.findElement(By.name("card-image"));
  137.         InputHelper.sendKeys(driver, cardImage3Element, "http://i.imgur.com/RRUe0Mo.png");
  138.         (new WebDriverWait(driver, 5)).until(
  139.                 (WebDriver d) -> d.findElement(By.name("add-card")) != null
  140.         );
  141.         driver.findElement(By.name("add-card")).click();
  142.  
  143.         (new WebDriverWait(driver, 5)).until(
  144.                 (WebDriver d) -> d.findElement(By.name("new-card")) != null
  145.         );
  146.         driver.findElement(By.name("new-card")).click();
  147.         WebElement cardName4Element = driver.findElement(By.name("card-text"));
  148.         InputHelper.sendKeys(driver, cardName4Element, cardName4);
  149.         WebElement cardImage4Element = driver.findElement(By.name("card-image"));
  150.         InputHelper.sendKeys(driver, cardImage4Element, "http://www.udenscollege.nl/wp-content/uploads/2014/06/boeken.jpg");
  151.         (new WebDriverWait(driver, 5)).until(
  152.                 (WebDriver d) -> d.findElement(By.name("add-card")) != null
  153.         );
  154.         driver.findElement(By.name("add-card")).click();
  155.  
  156.         //Add Cards to topic
  157.         driver.findElement(By.xpath("//*[contains(text(), 'Naschoolse activiteit')]"));
  158.         (new WebDriverWait(driver, 5)).until(
  159.                 (WebDriver d) -> d.findElement(By.name("add-card")) != null
  160.         );
  161.         driver.findElement(By.name("add-card")).click();
  162.         driver.findElement(By.xpath("//*[contains(text(), 'zee')]"));
  163.         driver.findElement(By.xpath("//*[contains(text(), 'vakantie')]"));
  164.         driver.findElement(By.xpath("//*[contains(text(), 'boekenbeurs')]"));
  165.         driver.findElement(By.xpath("//*[contains(text(), 'pretpark')]"));
  166.         (new WebDriverWait(driver, 5)).until(
  167.                 (WebDriver d) -> d.findElement(By.name("add-card")) != null
  168.         );
  169.         driver.findElement(By.name("add-card")).click();
  170.  
  171.         //Create SynchronousSession in topic
  172.         (new WebDriverWait(driver, 5)).until(
  173.                 (WebDriver d) -> d.findElement(By.name("new-session")) != null
  174.         );
  175.         driver.findElement(By.name("new-session")).click();
  176.  
  177.         (new WebDriverWait(driver, 5)).until(
  178.                 (WebDriver d) -> d.findElement(By.name("synchronous")) != null
  179.         );
  180.         driver.findElement(By.name("synchronous")).click();
  181.  
  182.         WebElement minCardsElement = driver.findElement(By.name("minNumberOfCardsPerParticipant"));
  183.         InputHelper.sendKeys(driver, minCardsElement, "2");
  184.  
  185.         WebElement maxCardsElement = driver.findElement(By.name("maxNumberOfCardsPerParticipant"));
  186.         InputHelper.sendKeys(driver, maxCardsElement, "4");
  187.  
  188.         WebElement amountOfCirclesElement = driver.findElement(By.name("amountOfCircles"));
  189.         InputHelper.sendKeys(driver, amountOfCirclesElement, "5");
  190.  
  191.         WebElement startDateTimeElement = driver.findElement(By.name("startDateTime"));
  192.         InputHelper.sendKeys(driver, startDateTimeElement, "03062016{TAB}1223");
  193.  
  194.         driver.findElement(By.name("participantsCanAddCards")).click();
  195.         driver.findElement(By.name("cardCommentsAllowed")).click();
  196.  
  197.         (new WebDriverWait(driver, 5)).until(
  198.                 (WebDriver d) -> d.findElement(By.name("add-session")) != null
  199.         );
  200.         driver.findElement(By.name("add-session")).click();
  201.  
  202.     }
  203. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top