List of usage examples for org.openqa.selenium.support.ui ExpectedConditions titleIs
public static ExpectedCondition<Boolean> titleIs(final String title)
From source file:com.ggasoftware.uitest.utils.WebDriverWrapper.java
License:Open Source License
/** * Wait until windows has title./*from w w w . j a v a2 s. co m*/ * * @param timeoutSec to wait until windows has title. * @param title - Expected window title. * @param checkCondition log assert for expected conditions. */ public static void waitForTitle(String title, int timeoutSec, boolean checkCondition) { ReporterNGExt.logAction(getDriver(), "", String.format("waitForTitle: %s", title)); long start = System.currentTimeMillis() / 1000; WebDriverWait wait = (WebDriverWait) new WebDriverWait(getDriver(), timeoutSec) .ignoring(StaleElementReferenceException.class); try { wait.until(ExpectedConditions.titleIs(title)); } catch (TimeoutException ignored) { ReporterNGExt.logTechnical(String.format("waitForTitle: [ %s ] during: [ %d ] sec ", title, System.currentTimeMillis() / 1000 - start)); } if (checkCondition) { ReporterNGExt.logAssertEquals(ReporterNGExt.BUSINESS_LEVEL, getDriver().getTitle(), title, "waitForTitle", TestBaseWebDriver.takePassedScreenshot); } }
From source file:com.ggasoftware.uitest.utils.WebDriverWrapper.java
License:Open Source License
/** * Wait until element is changed text/*from w ww .j av a 2 s . c o m*/ * * @param title before change * @param timeoutSec seconds to wait until element is changed text * @param checkCondition - log assert for expected conditions. */ public static void waitForTitleChanged(final String title, int timeoutSec, boolean checkCondition) { boolean isChanged; ReporterNGExt.logAction(getDriver(), "", String.format("waitForTitleChanged: %s", title)); long start = System.currentTimeMillis() / 1000; WebDriverWait wait = (WebDriverWait) new WebDriverWait(getDriver(), timeoutSec) .ignoring(StaleElementReferenceException.class); try { isChanged = wait.until(ExpectedConditions.not(ExpectedConditions.titleIs(title))); } catch (TimeoutException e) { ReporterNGExt.logTechnical(String.format("waitForTitleChanged: [ %s ] during: [ %d ] sec ", title, System.currentTimeMillis() / 1000 - start)); isChanged = false; } if (checkCondition) { ReporterNGExt.logAssertTrue(ReporterNGExt.BUSINESS_LEVEL, isChanged, String.format("waitForTitleChanged: title '%s' should be changed", title), TestBaseWebDriver.takePassedScreenshot); } }
From source file:com.pentaho.ctools.cde.reference.AjaxRequestReference.java
License:Apache License
/** * ############################### Test Case 1 ############################### * * Test Case Name:/*from w w w . j a v a2 s. com*/ * PageContent * Description: * The test case pretends validate the contents presented in the sample. * Steps: * 1. Check page content. */ @Test public void tc01_PageContent_InformationPresent() { this.log.info("tc01_PageContent_InformationPresent"); //Go to AddinReference driver.get(baseUrl + "api/repos/%3Apublic%3Aplugin-samples%3Apentaho-cdf-dd%3Atests%3AajaxRequest.wcdf/generatedContent"); //NOTE - we have to wait for loading disappear this.elemHelper.WaitForElementInvisibility(driver, By.cssSelector("div.blockUI.blockOverlay")); /* * ## Step 1 */ //Check page title wait.until(ExpectedConditions.titleIs("Ajax Request Reference")); assertEquals("Ajax Request Reference", driver.getTitle()); //Check title String title = this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//div[@id='Title']/span")); assertEquals("Ajax Request Reference", title); //Check first paragh String expParag = "Ajax Request Component provides a way to build an Ajax request. Given an url, a response type and list of parameters it's possible to build an jQuery ajax call, which its result will be stored in the resultvar."; String actParag = this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//div[@id='DescriptionBody']/p")); assertEquals(expParag, actParag); //Check subtitle String subtitle = this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//div[@id='DescriptionBody']/div")); assertEquals("Component Parameters", subtitle); //Check parag 1 String parag1 = this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//div[@id='DescriptionBody']/p[2]")); assertEquals("The Component definition supports the following arguments:", parag1); //Check subtitle2 String subtitle2 = this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//div[@id='DescriptionBody']/div[2]")); assertEquals("Default values", subtitle2); //Check quote String quote = this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//div[@id='DescriptionBody']/blockquote/pre")); assertEquals("defaults: { ajaxRequestType: json, asyncCall: true }", quote); //Check result String jsonQueryExpected = "{\"queryInfo\":{\"totalRows\":\"19\"},\"resultset\":[[\"Car\",\"Red\",10],[\"Car\",\"Blue\",20],[\"Car\",\"Green\",30],[\"Car\",\"Yellow\",5],[\"Car\",\"Black\",25],[\"Car\",\"White\",7],[\"Bike\",\"Red\",20],[\"Bike\",\"Blue\",20],[\"Bike\",\"Green\",40],[\"Bike\",\"Yellow\",80],[\"Bike\",\"Black\",1],[\"Bike\",\"White\",23],[\"Ship\",\"Red\",2],[\"Ship\",\"Blue\",7],[\"Plane\",\"Red\",5],[\"Plane\",\"Blue\",4],[\"Train\",\"Red\",50],[\"Train\",\"Blue\",50],[\"Train\",\"Green\",7]],\"metadata\":[{\"colIndex\":0,\"colType\":\"String\",\"colName\":\"series\"},{\"colIndex\":1,\"colType\":\"String\",\"colName\":\"category\"},{\"colIndex\":2,\"colType\":\"Integer\",\"colName\":\"value\"}]}"; String jsonQueryActual = this.elemHelper.WaitForTextDifferentEmpty(driver, By.id("column1")); JsonParser parser = new JsonParser(); JsonElement actual = parser.parse(jsonQueryActual); JsonElement expected = parser.parse(jsonQueryExpected); assertEquals(actual, expected); }
From source file:com.pentaho.ctools.cde.reference.BulletChartTestCase.java
License:Apache License
/** * ############################### Test Case 1 ############################### * * Test Case Name://from ww w .j av a 2 s .c om * PageContent * Description: * The test case pretends validate charts presented. * Steps: * 1. Check chart 1 - No data sent * 2. Check chart 2 - Returning one value only (65) * 3. Check chart 3 - Returning name and value * 4. Check chart 4 - Title, value and marker * 5. Check chart 5 - Complete dataset */ @Test public void tc01_ChartContent_DisplayedCorrect() { this.log.info("tc01_ChartContent_DisplayedCorrect"); /* * ## Step 0 */ //Check page title wait.until(ExpectedConditions.titleIs("Bullet chart testcase")); assertEquals("Bullet chart testcase", driver.getTitle()); //Check title String title = this.elemHelper.WaitForElementPresentGetText(driver, By.cssSelector("#title > span")); assertEquals("Bullet chart test case", title); /* * ## Step 1 */ //Chart 1 //Check title String subtitle1 = this.elemHelper.WaitForElementPresentGetText(driver, By.cssSelector("#subtitle1 > span")); assertEquals("No data sent", subtitle1); //Check serie title and subtitle String cht1Title1 = this.elemHelper.WaitForElementPresentGetText(driver, By.xpath( "//div[@id='obj1']/div/*[local-name()='svg' and namespace-uri()='http://www.w3.org/2000/svg']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g'][6]/*[local-name()='text']")); assertEquals("Title", cht1Title1); String cht1Subtitle1 = this.elemHelper.WaitForElementPresentGetText(driver, By.xpath( "//div[@id='obj1']/div/*[local-name()='svg' and namespace-uri()='http://www.w3.org/2000/svg']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g'][7]/*[local-name()='text']")); assertEquals("No data", cht1Subtitle1); //Check chart WebElement cht1SizeBar = this.elemHelper.FindElement(driver, By.xpath( "//div[@id='obj1']/div/*[local-name()='svg' and namespace-uri()='http://www.w3.org/2000/svg']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g'][2]/*[local-name()='rect']")); assertNotNull(cht1SizeBar); assertEquals("202.11111111111111", cht1SizeBar.getAttribute("width")); WebElement cht1RectWhite1 = this.elemHelper.FindElement(driver, By.xpath( "//div[@id='obj1']/div/*[local-name()='svg' and namespace-uri()='http://www.w3.org/2000/svg']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g'][3]/*[local-name()='path'][1]")); WebElement cht1RectWhite2 = this.elemHelper.FindElement(driver, By.xpath( "//div[@id='obj1']/div/*[local-name()='svg' and namespace-uri()='http://www.w3.org/2000/svg']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g'][3]/*[local-name()='path'][2]")); assertNotNull(cht1RectWhite1); assertNotNull(cht1RectWhite2); assertEquals("translate(78.46666666666665,15) ", cht1RectWhite1.getAttribute("transform")); assertEquals("translate(156.9333333333333,15) ", cht1RectWhite2.getAttribute("transform")); /* * ## Step 2 */ //Chart 2 //Check title String subtitle2 = this.elemHelper.WaitForElementPresentGetText(driver, By.id("subtitle2")); assertEquals("Returning one value only (65)", subtitle2); //Check serie title and subtitle String cht2Title1 = this.elemHelper.WaitForElementPresentGetText(driver, By.xpath( "//div[@id='obj2']/div/*[local-name()='svg' and namespace-uri()='http://www.w3.org/2000/svg']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g'][6]/*[local-name()='text']")); assertEquals("Value only", cht2Title1); String cht2Subtitle1 = this.elemHelper.WaitForElementPresentGetText(driver, By.xpath( "//div[@id='obj2']/div/*[local-name()='svg' and namespace-uri()='http://www.w3.org/2000/svg']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g'][7]/*[local-name()='text']")); assertEquals("value is 65", cht2Subtitle1); //Check chart WebElement cht2SizeBar = this.elemHelper.FindElement(driver, By.xpath( "//div[@id='obj2']/div/*[local-name()='svg' and namespace-uri()='http://www.w3.org/2000/svg']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g'][2]/*[local-name()='rect']")); assertNotNull(cht2SizeBar); assertEquals("154.55555555555554", cht2SizeBar.getAttribute("width")); WebElement cht2RectWhite1 = this.elemHelper.FindElement(driver, By.xpath( "//div[@id='obj2']/div/*[local-name()='svg' and namespace-uri()='http://www.w3.org/2000/svg']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g'][3]/*[local-name()='path'][1]")); assertNotNull(cht2RectWhite1); assertEquals("translate(71.33333333333333,12.5) ", cht2RectWhite1.getAttribute("transform")); /* * ## Step 3 */ //>Chart 3 //>>Chart 31 //Check title String subtitle3 = this.elemHelper.WaitForElementPresentGetText(driver, By.id("subtitle3")); assertEquals("Returning name and value", subtitle3); //Check series title and subtitle String cht31Title1 = this.elemHelper.WaitForElementPresentGetText(driver, By.xpath( "//div[@id='obj3']/div/*[local-name()='svg' and namespace-uri()='http://www.w3.org/2000/svg']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g'][6]/*[local-name()='text']")); assertEquals("Atelier graphique", cht31Title1); String cht31Subtitle1 = this.elemHelper.WaitForElementPresentGetText(driver, By.xpath( "//div[@id='obj3']/div/*[local-name()='svg' and namespace-uri()='http://www.w3.org/2000/svg']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g'][7]/*[local-name()='text']")); assertEquals("Customer", cht31Subtitle1); //Check chart WebElement cht31SizeBar = this.elemHelper.FindElement(driver, By.xpath( "//div[@id='obj3']/div/*[local-name()='svg' and namespace-uri()='http://www.w3.org/2000/svg']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g'][2]/*[local-name()='rect']")); assertNotNull(cht31SizeBar); assertEquals("178.26666666666668", cht31SizeBar.getAttribute("width")); WebElement cht31RectWhite1 = this.elemHelper.FindElement(driver, By.xpath( "//div[@id='obj3']/div/*[local-name()='svg' and namespace-uri()='http://www.w3.org/2000/svg']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g'][3]/*[local-name()='path'][1]")); assertNotNull(cht31RectWhite1); assertEquals("translate(509.3333333333333,10) ", cht31RectWhite1.getAttribute("transform")); //>>Chart 32 //Check series title and subtitle String cht32Title1 = this.elemHelper.WaitForElementPresentGetText(driver, By.xpath( "//div[@id='obj3']/div/*[local-name()='svg' and namespace-uri()='http://www.w3.org/2000/svg']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g'][2]/*[local-name()='g'][6]/*[local-name()='text']")); assertEquals("Signal Gift Stores", cht32Title1); String cht32Subtitle1 = this.elemHelper.WaitForElementPresentGetText(driver, By.xpath( "//div[@id='obj3']/div/*[local-name()='svg' and namespace-uri()='http://www.w3.org/2000/svg']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g'][2]/*[local-name()='g'][7]/*[local-name()='text']")); assertEquals("Customer", cht32Subtitle1); //Check chart WebElement cht32SizeBar = this.elemHelper.FindElement(driver, By.xpath( "//div[@id='obj3']/div/*[local-name()='svg' and namespace-uri()='http://www.w3.org/2000/svg']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g'][2]/*[local-name()='g'][2]/*[local-name()='rect']")); assertNotNull(cht32SizeBar); assertEquals("609.5022222222223", cht32SizeBar.getAttribute("width")); WebElement cht32RectWhite1 = this.elemHelper.FindElement(driver, By.xpath( "//div[@id='obj3']/div/*[local-name()='svg' and namespace-uri()='http://www.w3.org/2000/svg']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g'][2]/*[local-name()='g'][3]/*[local-name()='path'][1]")); assertNotNull(cht32RectWhite1); assertEquals("translate(509.3333333333333,10) ", cht32RectWhite1.getAttribute("transform")); //>>Chart 33 //Check series title and subtitle String cht33Title1 = this.elemHelper.WaitForElementPresentGetText(driver, By.xpath( "//div[@id='obj3']/div/*[local-name()='svg' and namespace-uri()='http://www.w3.org/2000/svg']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g'][3]/*[local-name()='g'][6]/*[local-name()='text']")); assertEquals("Australian Collectors, Co.", cht33Title1); String cht33Subtitle1 = this.elemHelper.WaitForElementPresentGetText(driver, By.xpath( "//div[@id='obj3']/div/*[local-name()='svg' and namespace-uri()='http://www.w3.org/2000/svg']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g'][3]/*[local-name()='g'][7]/*[local-name()='text']")); assertEquals("Customer", cht33Subtitle1); //Check chart WebElement cht33SizeBar = this.elemHelper.FindElement(driver, By.xpath( "//div[@id='obj3']/div/*[local-name()='svg' and namespace-uri()='http://www.w3.org/2000/svg']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g'][3]/*[local-name()='g'][2]/*[local-name()='rect']")); assertNotNull(cht33SizeBar); assertEquals("764", cht33SizeBar.getAttribute("width")); WebElement cht33RectWhite1 = this.elemHelper.FindElement(driver, By.xpath( "//div[@id='obj3']/div/*[local-name()='svg' and namespace-uri()='http://www.w3.org/2000/svg']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g'][3]/*[local-name()='g'][3]/*[local-name()='path'][1]")); assertNotNull(cht33RectWhite1); assertEquals("translate(390.79283887468034,10) ", cht33RectWhite1.getAttribute("transform")); //>>Chart 34 String cht34Title1 = this.elemHelper.WaitForElementPresentGetText(driver, By.xpath( "//div[@id='obj3']/div/*[local-name()='svg' and namespace-uri()='http://www.w3.org/2000/svg']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g'][4]/*[local-name()='g'][6]/*[local-name()='text']")); assertEquals("La Rochelle Gifts", cht34Title1); String cht34Subtitle1 = this.elemHelper.WaitForElementPresentGetText(driver, By.xpath( "//div[@id='obj3']/div/*[local-name()='svg' and namespace-uri()='http://www.w3.org/2000/svg']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g'][4]/*[local-name()='g'][7]/*[local-name()='text']")); assertEquals("Customer", cht34Subtitle1); //Check chart WebElement cht34SizeBar = this.elemHelper.FindElement(driver, By.xpath( "//div[@id='obj3']/div/*[local-name()='svg' and namespace-uri()='http://www.w3.org/2000/svg']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g'][4]/*[local-name()='g'][2]/*[local-name()='rect']")); assertNotNull(cht34SizeBar); assertEquals("764", cht34SizeBar.getAttribute("width")); WebElement cht34RectWhite1 = this.elemHelper.FindElement(driver, By.xpath( "//div[@id='obj3']/div/*[local-name()='svg' and namespace-uri()='http://www.w3.org/2000/svg']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g'][4]/*[local-name()='g'][3]/*[local-name()='path'][1]")); assertNotNull(cht34RectWhite1); assertEquals("translate(387.8172588832487,10) ", cht34RectWhite1.getAttribute("transform")); //>>Chart 35 String cht35Title1 = this.elemHelper.WaitForElementPresentGetText(driver, By.xpath( "//div[@id='obj3']/div/*[local-name()='svg' and namespace-uri()='http://www.w3.org/2000/svg']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g'][5]/*[local-name()='g'][6]/*[local-name()='text']")); assertEquals("Baane Mini Imports", cht35Title1); String cht35Subtitle1 = this.elemHelper.WaitForElementPresentGetText(driver, By.xpath( "//div[@id='obj3']/div/*[local-name()='svg' and namespace-uri()='http://www.w3.org/2000/svg']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g'][5]/*[local-name()='g'][7]/*[local-name()='text']")); assertEquals("Customer", cht35Subtitle1); //Check chart WebElement cht35SizeBar = this.elemHelper.FindElement(driver, By.xpath( "//div[@id='obj3']/div/*[local-name()='svg' and namespace-uri()='http://www.w3.org/2000/svg']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g'][5]/*[local-name()='g'][2]/*[local-name()='rect']")); assertNotNull(cht35SizeBar); assertEquals("693.5422222222222", cht35SizeBar.getAttribute("width")); WebElement cht35RectWhite1 = this.elemHelper.FindElement(driver, By.xpath( "//div[@id='obj3']/div/*[local-name()='svg' and namespace-uri()='http://www.w3.org/2000/svg']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g'][5]/*[local-name()='g'][3]/*[local-name()='path'][1]")); assertNotNull(cht35RectWhite1); assertEquals("translate(509.3333333333333,10) ", cht35RectWhite1.getAttribute("transform")); //>>Chart 36 String cht36Title1 = this.elemHelper.WaitForElementPresentGetText(driver, By.xpath( "//div[@id='obj3']/div/*[local-name()='svg' and namespace-uri()='http://www.w3.org/2000/svg']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g'][6]/*[local-name()='g'][6]/*[local-name()='text']")); assertEquals("Mini Gifts Distributors Ltd.", cht36Title1); String cht36Subtitle1 = this.elemHelper.WaitForElementPresentGetText(driver, By.xpath( "//div[@id='obj3']/div/*[local-name()='svg' and namespace-uri()='http://www.w3.org/2000/svg']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g'][6]/*[local-name()='g'][7]/*[local-name()='text']")); assertEquals("Customer", cht36Subtitle1); //Check chart WebElement cht36SizeBar = this.elemHelper.FindElement(driver, By.xpath( "//div[@id='obj3']/div/*[local-name()='svg' and namespace-uri()='http://www.w3.org/2000/svg']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g'][6]/*[local-name()='g'][2]/*[local-name()='rect']")); assertNotNull(cht36SizeBar); assertEquals("764", cht36SizeBar.getAttribute("width")); WebElement cht36RectWhite1 = this.elemHelper.FindElement(driver, By.xpath( "//div[@id='obj3']/div/*[local-name()='svg' and namespace-uri()='http://www.w3.org/2000/svg']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g'][6]/*[local-name()='g'][3]/*[local-name()='path'][1]")); assertNotNull(cht36RectWhite1); assertEquals("translate(217.76722090261282,10) ", cht36RectWhite1.getAttribute("transform")); //>>Chart 37 String cht37Title1 = this.elemHelper.WaitForElementPresentGetText(driver, By.xpath( "//div[@id='obj3']/div/*[local-name()='svg' and namespace-uri()='http://www.w3.org/2000/svg']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g'][7]/*[local-name()='g'][6]/*[local-name()='text']")); assertEquals("Havel & Zbyszek Co", cht37Title1); String cht37Subtitle1 = this.elemHelper.WaitForElementPresentGetText(driver, By.xpath( "//div[@id='obj3']/div/*[local-name()='svg' and namespace-uri()='http://www.w3.org/2000/svg']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g'][7]/*[local-name()='g'][7]/*[local-name()='text']")); assertEquals("Customer", cht37Subtitle1); //Check chart WebElement cht37SizeBar = this.elemHelper.FindElement(driver, By.xpath( "//div[@id='obj3']/div/*[local-name()='svg' and namespace-uri()='http://www.w3.org/2000/svg']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g'][7]/*[local-name()='g'][2]/*[local-name()='rect']"), 1); assertNull(cht37SizeBar); WebElement cht37RectWhite1 = this.elemHelper.FindElement(driver, By.xpath( "//div[@id='obj3']/div/*[local-name()='svg' and namespace-uri()='http://www.w3.org/2000/svg']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g'][7]/*[local-name()='g'][3]/*[local-name()='path'][1]")); assertNotNull(cht37RectWhite1); assertEquals("translate(509.3333333333333,10) ", cht37RectWhite1.getAttribute("transform")); //>>Chart 38 String cht38Title1 = this.elemHelper.WaitForElementPresentGetText(driver, By.xpath( "//div[@id='obj3']/div/*[local-name()='svg' and namespace-uri()='http://www.w3.org/2000/svg']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g'][8]/*[local-name()='g'][6]/*[local-name()='text']")); assertEquals("Blauer See Auto, Co.", cht38Title1); String cht38Subtitle1 = this.elemHelper.WaitForElementPresentGetText(driver, By.xpath( "//div[@id='obj3']/div/*[local-name()='svg' and namespace-uri()='http://www.w3.org/2000/svg']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g'][8]/*[local-name()='g'][7]/*[local-name()='text']")); assertEquals("Customer", cht38Subtitle1); //Check chart WebElement cht38SizeBar = this.elemHelper.FindElement(driver, By.xpath( "//div[@id='obj3']/div/*[local-name()='svg' and namespace-uri()='http://www.w3.org/2000/svg']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g'][8]/*[local-name()='g'][2]/*[local-name()='rect']")); assertNotNull(cht38SizeBar); assertEquals("506.7866666666667", cht38SizeBar.getAttribute("width")); WebElement cht38RectWhite1 = this.elemHelper.FindElement(driver, By.xpath( "//div[@id='obj3']/div/*[local-name()='svg' and namespace-uri()='http://www.w3.org/2000/svg']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g'][8]/*[local-name()='g'][3]/*[local-name()='path'][1]")); assertNotNull(cht38RectWhite1); assertEquals("translate(509.3333333333333,10) ", cht38RectWhite1.getAttribute("transform")); /* * ## Step 4 */ Actions acts = new Actions(driver); acts.moveToElement(this.elemHelper.FindElement(driver, By.cssSelector("div.webdetailsFooterWebdetails"))); acts.perform(); //Chart 4 //Check title String subtitle4 = this.elemHelper.WaitForElementPresentGetText(driver, By.id("subtitle4")); assertEquals("Title, value and marker", subtitle4); //Check serie title and subtitle String cht4Title1 = this.elemHelper.WaitForElementPresentGetText(driver, By.xpath( "//div[@id='obj4']/div/*[local-name()='svg' and namespace-uri()='http://www.w3.org/2000/svg']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g'][6]/*[local-name()='text']")); assertEquals("Atelier graphique", cht4Title1); String cht4Subtitle1 = this.elemHelper.WaitForElementPresentGetText(driver, By.xpath( "//div[@id='obj4']/div/*[local-name()='svg' and namespace-uri()='http://www.w3.org/2000/svg']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g'][7]/*[local-name()='text']")); assertEquals("Subtitle", cht4Subtitle1); //Check chart WebElement cht4SizeBar = this.elemHelper.FindElement(driver, By.xpath( "//div[@id='obj4']/div/*[local-name()='svg' and namespace-uri()='http://www.w3.org/2000/svg']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g'][2]/*[local-name()='rect']")); assertNotNull(cht4SizeBar); WebElement cht4RectWhite1 = this.elemHelper.FindElement(driver, By.xpath( "//div[@id='obj4']/div/*[local-name()='svg' and namespace-uri()='http://www.w3.org/2000/svg']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g'][3]/*[local-name()='path'][1]")); assertNotNull(cht4RectWhite1); /* * ## Step 5 */ //Chart 5 //Check title String subtitle5 = this.elemHelper.WaitForElementPresentGetText(driver, By.id("subtitle5")); assertEquals("Complete dataset", subtitle5); //Check serie title and subtitle String cht5Title1 = this.elemHelper.WaitForElementPresentGetText(driver, By.xpath( "//div[@id='obj5']/div/*[local-name()='svg' and namespace-uri()='http://www.w3.org/2000/svg']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g'][6]/*[local-name()='text']")); assertEquals("Atelier graphique", cht5Title1); String cht5Subtitle1 = this.elemHelper.WaitForElementPresentGetText(driver, By.xpath( "//div[@id='obj5']/div/*[local-name()='svg' and namespace-uri()='http://www.w3.org/2000/svg']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g'][7]/*[local-name()='text']")); assertEquals("Carine Schmitt", cht5Subtitle1); //Check chart WebElement cht5SizeBar = this.elemHelper.FindElement(driver, By.xpath( "//div[@id='obj5']/div/*[local-name()='svg' and namespace-uri()='http://www.w3.org/2000/svg']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g'][2]/*[local-name()='rect']")); assertNotNull(cht5SizeBar); WebElement cht5RectWhite1 = this.elemHelper.FindElement(driver, By.xpath( "//div[@id='obj5']/div/*[local-name()='svg' and namespace-uri()='http://www.w3.org/2000/svg']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g'][3]/*[local-name()='path'][1]")); assertNotNull(cht5RectWhite1); }
From source file:com.pentaho.ctools.cde.reference.CCCV2ShowCase.java
License:Apache License
/** * ############################### Test Case 0 ############################### * * Test Case Name://from w w w .j a v a 2 s. c om * Open sample page. */ @Test public void tc00_OpenSamplePage_Display() { // Go to AddinReference driver.get(baseUrl + "api/repos/%3Apublic%3Aplugin-samples%3Apentaho-cdf-dd%3Atests%3AtestCCCv2-II.wcdf/generatedContent"); // NOTE - we have to wait for loading disappear this.elemHelper.WaitForElementInvisibility(driver, By.cssSelector("div.blockUI.blockOverlay")); // Check page title wait.until(ExpectedConditions.titleIs("CCC V2 ShowCase")); assertEquals("CCC V2 ShowCase", driver.getTitle()); // Check title String title = this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//div[@id='Headers']/div")); assertEquals("CCC v2 - Show Case", title); // Wait for the charts load // search for width of barchartrect1 // search for width of barchartrect2 // search for width of barchartrect3 this.elemHelper.WaitForElementPresenceAndVisible(driver, By.xpath( "//div[@id='BarChartBodyRow']/div/div/*[local-name()='svg' and namespace-uri()='http://www.w3.org/2000/svg']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g'][2]/*[local-name()='g']/*[local-name()='g']/*[local-name()='g'][1]/*[local-name()='rect'][1][@width>192]")); this.elemHelper.WaitForElementPresenceAndVisible(driver, By.xpath( "//div[@id='BarChartBodyRow']/div/div/*[local-name()='svg' and namespace-uri()='http://www.w3.org/2000/svg']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g'][2]/*[local-name()='g']/*[local-name()='g']/*[local-name()='g'][1]/*[local-name()='rect'][2][@width>249]")); this.elemHelper.WaitForElementPresenceAndVisible(driver, By.xpath( "//div[@id='BarChartBodyRow']/div/div/*[local-name()='svg' and namespace-uri()='http://www.w3.org/2000/svg']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g'][2]/*[local-name()='g']/*[local-name()='g']/*[local-name()='g'][1]/*[local-name()='rect'][3][@width>100]")); // search for cy of line1 // search for cy of line7 // search for cy of line11 this.elemHelper.WaitForElementPresenceAndVisible(driver, By.xpath( "//div[@id='LineChartBodyRow']/div/div/*[local-name()='svg' and namespace-uri()='http://www.w3.org/2000/svg']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g'][3]/*[local-name()='g']/*[local-name()='g']/*[local-name()='g'][3]/*[local-name()='circle'][1][@cy>120]")); this.elemHelper.WaitForElementPresenceAndVisible(driver, By.xpath( "//div[@id='LineChartBodyRow']/div/div/*[local-name()='svg' and namespace-uri()='http://www.w3.org/2000/svg']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g'][3]/*[local-name()='g']/*[local-name()='g']/*[local-name()='g'][3]/*[local-name()='circle'][7][@cy>136]")); this.elemHelper.WaitForElementPresenceAndVisible(driver, By.xpath( "//div[@id='LineChartBodyRow']/div/div/*[local-name()='svg' and namespace-uri()='http://www.w3.org/2000/svg']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g'][3]/*[local-name()='g']/*[local-name()='g']/*[local-name()='g'][3]/*[local-name()='circle'][11][@cy>24]")); }
From source file:com.pentaho.ctools.cde.reference.OlapSelectorComponent.java
License:Apache License
/** * ############################### Test Case 1 ############################### * * Test Case Name:/* w ww .j a va 2s . c om*/ * Sniff test to sample * * Description: * This test is to assert simple functionality of sample * * Steps: * 1. Opne sample and assert selector button is shown * 2. Click button and assert options are shown * 3. Make options and click ok, assert options were correctly selected * */ @Test public void tc1_OlapSelectorComponent_SniffTestSample() { this.log.info("tc1_OlapSelectorComponent_SniffTestSample"); /* * ## Step 1 */ // Go to Olap Selector Sample driver.get(baseUrl + "api/repos/%3Apublic%3Aplugin-samples%3Apentaho-cdf-dd%3Atests%3AOlapSelector%3AolapSelector.wcdf/generatedContent"); // NOTE - we have to wait for loading disappear this.elemHelper.WaitForElementInvisibility(driver, By.cssSelector("div.blockUI.blockOverlay")); // Check page title wait.until(ExpectedConditions.titleIs("olapSelector")); assertEquals("olapSelector", driver.getTitle()); // Wait for Selector button WebElement selectorButton = this.elemHelper.WaitForElementPresenceAndVisible(driver, By.xpath("//div[@id='column1']/div/div/div[@class='title']")); assertNotNull(selectorButton); /* * ## Step 2 */ //click selector button selectorButton.click(); //Assert Options are shown WebElement optionList = this.elemHelper.WaitForElementPresenceAndVisible(driver, By.xpath("//div[@id='column1']/div/div/div[@class='optionList']")); assertNotNull(optionList); WebElement firstSelection = this.elemHelper.WaitForElementPresenceAndVisible(driver, By.xpath("//div[@class='options']//span[@title='Alpha Cognac']")); assertNotNull(firstSelection); String firstName = firstSelection.getText(); WebElement secondSelection = this.elemHelper.WaitForElementPresenceAndVisible(driver, By.xpath("//div[@class='options']//span[@title='Asian Shopping Network, Co']")); assertNotNull(secondSelection); String secondName = secondSelection.getText(); WebElement thirdSelection = this.elemHelper.WaitForElementPresenceAndVisible(driver, By.xpath("//div[@class='options']//span[@title='Diecast Collectables']")); assertNotNull(thirdSelection); String thirdName = thirdSelection.getText(); /* * ## Step 3 */ this.elemHelper.WaitForElementPresenceAndVisible(driver, By.xpath("//div[@class='options']//span[@title='Alpha Cognac']")).click(); this.elemHelper.WaitForElementPresenceAndVisible(driver, By.xpath("//div[@class='options']//span[@title='Asian Shopping Network, Co']")).click(); this.elemHelper.WaitForElementPresenceAndVisible(driver, By.xpath("//div[@class='options']//span[@title='Diecast Collectables']")).click(); WebElement applyButton = this.elemHelper.WaitForElementPresenceAndVisible(driver, By.xpath("//div[@class='footer']/div[@class='button validate']")); assertNotNull(applyButton); applyButton.click(); this.elemHelper.WaitForElementNotPresent(driver, By.xpath("//div[@id='column1']/div/div/div[@class='optionList']")); String selectedCustomers = this.elemHelper.WaitForElementPresentGetText(driver, By.id("columnLabel")); String expectedCustomers = "[\"[Customers].[" + firstName + "]\"\"[Customers].[" + secondName + "]\"\"[Customers].[" + thirdName + "]\"]"; assertEquals(expectedCustomers, selectedCustomers); }
From source file:com.pentaho.ctools.cde.require.AjaxRequestReference.java
License:Apache License
/** * ############################### Test Case 1 ############################### * * Test Case Name://from w ww. ja va 2 s .co m * PageContent * Description: * The test case pretends validate the contents presented in the sample. * Steps: * 1. Check page content. */ @Test public void tc01_PageContent_InformationPresent() { this.log.info("tc01_PageContent_InformationPresent"); //Go to AddinReference driver.get(baseUrl + "api/repos/%3Apublic%3Aplugin-samples%3Apentaho-cdf-dd%3Apentaho-cdf-dd-require%3Atests%3AAjaxRequest%3AajaxRequest.wcdf/generatedContent"); // NOTE - we have to wait for loading disappear this.elemHelper.WaitForElementPresence(driver, By.cssSelector("div.blockUI.blockOverlay")); this.elemHelper.WaitForElementNotPresent(driver, By.cssSelector("div.blockUI.blockOverlay")); /* * ## Step 1 */ //Check page title wait.until(ExpectedConditions.titleIs("Ajax Request Reference")); assertEquals("Ajax Request Reference", driver.getTitle()); //Check title String title = this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//div[@id='Title']/span")); assertEquals("Ajax Request Reference", title); //Check first paragh String expParag = "Ajax Request Component provides a way to build an Ajax request. Given an url, a response type and list of parameters it's possible to build an jQuery ajax call, which its result will be stored in the resultvar."; String actParag = this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//div[@id='DescriptionBody']/p")); assertEquals(expParag, actParag); //Check subtitle String subtitle = this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//div[@id='DescriptionBody']/div")); assertEquals("Component Parameters", subtitle); //Check parag 1 String parag1 = this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//div[@id='DescriptionBody']/p[2]")); assertEquals("The Component definition supports the following arguments:", parag1); //Check subtitle2 String subtitle2 = this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//div[@id='DescriptionBody']/div[2]")); assertEquals("Default values", subtitle2); //Check quote String quote = this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//div[@id='DescriptionBody']/blockquote/pre")); assertEquals("defaults: { ajaxRequestType: json, asyncCall: true }", quote); //Check result String jsonQueryExpected = "{\"queryInfo\":{\"totalRows\":\"19\"},\"resultset\":[[\"Car\",\"Red\",10],[\"Car\",\"Blue\",20],[\"Car\",\"Green\",30],[\"Car\",\"Yellow\",5],[\"Car\",\"Black\",25],[\"Car\",\"White\",7],[\"Bike\",\"Red\",20],[\"Bike\",\"Blue\",20],[\"Bike\",\"Green\",40],[\"Bike\",\"Yellow\",80],[\"Bike\",\"Black\",1],[\"Bike\",\"White\",23],[\"Ship\",\"Red\",2],[\"Ship\",\"Blue\",7],[\"Plane\",\"Red\",5],[\"Plane\",\"Blue\",4],[\"Train\",\"Red\",50],[\"Train\",\"Blue\",50],[\"Train\",\"Green\",7]],\"metadata\":[{\"colIndex\":0,\"colType\":\"String\",\"colName\":\"series\"},{\"colIndex\":1,\"colType\":\"String\",\"colName\":\"category\"},{\"colIndex\":2,\"colType\":\"Integer\",\"colName\":\"value\"}]}"; String jsonQueryActual = this.elemHelper.WaitForTextDifferentEmpty(driver, By.id("column1")); JsonParser parser = new JsonParser(); JsonElement actual = parser.parse(jsonQueryActual); JsonElement expected = parser.parse(jsonQueryExpected); assertEquals(actual, expected); }
From source file:com.pentaho.ctools.cde.require.CCCV2ShowCase.java
License:Apache License
/** * ############################### Test Case 0 ############################### * * Test Case Name:/* ww w. ja va 2s . com*/ * Open sample page. */ @Test public void tc00_OpenSamplePage_Display() { // Go to AddinReference driver.get(baseUrl + "api/repos/%3Apublic%3Aplugin-samples%3Apentaho-cdf-dd%3Apentaho-cdf-dd-require%3Atests%3AtestCCCv2-II.wcdf/generatedContent"); // NOTE - we have to wait for loading disappear this.elemHelper.WaitForElementPresence(driver, By.cssSelector("div.blockUI.blockOverlay"), 1); this.elemHelper.WaitForElementInvisibility(driver, By.cssSelector("div.blockUI.blockOverlay")); // Check page title wait.until(ExpectedConditions.titleIs("CCC V2 ShowCase")); assertEquals("CCC V2 ShowCase", driver.getTitle()); // Check title String title = this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//div[@id='Headers']/div")); assertEquals("CCC v2 - Show Case", title); // Wait for the charts load // search for width of barchartrect1 // search for width of barchartrect2 // search for width of barchartrect3 this.elemHelper.WaitForElementPresenceAndVisible(driver, By.xpath( "//div[@id='BarChartBodyRow']/div/div/*[local-name()='svg' and namespace-uri()='http://www.w3.org/2000/svg']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g'][2]/*[local-name()='g']/*[local-name()='g']/*[local-name()='g'][1]/*[local-name()='rect'][1][@width>192]")); this.elemHelper.WaitForElementPresenceAndVisible(driver, By.xpath( "//div[@id='BarChartBodyRow']/div/div/*[local-name()='svg' and namespace-uri()='http://www.w3.org/2000/svg']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g'][2]/*[local-name()='g']/*[local-name()='g']/*[local-name()='g'][1]/*[local-name()='rect'][2][@width>249]")); this.elemHelper.WaitForElementPresenceAndVisible(driver, By.xpath( "//div[@id='BarChartBodyRow']/div/div/*[local-name()='svg' and namespace-uri()='http://www.w3.org/2000/svg']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g'][2]/*[local-name()='g']/*[local-name()='g']/*[local-name()='g'][1]/*[local-name()='rect'][3][@width>100]")); // search for cy of line1 // search for cy of line7 // search for cy of line11 this.elemHelper.WaitForElementPresenceAndVisible(driver, By.xpath( "//div[@id='LineChartBodyRow']/div/div/*[local-name()='svg' and namespace-uri()='http://www.w3.org/2000/svg']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g'][3]/*[local-name()='g']/*[local-name()='g']/*[local-name()='g'][3]/*[local-name()='circle'][1][@cy>120]")); this.elemHelper.WaitForElementPresenceAndVisible(driver, By.xpath( "//div[@id='LineChartBodyRow']/div/div/*[local-name()='svg' and namespace-uri()='http://www.w3.org/2000/svg']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g'][3]/*[local-name()='g']/*[local-name()='g']/*[local-name()='g'][3]/*[local-name()='circle'][7][@cy>136]")); this.elemHelper.WaitForElementPresenceAndVisible(driver, By.xpath( "//div[@id='LineChartBodyRow']/div/div/*[local-name()='svg' and namespace-uri()='http://www.w3.org/2000/svg']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g'][3]/*[local-name()='g']/*[local-name()='g']/*[local-name()='g'][3]/*[local-name()='circle'][11][@cy>24]")); }
From source file:net.atf4j.webdriver.page.AbstractPageObject.java
License:Open Source License
/** * Wait for title to become equal to specific text. * * @param pageTitle the page title/* www.j a v a 2 s. c om*/ * @return true if within timeout, otherwise false. */ public Boolean waitUntilTitle(final String pageTitle) { return this.webDriverWait.until(ExpectedConditions.titleIs(pageTitle)); }
From source file:org.mrge.tradeo.seleniumtask.traderpopup.HomePageTest.java
@Test public void cannotSignInWithWrongPasswordAsCustomerFromHomePage() throws Exception { gotoHomePageAndSignIn(TradeoTestCustomer.loginWrongPassword); WebDriverWait wait = new WebDriverWait(driver, WAIT_AFTER_CLICK_IN_SEC); wait.until(ExpectedConditions.titleIs(TradeoSignInPage.title)); WebElement alert = driver.findElement(By.xpath(TradeoSignInPage.alertXpath)); assertEquals(TradeoSignInPage.invalidLoginAlertTextEnglish, alert.getText()); }