List of usage examples for org.openqa.selenium.support.ui Wait until
<T> T until(Function<? super F, T> isTrue);
From source file:org.jboss.forge.scaffold.angularjs.scenario.dronetests.manytoonerequired.ManyStoreOrderAndOneRequiredCustomerViewsClient.java
License:Open Source License
@Test @InSequence(2)//from w w w .ja v a 2 s . c o m public void testSaveNewStoreOrder(@ArquillianResource URL baseUrl) throws Exception { Wait<WebDriver> wait = new WebDriverWait(driver, 10); // Click on the StoreOrders nav entry driver.get(baseUrl.toString() + "app.html#/"); driver.findElement(By.linkText("StoreOrders")).click(); wait.until(new HasLandedOnSearchStoreOrderView()); // Choose to create a new store order driver.findElement(By.id("Create")).click(); wait.until(new HasLandedOnNewStoreOrderView()); // Enter the store order details driver.findElement(By.id("product")).clear(); driver.findElement(By.id("product")).sendKeys("Apples"); driver.findElement(By.id("orderDate")).clear(); driver.findElement(By.id("orderDate")).sendKeys("2013-01-10"); // Verify that the customer field is marked as required, before filling it. isBootstrapErrorDisplayedForFormControl("customerControls", "required"); // Establish the relationship between the store order and the existing customer. WebElement customerElement = driver.findElement(By.id("customer")); Select customers = new Select(customerElement); customers.selectByVisibleText("1"); // Save driver.findElement(By.id("saveStoreOrder")).click(); // Verify the details are presented in the Edit view wait.until(new HasLandedOnEditStoreOrderView()); assertEquals(baseUrl.toString() + "app.html#/StoreOrders/edit/2", driver.getCurrentUrl()); assertEquals("Apples", driver.findElement(By.id("product")).getAttribute("value")); assertEquals("2013-01-10", driver.findElement(By.id("orderDate")).getAttribute("value")); customerElement = driver.findElement(By.id("customer")); customers = new Select(customerElement); assertEquals("1", customers.getFirstSelectedOption().getText()); // Browse to search store order view and verify if searching for the store order works driver.findElement(By.id("cancel")).click(); wait.until(new HasLandedOnSearchStoreOrderView()); driver.findElement(By.id("product")).clear(); driver.findElement(By.id("product")).sendKeys("Apple"); wait.until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.xpath("id(\"search-results-body\")/tr"))); List<WebElement> searchResults = driver.findElements(By.xpath("id(\"search-results-body\")/tr")); assertEquals(1, searchResults.size()); // Verify if searching for the store order through HTML dropdowns work driver.findElement(By.id("product")).clear(); customerElement = driver.findElement(By.id("customer")); customers = new Select(customerElement); customers.selectByVisibleText("1"); wait.until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.xpath("id(\"search-results-body\")/tr"))); searchResults = driver.findElements(By.xpath("id(\"search-results-body\")/tr")); assertEquals(1, searchResults.size()); // Browse to the edit View of a search result and verify if the details are displayed driver.findElement(By.xpath("id(\"search-results-body\")/tr[1]/td[1]/a")).click(); wait.until(new HasLandedOnEditStoreOrderView()); assertEquals("Apples", driver.findElement(By.id("product")).getAttribute("value")); assertEquals("2013-01-10", driver.findElement(By.id("orderDate")).getAttribute("value")); // Edit the details, save and reverify the details driver.findElement(By.id("product")).clear(); driver.findElement(By.id("product")).sendKeys("Oranges"); driver.findElement(By.id("saveStoreOrder")).click(); wait.until(new HasLandedOnEditStoreOrderView()); assertEquals("Oranges", driver.findElement(By.id("product")).getAttribute("value")); assertEquals("2013-01-10", driver.findElement(By.id("orderDate")).getAttribute("value")); customerElement = driver.findElement(By.id("customer")); customers = new Select(customerElement); assertEquals("1", customers.getFirstSelectedOption().getText()); }
From source file:org.jboss.forge.scaffold.angularjs.scenario.dronetests.onetomany.OneCustomerAndManyStoreOrderViewsClient.java
License:Open Source License
@Test @InSequence(2)//from w w w .j ava 2s . c o m public void testSaveNewStoreOrder(@ArquillianResource URL baseUrl) throws Exception { Wait<WebDriver> wait = new WebDriverWait(driver, 10); // Click on the StoreOrders nav entry driver.get(baseUrl.toString() + "app.html#/"); driver.findElement(By.linkText("StoreOrders")).click(); wait.until(new HasLandedOnSearchStoreOrderView()); // Choose to create a new store order driver.findElement(By.id("Create")).click(); wait.until(new HasLandedOnNewStoreOrderView()); // Enter the store order details and save driver.findElement(By.id("product")).clear(); driver.findElement(By.id("product")).sendKeys("Apples"); driver.findElement(By.id("orderDate")).clear(); driver.findElement(By.id("orderDate")).sendKeys("2013-01-10"); driver.findElement(By.id("saveStoreOrder")).click(); // Verify the details are presented in the Edit view wait.until(new HasLandedOnEditStoreOrderView()); assertEquals(baseUrl.toString() + "app.html#/StoreOrders/edit/2", driver.getCurrentUrl()); assertEquals("Apples", driver.findElement(By.id("product")).getAttribute("value")); assertEquals("2013-01-10", driver.findElement(By.id("orderDate")).getAttribute("value")); // Browse to search customer view and verify if searching for the customer works driver.findElement(By.id("cancel")).click(); wait.until(new HasLandedOnSearchStoreOrderView()); driver.findElement(By.id("product")).clear(); driver.findElement(By.id("product")).sendKeys("Apple"); wait.until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.xpath("id(\"search-results-body\")/tr"))); List<WebElement> searchResults = driver.findElements(By.xpath("id(\"search-results-body\")/tr")); assertEquals(1, searchResults.size()); // Browse to the edit View of a search result and verify if the details are displayed driver.findElement(By.xpath("id(\"search-results-body\")/tr[1]/td[1]/a")).click(); wait.until(new HasLandedOnEditStoreOrderView()); assertEquals("Apples", driver.findElement(By.id("product")).getAttribute("value")); assertEquals("2013-01-10", driver.findElement(By.id("orderDate")).getAttribute("value")); // Edit the details, save and reverify the details driver.findElement(By.id("product")).clear(); driver.findElement(By.id("product")).sendKeys("Oranges"); driver.findElement(By.id("saveStoreOrder")).click(); wait.until(new HasLandedOnEditStoreOrderView()); assertEquals("Oranges", driver.findElement(By.id("product")).getAttribute("value")); assertEquals("2013-01-10", driver.findElement(By.id("orderDate")).getAttribute("value")); }
From source file:org.jboss.forge.scaffold.angularjs.scenario.dronetests.onetomany.OneCustomerAndManyStoreOrderViewsClient.java
License:Open Source License
@Test @InSequence(3)// ww w. ja va2 s. c om public void testEstablishCustomerStoreOrderRelation(@ArquillianResource URL baseUrl) throws Exception { Wait<WebDriver> wait = new WebDriverWait(driver, 10); // Click on the Customers nav entry driver.get(baseUrl.toString() + "app.html#/"); driver.findElement(By.linkText("Customers")).click(); wait.until(new HasLandedOnSearchCustomerView()); // Choose to create a new store order driver.findElement(By.id("Create")).click(); wait.until(new HasLandedOnNewCustomerView()); // Enter the store order details and save driver.findElement(By.id("firstName")).clear(); driver.findElement(By.id("firstName")).sendKeys("John Doe"); driver.findElement(By.id("dateOfBirth")).clear(); driver.findElement(By.id("dateOfBirth")).sendKeys("2013-01-10"); WebElement ordersElement = driver.findElement(By.id("orders")); Select orders = new Select(ordersElement); orders.selectByVisibleText("2"); driver.findElement(By.id("saveCustomer")).click(); // Verify the details are presented in the Edit view wait.until(new HasLandedOnEditCustomerView()); assertEquals(baseUrl.toString() + "app.html#/Customers/edit/3", driver.getCurrentUrl()); assertEquals("John Doe", driver.findElement(By.id("firstName")).getAttribute("value")); assertEquals("2013-01-10", driver.findElement(By.id("dateOfBirth")).getAttribute("value")); ordersElement = driver.findElement(By.id("orders")); orders = new Select(ordersElement); for (WebElement option : orders.getAllSelectedOptions()) { System.out.println(option.getText()); } assertEquals("2", orders.getFirstSelectedOption().getText()); }
From source file:org.jboss.forge.scaffold.angularjs.scenario.dronetests.onetoone.CustomerAndAddressViewsClient.java
License:Open Source License
@Test @InSequence(2)//from www .j av a2s . c o m public void testSaveNewAddress(@ArquillianResource URL baseUrl) throws Exception { Wait<WebDriver> wait = new WebDriverWait(driver, 10); // Click on the Address nav entry driver.get(baseUrl.toString() + "app.html#/"); driver.findElement(By.linkText("Addresss")).click(); wait.until(new HasLandedOnSearchAddressView()); // Choose to create a new address driver.findElement(By.id("Create")).click(); wait.until(new HasLandedOnNewAddressView()); // Enter the address details and save driver.findElement(By.id("street")).clear(); driver.findElement(By.id("street")).sendKeys("6747 Crystal Limits"); driver.findElement(By.id("city")).clear(); driver.findElement(By.id("city")).sendKeys("Markinch"); driver.findElement(By.id("state")).clear(); driver.findElement(By.id("state")).sendKeys("Mississippi"); driver.findElement(By.id("country")).clear(); driver.findElement(By.id("country")).sendKeys("USA"); driver.findElement(By.id("postalcode")).clear(); driver.findElement(By.id("postalcode")).sendKeys("39512-8569"); driver.findElement(By.id("saveAddress")).click(); // Verify the details are presented in the Edit view wait.until(new HasLandedOnEditAddressView()); assertEquals(baseUrl.toString() + "app.html#/Addresss/edit/2", driver.getCurrentUrl()); assertEquals("6747 Crystal Limits", driver.findElement(By.id("street")).getAttribute("value")); assertEquals("Markinch", driver.findElement(By.id("city")).getAttribute("value")); assertEquals("Mississippi", driver.findElement(By.id("state")).getAttribute("value")); assertEquals("USA", driver.findElement(By.id("country")).getAttribute("value")); assertEquals("39512-8569", driver.findElement(By.id("postalcode")).getAttribute("value")); // Browse to search address view and verify if searching for the address works driver.findElement(By.id("cancel")).click(); wait.until(new HasLandedOnSearchAddressView()); driver.findElement(By.id("street")).clear(); driver.findElement(By.id("street")).sendKeys("6747"); wait.until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.xpath("id(\"search-results-body\")/tr"))); List<WebElement> searchResults = driver.findElements(By.xpath("id(\"search-results-body\")/tr")); assertEquals(1, searchResults.size()); // Browse to the edit View of a search result and verify if the details are displayed driver.findElement(By.xpath("id(\"search-results-body\")/tr[1]/td[1]/a")).click(); wait.until(new HasLandedOnEditAddressView()); assertEquals("6747 Crystal Limits", driver.findElement(By.id("street")).getAttribute("value")); assertEquals("Markinch", driver.findElement(By.id("city")).getAttribute("value")); assertEquals("Mississippi", driver.findElement(By.id("state")).getAttribute("value")); assertEquals("USA", driver.findElement(By.id("country")).getAttribute("value")); assertEquals("39512-8569", driver.findElement(By.id("postalcode")).getAttribute("value")); // Edit the details, save and reverify the details driver.findElement(By.id("street")).clear(); driver.findElement(By.id("street")).sendKeys("6017 Thunder Way"); driver.findElement(By.id("city")).clear(); driver.findElement(By.id("city")).sendKeys("Skookumchuck"); driver.findElement(By.id("postalcode")).clear(); driver.findElement(By.id("postalcode")).sendKeys("39200-1131"); driver.findElement(By.id("saveAddress")).click(); wait.until(new HasLandedOnEditAddressView()); assertEquals("6017 Thunder Way", driver.findElement(By.id("street")).getAttribute("value")); assertEquals("Skookumchuck", driver.findElement(By.id("city")).getAttribute("value")); assertEquals("Mississippi", driver.findElement(By.id("state")).getAttribute("value")); assertEquals("USA", driver.findElement(By.id("country")).getAttribute("value")); assertEquals("39200-1131", driver.findElement(By.id("postalcode")).getAttribute("value")); }
From source file:org.jboss.forge.scaffold.angularjs.scenario.dronetests.onetoone.CustomerAndAddressViewsClient.java
License:Open Source License
@Test @InSequence(3)/*from w ww. ja v a2s.com*/ public void testEstablishCustomerAddressRelation(@ArquillianResource URL baseUrl) throws Exception { Wait<WebDriver> wait = new WebDriverWait(driver, 10); // Click on the Customers nav entry driver.get(baseUrl.toString() + "app.html#/"); driver.findElement(By.linkText("Customers")).click(); wait.until(new HasLandedOnSearchCustomerView()); // Choose to create a new customer driver.findElement(By.id("Create")).click(); wait.until(new HasLandedOnNewCustomerView()); // Enter the customer details and save driver.findElement(By.id("firstName")).clear(); driver.findElement(By.id("firstName")).sendKeys("John Doe"); driver.findElement(By.id("dateOfBirth")).clear(); driver.findElement(By.id("dateOfBirth")).sendKeys("2013-01-10"); WebElement addressElement = driver.findElement(By.id("shippingAddress")); Select addresses = new Select(addressElement); addresses.selectByVisibleText("2"); driver.findElement(By.id("saveCustomer")).click(); // Verify the details are presented in the Edit view wait.until(new HasLandedOnEditCustomerView()); assertEquals(baseUrl.toString() + "app.html#/Customers/edit/3", driver.getCurrentUrl()); assertEquals("John Doe", driver.findElement(By.id("firstName")).getAttribute("value")); assertEquals("2013-01-10", driver.findElement(By.id("dateOfBirth")).getAttribute("value")); addressElement = driver.findElement(By.id("shippingAddress")); addresses = new Select(addressElement); assertEquals("2", addresses.getFirstSelectedOption().getText()); // Browse to the search view and verify if searching through HTML dropdowns work driver.findElement(By.id("cancel")).click(); wait.until(new HasLandedOnSearchCustomerView()); addressElement = driver.findElement(By.id("shippingAddress")); addresses = new Select(addressElement); addresses.selectByVisibleText("2"); wait.until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.xpath("id(\"search-results-body\")/tr"))); List<WebElement> searchResults = driver.findElements(By.xpath("id(\"search-results-body\")/tr")); assertEquals(1, searchResults.size()); }
From source file:org.jboss.forge.scaffold.angularjs.scenario.dronetests.onetoonerequired.AddressAndRequiredCustomerViewsClient.java
License:Open Source License
@Test @InSequence(1)//from w ww. j a v a 2 s.c om public void testSaveNewAddress(@ArquillianResource URL baseUrl) throws Exception { Wait<WebDriver> wait = new WebDriverWait(driver, 10); // Click on the Address nav entry driver.get(baseUrl.toString() + "app.html#/"); driver.findElement(By.linkText("Addresss")).click(); wait.until(new HasLandedOnSearchAddressView()); // Choose to create a new address driver.findElement(By.id("Create")).click(); wait.until(new HasLandedOnNewAddressView()); // Enter the address details and save driver.findElement(By.id("street")).clear(); driver.findElement(By.id("street")).sendKeys("6747 Crystal Limits"); driver.findElement(By.id("city")).clear(); driver.findElement(By.id("city")).sendKeys("Markinch"); driver.findElement(By.id("state")).clear(); driver.findElement(By.id("state")).sendKeys("Mississippi"); driver.findElement(By.id("country")).clear(); driver.findElement(By.id("country")).sendKeys("USA"); driver.findElement(By.id("postalcode")).clear(); driver.findElement(By.id("postalcode")).sendKeys("39512-8569"); driver.findElement(By.id("saveAddress")).click(); // Verify the details are presented in the Edit view wait.until(new HasLandedOnEditAddressView()); assertEquals(baseUrl.toString() + "app.html#/Addresss/edit/1", driver.getCurrentUrl()); assertEquals("6747 Crystal Limits", driver.findElement(By.id("street")).getAttribute("value")); assertEquals("Markinch", driver.findElement(By.id("city")).getAttribute("value")); assertEquals("Mississippi", driver.findElement(By.id("state")).getAttribute("value")); assertEquals("USA", driver.findElement(By.id("country")).getAttribute("value")); assertEquals("39512-8569", driver.findElement(By.id("postalcode")).getAttribute("value")); // Browse to search customer view and verify if searching for the customer works driver.findElement(By.id("cancel")).click(); wait.until(new HasLandedOnSearchAddressView()); driver.findElement(By.id("street")).clear(); driver.findElement(By.id("street")).sendKeys("6747"); wait.until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.xpath("id(\"search-results-body\")/tr"))); List<WebElement> searchResults = driver.findElements(By.xpath("id(\"search-results-body\")/tr")); assertEquals(1, searchResults.size()); // Browse to the edit View of a search result and verify if the details are displayed driver.findElement(By.xpath("id(\"search-results-body\")/tr[1]/td[1]/a")).click(); wait.until(new HasLandedOnEditAddressView()); assertEquals("6747 Crystal Limits", driver.findElement(By.id("street")).getAttribute("value")); assertEquals("Markinch", driver.findElement(By.id("city")).getAttribute("value")); assertEquals("Mississippi", driver.findElement(By.id("state")).getAttribute("value")); assertEquals("USA", driver.findElement(By.id("country")).getAttribute("value")); assertEquals("39512-8569", driver.findElement(By.id("postalcode")).getAttribute("value")); // Edit the details, save and reverify the details driver.findElement(By.id("street")).clear(); driver.findElement(By.id("street")).sendKeys("6017 Thunder Way"); driver.findElement(By.id("city")).clear(); driver.findElement(By.id("city")).sendKeys("Skookumchuck"); driver.findElement(By.id("postalcode")).clear(); driver.findElement(By.id("postalcode")).sendKeys("39200-1131"); driver.findElement(By.id("saveAddress")).click(); wait.until(new HasLandedOnEditAddressView()); assertEquals("6017 Thunder Way", driver.findElement(By.id("street")).getAttribute("value")); assertEquals("Skookumchuck", driver.findElement(By.id("city")).getAttribute("value")); assertEquals("Mississippi", driver.findElement(By.id("state")).getAttribute("value")); assertEquals("USA", driver.findElement(By.id("country")).getAttribute("value")); assertEquals("39200-1131", driver.findElement(By.id("postalcode")).getAttribute("value")); }
From source file:org.jboss.forge.scaffold.angularjs.scenario.dronetests.onetoonerequired.AddressAndRequiredCustomerViewsClient.java
License:Open Source License
@Test @InSequence(2)/* w w w .j a v a2 s . c om*/ public void testSaveNewCustomer(@ArquillianResource URL baseUrl) throws Exception { Wait<WebDriver> wait = new WebDriverWait(driver, 10); // Click on the Customers nav entry driver.get(baseUrl.toString() + "app.html#/"); driver.findElement(By.linkText("Customers")).click(); wait.until(new HasLandedOnSearchCustomerView()); // Choose to create a new customer driver.findElement(By.id("Create")).click(); wait.until(new HasLandedOnNewCustomerView()); // Enter the customer details driver.findElement(By.id("firstName")).clear(); driver.findElement(By.id("firstName")).sendKeys("John Doe"); driver.findElement(By.id("dateOfBirth")).clear(); driver.findElement(By.id("dateOfBirth")).sendKeys("2013-01-10"); // Verify that the shipping Address field is marked as required before filling isBootstrapErrorDisplayedForFormControl("shippingAddressControls", "required"); // Establish the customer and address relationship WebElement addressElement = driver.findElement(By.id("shippingAddress")); Select addresses = new Select(addressElement); addresses.selectByVisibleText("1"); // Save driver.findElement(By.id("saveCustomer")).click(); // Verify the details are presented in the Edit view wait.until(new HasLandedOnEditCustomerView()); assertEquals(baseUrl.toString() + "app.html#/Customers/edit/2", driver.getCurrentUrl()); assertEquals("John Doe", driver.findElement(By.id("firstName")).getAttribute("value")); assertEquals("2013-01-10", driver.findElement(By.id("dateOfBirth")).getAttribute("value")); addressElement = driver.findElement(By.id("shippingAddress")); addresses = new Select(addressElement); assertEquals("1", addresses.getFirstSelectedOption().getText()); // Browse to search customer view and verify if searching for the customer works driver.findElement(By.id("cancel")).click(); wait.until(new HasLandedOnSearchCustomerView()); driver.findElement(By.id("firstName")).clear(); driver.findElement(By.id("firstName")).sendKeys("John"); wait.until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.xpath("id(\"search-results-body\")/tr"))); List<WebElement> searchResults = driver.findElements(By.xpath("id(\"search-results-body\")/tr")); assertEquals(1, searchResults.size()); // Browse to the edit View of a search result and verify if the details are displayed driver.findElement(By.xpath("id(\"search-results-body\")/tr[1]/td[1]/a")).click(); wait.until(new HasLandedOnEditCustomerView()); assertEquals("John Doe", driver.findElement(By.id("firstName")).getAttribute("value")); assertEquals("2013-01-10", driver.findElement(By.id("dateOfBirth")).getAttribute("value")); addressElement = driver.findElement(By.id("shippingAddress")); addresses = new Select(addressElement); assertEquals("1", addresses.getFirstSelectedOption().getText()); // Edit the details, save and reverify the details driver.findElement(By.id("firstName")).clear(); driver.findElement(By.id("firstName")).sendKeys("Jane Doe"); driver.findElement(By.id("saveCustomer")).click(); wait.until(new HasLandedOnEditCustomerView()); assertEquals("Jane Doe", driver.findElement(By.id("firstName")).getAttribute("value")); assertEquals("2013-01-10", driver.findElement(By.id("dateOfBirth")).getAttribute("value")); addressElement = driver.findElement(By.id("shippingAddress")); addresses = new Select(addressElement); assertEquals("1", addresses.getFirstSelectedOption().getText()); // Browse to search customer view and verify if searching for the customer works driver.findElement(By.id("cancel")).click(); wait.until(new HasLandedOnSearchCustomerView()); addressElement = driver.findElement(By.id("shippingAddress")); addresses = new Select(addressElement); addresses.selectByVisibleText("1"); wait.until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.xpath("id(\"search-results-body\")/tr"))); searchResults = driver.findElements(By.xpath("id(\"search-results-body\")/tr")); assertEquals(1, searchResults.size()); }
From source file:org.jboss.forge.scaffold.angularjs.scenario.dronetests.singleentity.CustomerViewClient.java
License:Open Source License
@Test public void testSaveNewCustomer(@ArquillianResource URL baseUrl) throws Exception { Wait<WebDriver> wait = new WebDriverWait(driver, 10); // Click on the Customers nav entry driver.get(baseUrl.toString() + "app.html#/"); driver.findElement(By.linkText("Customers")).click(); wait.until(new HasLandedOnSearchCustomerView()); // Choose to create a new customer driver.findElement(By.id("Create")).click(); wait.until(new HasLandedOnNewCustomerView()); // Enter the customer details and save driver.findElement(By.id("firstName")).clear(); driver.findElement(By.id("firstName")).sendKeys("John Doe"); driver.findElement(By.id("dateOfBirth")).clear(); driver.findElement(By.id("dateOfBirth")).sendKeys("2013-01-10"); driver.findElement(By.id("saveCustomer")).click(); // Verify the details are presented in the Edit view wait.until(new HasLandedOnEditCustomerView()); assertEquals(baseUrl.toString() + "app.html#/Customers/edit/1", driver.getCurrentUrl()); assertEquals("John Doe", driver.findElement(By.id("firstName")).getAttribute("value")); assertEquals("2013-01-10", driver.findElement(By.id("dateOfBirth")).getAttribute("value")); // Browse to search customer view and verify if searching for the customer works driver.findElement(By.id("cancel")).click(); wait.until(new HasLandedOnSearchCustomerView()); driver.findElement(By.id("firstName")).clear(); driver.findElement(By.id("firstName")).sendKeys("John"); wait.until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.xpath("id(\"search-results-body\")/tr"))); List<WebElement> searchResults = driver.findElements(By.xpath("id(\"search-results-body\")/tr")); assertEquals(1, searchResults.size()); // Browse to the edit View of a search result and verify if the details are displayed driver.findElement(By.xpath("id(\"search-results-body\")/tr[1]/td[1]/a")).click(); wait.until(new HasLandedOnEditCustomerView()); assertEquals("John Doe", driver.findElement(By.id("firstName")).getAttribute("value")); assertEquals("2013-01-10", driver.findElement(By.id("dateOfBirth")).getAttribute("value")); // Edit the details, save and reverify the details driver.findElement(By.id("firstName")).clear(); driver.findElement(By.id("firstName")).sendKeys("Jane Doe"); driver.findElement(By.id("saveCustomer")).click(); wait.until(new HasLandedOnEditCustomerView()); assertEquals("Jane Doe", driver.findElement(By.id("firstName")).getAttribute("value")); assertEquals("2013-01-10", driver.findElement(By.id("dateOfBirth")).getAttribute("value")); }
From source file:org.jboss.forge.scaffold.angularjs.scenario.dronetests.singleentityvalidations.CustomerViewWithValidationsClient.java
License:Open Source License
@Test public void testSaveNewCustomer(@ArquillianResource URL baseUrl) throws Exception { Wait<WebDriver> wait = new WebDriverWait(driver, 10); // Click on the Customers nav entry driver.get(baseUrl.toString() + "app.html#/"); driver.findElement(By.linkText("Customers")).click(); wait.until(new HasLandedOnSearchCustomerView()); // Choose to create a new customer driver.findElement(By.id("Create")).click(); wait.until(new HasLandedOnNewCustomerView()); // Enter the customer details and save driver.findElement(By.id("firstName")).clear(); driver.findElement(By.id("firstName")).sendKeys("John Doe"); driver.findElement(By.id("dateOfBirth")).clear(); driver.findElement(By.id("dateOfBirth")).sendKeys("2013-01-10"); driver.findElement(By.id("ficoCreditScore")).clear(); driver.findElement(By.id("ficoCreditScore")).sendKeys("700"); driver.findElement(By.id("saveCustomer")).click(); // Verify the details are presented in the Edit view wait.until(new HasLandedOnEditCustomerView()); assertEquals(baseUrl.toString() + "app.html#/Customers/edit/1", driver.getCurrentUrl()); assertEquals("John Doe", driver.findElement(By.id("firstName")).getAttribute("value")); assertEquals("2013-01-10", driver.findElement(By.id("dateOfBirth")).getAttribute("value")); // Browse to search customer view and verify if searching for the customer works driver.findElement(By.id("cancel")).click(); wait.until(new HasLandedOnSearchCustomerView()); driver.findElement(By.id("firstName")).clear(); driver.findElement(By.id("firstName")).sendKeys("John"); wait.until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.xpath("id(\"search-results-body\")/tr"))); List<WebElement> searchResults = driver.findElements(By.xpath("id(\"search-results-body\")/tr")); assertEquals(1, searchResults.size()); // Browse to the edit View of a search result and verify if the details are displayed driver.findElement(By.xpath("id(\"search-results-body\")/tr[1]/td[1]/a")).click(); wait.until(new HasLandedOnEditCustomerView()); assertEquals("John Doe", driver.findElement(By.id("firstName")).getAttribute("value")); assertEquals("2013-01-10", driver.findElement(By.id("dateOfBirth")).getAttribute("value")); // Edit the details, save and reverify the details driver.findElement(By.id("firstName")).clear(); driver.findElement(By.id("firstName")).sendKeys("Jane Doe"); driver.findElement(By.id("saveCustomer")).click(); wait.until(new HasLandedOnEditCustomerView()); assertEquals("Jane Doe", driver.findElement(By.id("firstName")).getAttribute("value")); assertEquals("2013-01-10", driver.findElement(By.id("dateOfBirth")).getAttribute("value")); }
From source file:org.jboss.forge.scaffold.angularjs.scenario.dronetests.singleentityvalidations.CustomerViewWithValidationsClient.java
License:Open Source License
@Test public void testSaveNewCustomerWithoutRequiredFields(@ArquillianResource URL baseUrl) throws Exception { Wait<WebDriver> wait = new WebDriverWait(driver, 10); // Click on the Customers nav entry driver.get(baseUrl.toString() + "app.html#/"); driver.findElement(By.linkText("Customers")).click(); wait.until(new HasLandedOnSearchCustomerView()); // Choose to create a new customer driver.findElement(By.id("Create")).click(); wait.until(new HasLandedOnNewCustomerView()); // Enter the customer details and save driver.findElement(By.id("firstName")).clear(); driver.findElement(By.id("dateOfBirth")).clear(); driver.findElement(By.id("ficoCreditScore")).clear(); assertTrue(isBootstrapErrorDisplayedForFormControl("firstNameControls", "required")); assertTrue(isBootstrapErrorDisplayedForFormControl("ficoCreditScoreControls", "required")); }