List of usage examples for org.openqa.selenium.support.ui ExpectedConditions presenceOfAllElementsLocatedBy
public static ExpectedCondition<List<WebElement>> presenceOfAllElementsLocatedBy(final By locator)
From source file:org.eclipse.che.selenium.pageobject.debug.DebugPanel.java
License:Open Source License
/** * Wait text in debug highlighted area (red line into Che editor under debugger) * * @param text the text under debug - highlighter *//*from w w w. j av a 2s .c o m*/ public void waitDebugHighlightedText(String text) { StringBuilder highLightedText = new StringBuilder(); String locatorWithHiglightedText = "//div[@id='gwt-debug-editorPartStack-contentPanel']//div[@active]//div[@class='textviewContent' and @contenteditable='true']//span[@debugid='debug-line']"; List<WebElement> hilightedElements = new WebDriverWait(seleniumWebDriver, LOAD_PAGE_TIMEOUT_SEC) .until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.xpath(locatorWithHiglightedText))); for (WebElement hilightedElement : hilightedElements) { highLightedText.append(hilightedElement.getText()); } new WebDriverWait(seleniumWebDriver, MINIMUM_SEC).until((WebDriver driver) -> { return highLightedText.toString().contains(text); }); }
From source file:org.eclipse.che.selenium.pageobject.KeyBindings.java
License:Open Source License
private List<WebElement> getListElementsKeyBindingById(String id) { waitKeyBindingsFormIsOpened();/*from w w w .ja v a 2 s . c o m*/ return new WebDriverWait(seleniumWebDriver, REDRAW_UI_ELEMENTS_TIMEOUT_SEC).until( ExpectedConditions.presenceOfAllElementsLocatedBy(By.xpath("//div[contains(@id,'" + id + "')]"))); }
From source file:org.eclipse.che.selenium.pageobject.Wizard.java
License:Open Source License
/** * Select the type of packaging on Wizard * * @param mavenType type project of Maven *//* w w w . j av a 2 s . c om*/ public void selectPackagingType(PackagingMavenType mavenType) { List<WebElement> DropDownList = new WebDriverWait(seleniumWebDriver, REDRAW_UI_ELEMENTS_TIMEOUT_SEC) .until(ExpectedConditions .presenceOfAllElementsLocatedBy(By.xpath(Locators.SELECT_PACKAGING_DROPDOWN_BLOCK))); new WebDriverWait(seleniumWebDriver, REDRAW_UI_ELEMENTS_TIMEOUT_SEC) .until(ExpectedConditions.visibilityOfElementLocated(By.xpath(Locators.SELECT_PACKAGING_DROPDOWN))) .click(); switch (mavenType) { case JAR: DropDownList.get(1).click(); break; case WAR: DropDownList.get(2).click(); break; case POM: DropDownList.get(3).click(); break; default: DropDownList.get(0).click(); break; } }
From source file:org.jboss.forge.scaffold.angularjs.scenario.dronetests.manytoone.ManyStoreOrderAndOneCustomerViewsClient.java
License:Open Source License
@Test @InSequence(1)/* w w w. jav a2 s .com*/ 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.manytoone.ManyStoreOrderAndOneCustomerViewsClient.java
License:Open Source License
@Test @InSequence(2)//from w ww . j a v a 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 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()); // 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.manytoone.ManyStoreOrderAndOneCustomerViewsClient.java
License:Open Source License
@Test @InSequence(3)/*w w w .j a va 2 s.com*/ public void testEstablishCustomerStoreOrderRelation(@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"); WebElement customerElement = driver.findElement(By.id("customer")); Select customers = new Select(customerElement); customers.selectByVisibleText("1"); 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/3", 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 customer view and verify if searching for the store order through HTML dropdowns work driver.findElement(By.id("cancel")).click(); wait.until(new HasLandedOnSearchStoreOrderView()); customerElement = driver.findElement(By.id("customer")); customers = new Select(customerElement); customers.selectByVisibleText("1"); 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.manytoonerequired.ManyStoreOrderAndOneRequiredCustomerViewsClient.java
License:Open Source License
@Test @InSequence(2)//from w w w. ja va 2s.co 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. java2s . 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.onetoone.CustomerAndAddressViewsClient.java
License:Open Source License
@Test @InSequence(2)//from www . j a v a2 s .com 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)//ww w .j av a2 s .co m 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()); }