List of usage examples for org.openqa.selenium Keys SHIFT
Keys SHIFT
To view the source code for org.openqa.selenium Keys SHIFT.
Click Source Link
From source file:com.liferay.faces.test.FACES1427PortletTest.java
License:Open Source License
@Test @RunAsClient//from w ww .j a v a 2 s .c o m @InSequence(1300) public void steps89012() throws Exception { if (isThere(browser, errorMessageXpath) && errorMessage.isDisplayed()) { return; } logger.log(Level.INFO, "8: textarea1.getAttribute('value') = " + textarea1.getAttribute("value")); // click into textarea1 textarea1.click(); Thread.sleep(50); // move to the beginning of textarea1 textarea1.sendKeys(Keys.HOME); // firefox cursor is on the left after the last click, in chromium cursor is on // the right of the text ... grr Thread.sleep(50); // arrow over to the word 'initial' textarea1.sendKeys(Keys.ARROW_RIGHT); Thread.sleep(50); textarea1.sendKeys(Keys.ARROW_RIGHT); Thread.sleep(50); textarea1.sendKeys(Keys.ARROW_RIGHT); Thread.sleep(50); textarea1.sendKeys(Keys.ARROW_RIGHT); Thread.sleep(50); textarea1.sendKeys(Keys.ARROW_RIGHT); Thread.sleep(50); textarea1.sendKeys(Keys.ARROW_RIGHT); Thread.sleep(50); textarea1.sendKeys(Keys.ARROW_RIGHT); Thread.sleep(50); textarea1.sendKeys(Keys.ARROW_RIGHT); Thread.sleep(50); textarea1.sendKeys(Keys.ARROW_RIGHT); Thread.sleep(50); textarea1.sendKeys(Keys.ARROW_RIGHT); Thread.sleep(50); // delete the word 'initial' textarea1.sendKeys(Keys.DELETE); Thread.sleep(50); textarea1.sendKeys(Keys.DELETE); Thread.sleep(50); textarea1.sendKeys(Keys.DELETE); Thread.sleep(50); textarea1.sendKeys(Keys.DELETE); Thread.sleep(50); textarea1.sendKeys(Keys.DELETE); Thread.sleep(50); textarea1.sendKeys(Keys.DELETE); Thread.sleep(50); textarea1.sendKeys(Keys.DELETE); Thread.sleep(50); // type the word 'subsequent' textarea1.sendKeys("subsequent"); Thread.sleep(50); // select the word 'subsequent' ... easier said than done logger.log(Level.INFO, "8: textarea1.getAttribute('id') = '" + textarea1.getAttribute("id") + "'"); logger.log(Level.INFO, "8: before selecting ... selectText.getSelection(id) = " + selectText.getSelection(textarea1.getAttribute("id"))); Thread.sleep(500); logger.log(Level.INFO, "8: selectText.getSelection('id', 10, 20) ... "); selectText.setSelection(textarea1.getAttribute("id"), 10, 20); Thread.sleep(1000); logger.log(Level.INFO, "8: after selecting ... selectText.getSelection(id) = " + selectText.getSelection(textarea1.getAttribute("id"))); Thread.sleep(500); logger.log(Level.INFO, "8: isThere(browser, bold1Xpath) = " + isThere(browser, bold1Xpath)); logger.log(Level.INFO, "8: bold1.isDisplayed() = " + bold1.isDisplayed()); logger.log(Level.INFO, "8: bold1.getAttribute('src') = " + bold1.getAttribute("src")); logger.log(Level.INFO, "8: bold1.getLocation() = " + bold1.getLocation()); logger.log(Level.INFO, "8: clicking the bold1 button ..."); // click the bold1 button to make the word 'subsequent' bold try { bold1.click(); } catch (Exception e) { // apparently things are different in chromium logger.log(Level.INFO, "8: e.getMessage() = " + e.getMessage()); (new Actions(browser)).moveToElement(bold1, 3, 3).click(bold1).build().perform(); Thread.sleep(500); (new Actions(browser)).moveToElement(bold1, 3, 3).click().build().perform(); Thread.sleep(500); (new Actions(browser)).moveToElement(bold1).doubleClick().build().perform(); Thread.sleep(500); } Thread.sleep(50); // move into iframe1 logger.log(Level.INFO, "9: clicking into iframe1 ..."); iframe1.click(); Thread.sleep(50); (new Actions(browser)).sendKeys(Keys.TAB).perform(); Thread.sleep(50); // arrow over to the word 'initial' (new Actions(browser)).sendKeys(Keys.ARROW_RIGHT).perform(); Thread.sleep(50); (new Actions(browser)).sendKeys(Keys.ARROW_RIGHT).perform(); Thread.sleep(50); (new Actions(browser)).sendKeys(Keys.ARROW_RIGHT).perform(); Thread.sleep(50); (new Actions(browser)).sendKeys(Keys.ARROW_RIGHT).perform(); Thread.sleep(50); (new Actions(browser)).sendKeys(Keys.ARROW_RIGHT).perform(); Thread.sleep(50); (new Actions(browser)).sendKeys(Keys.ARROW_RIGHT).perform(); Thread.sleep(50); (new Actions(browser)).sendKeys(Keys.ARROW_RIGHT).perform(); Thread.sleep(50); (new Actions(browser)).sendKeys(Keys.ARROW_RIGHT).perform(); Thread.sleep(50); (new Actions(browser)).sendKeys(Keys.ARROW_RIGHT).perform(); Thread.sleep(50); (new Actions(browser)).sendKeys(Keys.ARROW_RIGHT).perform(); Thread.sleep(50); (new Actions(browser)).sendKeys(Keys.ARROW_RIGHT).perform(); Thread.sleep(50); (new Actions(browser)).sendKeys(Keys.ARROW_RIGHT).perform(); Thread.sleep(50); (new Actions(browser)).sendKeys(Keys.ARROW_RIGHT).perform(); Thread.sleep(50); (new Actions(browser)).sendKeys(Keys.ARROW_RIGHT).perform(); Thread.sleep(50); (new Actions(browser)).sendKeys(Keys.ARROW_RIGHT).perform(); Thread.sleep(50); (new Actions(browser)).sendKeys(Keys.ARROW_RIGHT).perform(); Thread.sleep(50); (new Actions(browser)).sendKeys(Keys.ARROW_RIGHT).perform(); Thread.sleep(50); // delete the word 'initial' (new Actions(browser)).sendKeys(Keys.BACK_SPACE).perform(); Thread.sleep(50); (new Actions(browser)).sendKeys(Keys.BACK_SPACE).perform(); Thread.sleep(50); (new Actions(browser)).sendKeys(Keys.BACK_SPACE).perform(); Thread.sleep(50); (new Actions(browser)).sendKeys(Keys.BACK_SPACE).perform(); Thread.sleep(50); (new Actions(browser)).sendKeys(Keys.BACK_SPACE).perform(); Thread.sleep(50); (new Actions(browser)).sendKeys(Keys.BACK_SPACE).perform(); Thread.sleep(50); (new Actions(browser)).sendKeys(Keys.BACK_SPACE).perform(); Thread.sleep(50); // type the word 'subsequent' (new Actions(browser)).sendKeys("subsequent").perform(); Thread.sleep(50); // select the word 'subsequent' ... easier said than done (new Actions(browser)).keyDown(iframe1, Keys.SHIFT).sendKeys(Keys.LEFT).sendKeys(Keys.LEFT) .sendKeys(Keys.LEFT).sendKeys(Keys.LEFT).sendKeys(Keys.LEFT).sendKeys(Keys.LEFT).sendKeys(Keys.LEFT) .sendKeys(Keys.LEFT).sendKeys(Keys.LEFT).sendKeys(Keys.LEFT).keyUp(iframe1, Keys.SHIFT).build() .perform(); Thread.sleep(50); // click the bold2 button to make the word 'subsequent' bold logger.log(Level.INFO, "9: clicking on the bold button in the second editor ..."); bold2.click(); Thread.sleep(50); // Why do we need to click the iframe before clicking the submit button? Who knows? iframe1.click(); Thread.sleep(50); // submit the form logger.log(Level.INFO, "10: clicking the submit button ..."); submit.click(); Thread.sleep(50); // log some elements logger.log(Level.INFO, "11: comments1Output.getText() = " + comments1Output.getText()); logger.log(Level.INFO, "12: comments2Output.getText() = " + comments2Output.getText()); // assert to test assertTrue( "the submitted value for the FIRST editor should be 'comments1-[b]subsequent[/b]-value', but " + "it is '" + comments1Output.getText() + "'", comments1Output.getText().equals("comments1-[b]subsequent[/b]-value")); assertTrue( "the submitted value for the SECOND editor should be 'comments2-[b]subsequent[/b]-value', but " + "it is '" + comments2Output.getText() + "'", comments2Output.getText().equals("comments2-[b]subsequent[/b]-value")); }
From source file:com.liferay.faces.test.Icefaces4PortletTest.java
License:Open Source License
@Test @RunAsClient//w w w. ja va2 s. c om @InSequence(1500) public void dataEntry() throws Exception { String foo = ""; logger.log(Level.INFO, "clicking into the firstNameField ..."); firstNameField.click(); logger.log(Level.INFO, "tabbing into the next field ..."); firstNameField.sendKeys(Keys.TAB); logger.log(Level.INFO, "firstNameField.getAttribute('value') = " + firstNameField.getAttribute("value")); logger.log(Level.INFO, "isThere(browser, firstNameFieldErrorXpath) = " + isThere(browser, firstNameFieldErrorXpath)); if (isThere(browser, firstNameFieldErrorXpath)) { // houston we have a problem logger.log(Level.INFO, "firstNameFieldError.isDisplayed() = " + firstNameFieldError.isDisplayed()); assertFalse( "firstNameFieldError should not be displayed after simply tabbing out of the empty field, having never entered any data. " + "But we see '" + firstNameFieldError.getText() + "'", firstNameFieldError.isDisplayed()); } logger.log(Level.INFO, "Shift tabbing back into the firstNameField ..."); (new Actions(browser)).keyDown(Keys.SHIFT).sendKeys(Keys.TAB).keyDown(Keys.SHIFT).perform(); logger.log(Level.INFO, "isThere(browser, firstNameFieldErrorXpath) = " + isThere(browser, firstNameFieldErrorXpath)); logger.log(Level.INFO, "entering 'asdf' into the firstNameField and then tabbing out of it..."); firstNameField.sendKeys("asdf"); firstNameField.sendKeys(Keys.TAB); logger.log(Level.INFO, "firstNameField.getAttribute('value') = " + firstNameField.getAttribute("value")); logger.log(Level.INFO, "isThere(browser, firstNameFieldErrorXpath) = " + isThere(browser, firstNameFieldErrorXpath)); assertTrue("The data 'asdf' should be in the firstNameField after tabbing out of it", "asdf".equals(firstNameField.getAttribute("value"))); logger.log(Level.INFO, "Shift tabbing back into the firstNameField ..."); (new Actions(browser)).keyDown(Keys.SHIFT).sendKeys(Keys.TAB).keyUp(Keys.SHIFT).perform(); firstNameField.click(); logger.log(Level.INFO, "clearing the firstNameField using the BACKSPACE key, and then tabbing out of the firstNameField ..."); firstNameField.sendKeys(Keys.BACK_SPACE); logger.log(Level.INFO, "Waiting for the firstNameField to contain 'asd' ..."); try { WebDriverWait wait = new WebDriverWait(browser, 10); wait.until(ExpectedConditions.textToBePresentInElementValue(By.xpath(firstNameFieldXpath), "asd")); } catch (Exception e) { logger.log(Level.INFO, "Exception e.getMessage() = " + e.getMessage()); if (isThere(browser, firstNameFieldXpath)) { foo = firstNameField.getText(); } logger.log(Level.INFO, "firstNameField.getText() = " + firstNameField.getText()); assertTrue( "firstNameField should contain 'asd', but " + firstNameFieldXpath + " contains '" + foo + "'.", false); } firstNameField.sendKeys(Keys.BACK_SPACE); logger.log(Level.INFO, "Waiting for the firstNameField to contain 'as' ..."); try { WebDriverWait wait = new WebDriverWait(browser, 10); wait.until(ExpectedConditions.textToBePresentInElementValue(By.xpath(firstNameFieldXpath), "as")); } catch (Exception e) { logger.log(Level.INFO, "Exception e.getMessage() = " + e.getMessage()); if (isThere(browser, firstNameFieldXpath)) { foo = firstNameField.getText(); } assertTrue( "firstNameField should contain 'as', but " + firstNameFieldXpath + " contains '" + foo + "'.", false); } firstNameField.sendKeys(Keys.BACK_SPACE); logger.log(Level.INFO, "Waiting for the firstNameField to contain 'a' ..."); try { WebDriverWait wait = new WebDriverWait(browser, 10); wait.until(ExpectedConditions.textToBePresentInElementValue(By.xpath(firstNameFieldXpath), "a")); } catch (Exception e) { logger.log(Level.INFO, "Exception e.getMessage() = " + e.getMessage()); if (isThere(browser, firstNameFieldXpath)) { foo = firstNameField.getText(); } assertTrue("firstNameField should contain 'a', but " + firstNameFieldXpath + " contains '" + foo + "'.", false); } firstNameField.sendKeys(Keys.BACK_SPACE); logger.log(Level.INFO, "Waiting for the firstNameField to contain '' ..."); try { WebDriverWait wait = new WebDriverWait(browser, 10); wait.until(ExpectedConditions.textToBePresentInElementValue(By.xpath(firstNameFieldXpath), "")); } catch (Exception e) { logger.log(Level.INFO, "Exception e.getMessage() = " + e.getMessage()); if (isThere(browser, firstNameFieldXpath)) { foo = firstNameField.getText(); } assertTrue("firstNameField should contain '', but " + firstNameFieldXpath + " contains '" + foo + "'.", false); } firstNameField.sendKeys(Keys.TAB); logger.log(Level.INFO, "Waiting for the firstNameFieldError to contain 'Value is required' ..."); try { WebDriverWait wait = new WebDriverWait(browser, 10); wait.until(ExpectedConditions.textToBePresentInElementLocated(By.xpath(firstNameFieldErrorXpath), "Value is required")); } catch (Exception e) { logger.log(Level.INFO, "Exception e.getMessage() = " + e.getMessage()); assertTrue("firstNameFieldError should be visible after tabbing out with no value," + " but " + firstNameFieldErrorXpath + " is not visible.", false); } logger.log(Level.INFO, "firstNameField.getAttribute('value') = " + firstNameField.getAttribute("value")); assertTrue( "The data 'asdf' should no longer be in the firstNameField after clearing it out with BACK_SPACE and then tabbing out. " + "But we see '" + firstNameField.getAttribute("value") + "'", "".equals(firstNameField.getAttribute("value"))); logger.log(Level.INFO, "isThere(browser, firstNameFieldErrorXpath) = " + isThere(browser, firstNameFieldErrorXpath)); assertTrue( "The firstNameFieldError should at least be in the DOM somewhere by this point, but it is not there", isThere(browser, firstNameFieldErrorXpath)); logger.log(Level.INFO, "firstNameFieldError.getText() = " + firstNameFieldError.getText()); assertTrue("The firstNameFieldError should say 'Value is required'", firstNameFieldError.getText().contains("Value is required")); }
From source file:com.liferay.faces.test.PlutoTest.java
License:Open Source License
@Test @RunAsClient/*from w w w . j a va 2 s. c o m*/ @InSequence(1500) public void dataEntry() throws Exception { logger.log(Level.INFO, "clicking into the firstNameField ..."); firstNameField.click(); Thread.sleep(50); logger.log(Level.INFO, "tabbing into the next field ..."); firstNameField.sendKeys(Keys.TAB); Thread.sleep(500); logger.log(Level.INFO, "firstNameField.getAttribute('value') = " + firstNameField.getAttribute("value")); logger.log(Level.INFO, "isThere(browser, firstNameFieldErrorXpath) = " + isThere(browser, firstNameFieldErrorXpath)); if (isThere(browser, firstNameFieldErrorXpath)) { // houston we have a problem logger.log(Level.INFO, "firstNameFieldError.isDisplayed() = " + firstNameFieldError.isDisplayed()); assertFalse( "firstNameFieldError should not be displayed after simply tabbing out of the empty field, having never entered any data. " + "But we see '" + firstNameFieldError.getText() + "'", firstNameFieldError.isDisplayed()); } logger.log(Level.INFO, "Shift tabbing back into the firstNameField ..."); (new Actions(browser)).keyDown(Keys.SHIFT).sendKeys(Keys.TAB).keyDown(Keys.SHIFT).perform(); Thread.sleep(50); logger.log(Level.INFO, "isThere(browser, firstNameFieldErrorXpath) = " + isThere(browser, firstNameFieldErrorXpath)); logger.log(Level.INFO, "entering 'asdf' into the firstNameField and then tabbing out of it..."); firstNameField.sendKeys("asdf"); firstNameField.sendKeys(Keys.TAB); Thread.sleep(50); logger.log(Level.INFO, "firstNameField.getAttribute('value') = " + firstNameField.getAttribute("value")); logger.log(Level.INFO, "isThere(browser, firstNameFieldErrorXpath) = " + isThere(browser, firstNameFieldErrorXpath)); assertTrue("The data 'asdf' should be in the firstNameField after tabbing out of it", "asdf".equals(firstNameField.getAttribute("value"))); logger.log(Level.INFO, "Shift tabbing back into the firstNameField ..."); (new Actions(browser)).keyDown(Keys.SHIFT).sendKeys(Keys.TAB).keyDown(Keys.SHIFT).perform(); Thread.sleep(50); logger.log(Level.INFO, "clearing the firstNameField using the BACKSPACE key, and then tabbing out of the firstNameField ..."); firstNameField.sendKeys(Keys.BACK_SPACE); Thread.sleep(50); firstNameField.sendKeys(Keys.BACK_SPACE); Thread.sleep(50); firstNameField.sendKeys(Keys.BACK_SPACE); Thread.sleep(50); firstNameField.sendKeys(Keys.BACK_SPACE); Thread.sleep(50); firstNameField.sendKeys(Keys.TAB); Thread.sleep(50); logger.log(Level.INFO, "firstNameField.getAttribute('value') = " + firstNameField.getAttribute("value")); assertTrue( "The data 'asdf' should no longer be in the firstNameField after clearing it out with BACK_SPACE and then tabbing out. " + "But we see '" + firstNameField.getAttribute("value") + "'", "".equals(firstNameField.getAttribute("value"))); logger.log(Level.INFO, "isThere(browser, firstNameFieldErrorXpath) = " + isThere(browser, firstNameFieldErrorXpath)); assertTrue( "The firstNameFieldError should at least be in the DOM somewhere by this point, but it is not there", isThere(browser, firstNameFieldErrorXpath)); logger.log(Level.INFO, "firstNameFieldError.getText() = " + firstNameFieldError.getText()); assertTrue("The firstNameFieldError should say 'Value is required'", firstNameFieldError.getText().contains("Value is required")); }
From source file:com.machinepublishers.jbrowserdriver.KeyboardServer.java
License:Apache License
/** * {@inheritDoc}/*from w w w . ja v a 2 s.c o m*/ */ @Override public void pressKey(CharSequence key) { synchronized (lock) { if (!shiftPressed) { shiftPressed = Keys.SHIFT.equals(key) || Keys.LEFT_SHIFT.equals(key); } } robot.get().keysPress(key); }
From source file:com.machinepublishers.jbrowserdriver.KeyboardServer.java
License:Apache License
/** * {@inheritDoc}/* ww w . j a v a2s . com*/ */ @Override public void releaseKey(CharSequence key) { synchronized (lock) { if (shiftPressed) { shiftPressed = !Keys.SHIFT.equals(key) && !Keys.LEFT_SHIFT.equals(key); } } robot.get().keysRelease(key); }
From source file:com.me.jvmi.SelectElement.java
public void selectAll(Set<String> optionsText) { Actions shiftClick = new Actions(driver); shiftClick = shiftClick.keyDown(Keys.SHIFT); List<WebElement> options = select.findElements(By.tagName("option")); for (WebElement option : options) { if (optionsText.contains(option.getText())) { shiftClick = shiftClick.click(option); }//from w w w. jav a 2s . c o m } shiftClick.keyUp(Keys.SHIFT).perform(); }
From source file:com.mkl.websuites.internal.command.impl.key.PressCommand.java
License:Apache License
private Keys keyFromModifier(String key) { switch (key) { case "CTRL": return Keys.CONTROL; case "ALT": return Keys.ALT; case "SHIFT": return Keys.SHIFT; default:/*from w w w .ja v a 2 s .c om*/ return null; } }
From source file:com.nabla.project.fronter.selenium.tests.helper.SeleniumHelper.java
License:Open Source License
public static void testRowSelectionUsingShiftKey(final List<WebElement> tableRowsInput, final List<WebElement> tableRowsOutput, final long expectedRows, final WebDriver driver) { // List<WebElement> tableRowsInput = driver.findElements(By.xpath("//table[@class='myDataTbl']/tbody/tr")); // Selected Row Table shows two rows selected // List<WebElement> tableRowsOutput = driver.findElements(By.xpath("//div[@class='icePnlGrp exampleBox']/table[@class='myDataTbl']/tbody/tr")); // Select first row to fourth row from Table using Shift Key // Row Index start at 0 final Actions builder = new Actions(driver); builder.click(tableRowsInput.get(0)).keyDown(Keys.SHIFT).click(tableRowsInput.get(1)) .click(tableRowsInput.get(2)).click(tableRowsInput.get(3)).keyUp(Keys.SHIFT).build().perform(); // Verify Selected Row Table shows X rows selected Assert.assertEquals(expectedRows, tableRowsOutput.size()); }
From source file:com.opera.core.systems.DriverKeysTest.java
License:Apache License
@Test public void testShiftCapitals() { new Actions(driver).sendKeys("a").sendKeys(Keys.SHIFT + "bc").sendKeys("d").build().perform(); assertEquals("aBCd", fieldOne.getAttribute("value")); }
From source file:com.pentaho.ctools.issues.cde.CDE286.java
License:Apache License
/** * ############################### Test Case 1 ############################### * * Test Case Name:// ww w .j a v a2s . c om * Asserting CGG Dial Chart can be exported and viewed via URL * * Description: * The test pretends validate the CDE-286 issue, so when user exports a CGG Dial Component it can * be viewed via the URL given. * * Steps: * 1. Wait for new Dashboard to be created, assert elements on page and click "Components Panel" * 2. Add CGG Dial Component and fill it's properties * 3. Click "Shift+G" to create export file and choose URL * 4. Add "¶m=25" to URL and assert Dial Component is properly shown * @throws InterruptedException * */ @Test public void tc01_NewCdeDashboard_CggDialComponentExport() { this.log.info("tc01_NewCdeDashboard_CggDialComponentExport"); /* * ## Step 1 */ //Go to New CDE Dashboard driver.get(PageUrl.CDE_DASHBOARD); this.elemHelper.WaitForElementInvisibility(driver, By.cssSelector("div.blockUI.blockOverlay")); //assert buttons WebElement buttonSaveTemplate = this.elemHelper.WaitForElementPresence(driver, By.xpath("//a[@title='Save as Template']")); WebElement buttonApplyTemplate = this.elemHelper.WaitForElementPresence(driver, By.xpath("//a[@title='Apply Template']")); WebElement buttonAddResource = this.elemHelper.WaitForElementPresence(driver, By.xpath("//a[@title='Add Resource']")); WebElement buttonAddBoostrap = this.elemHelper.WaitForElementPresence(driver, By.xpath("//a[@title='Add Bootstrap Panel']")); WebElement buttonAddFreeForm = this.elemHelper.WaitForElementPresence(driver, By.xpath("//a[@title='Add FreeForm']")); WebElement buttonAddRow = this.elemHelper.WaitForElementPresence(driver, By.xpath("//a[@title='Add Row']")); WebElement buttonLayout = this.elemHelper.WaitForElementPresenceAndVisible(driver, By.xpath("//div[@class='layoutPanelButton']")); WebElement buttonComponents = this.elemHelper.WaitForElementPresenceAndVisible(driver, By.xpath("//div[@class='componentsPanelButton']")); WebElement buttonDatasources = this.elemHelper.WaitForElementPresenceAndVisible(driver, By.xpath("//div[@class='datasourcesPanelButton']")); assertNotNull(buttonSaveTemplate); assertNotNull(buttonApplyTemplate); assertNotNull(buttonAddResource); assertNotNull(buttonAddBoostrap); assertNotNull(buttonAddFreeForm); assertNotNull(buttonAddRow); assertNotNull(buttonLayout); assertNotNull(buttonComponents); assertNotNull(buttonDatasources); this.elemHelper.Click(driver, By.cssSelector("div.componentsPanelButton")); /* * ## Step 2 */ this.elemHelper.Click(driver, By.xpath("//div[@id='cdfdd-components-palletePallete']/div/h3/span")); this.elemHelper.Click(driver, By.xpath( "//div[@id='cdfdd-components-palletePallete']/div/div/ul/li[24]/a[@title='CGG Dial Chart']")); String componentName = this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='table-cdfdd-components-components']/tbody/tr[2]/td")); assertEquals(componentName, "CGG Dial Component"); //Add Name String expectedChartName = "dial"; this.elemHelper .FindElement(driver, By.xpath( "//div[@id='cdfdd-components-properties']/div/div[2]/table/tbody/tr/td[2]/form/input")) .sendKeys("dial"); this.elemHelper .FindElement(driver, By.xpath( "//div[@id='cdfdd-components-properties']/div/div[2]/table/tbody/tr/td[2]/form/input")) .submit(); this.elemHelper.WaitForTextPresence(driver, By.xpath("//div[@id='cdfdd-components-properties']/div/div[2]/table/tbody/tr/td[2]"), "dial"); String actualChartName = this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//div[@id='cdfdd-components-properties']/div/div[2]/table/tbody/tr/td[2]")); assertEquals(expectedChartName, actualChartName); //Add Color Range String strColor1 = "blue"; String strColor2 = "green"; String strColor3 = "brown"; this.elemHelper.Click(driver, By.xpath("//table[@id='table-cdfdd-components-properties']/tbody/tr[2]/td[2]")); //We need to wait for the animation finish for the display popup this.elemHelper.FindElement(driver, By.id("popup")); //Add Colors //this.elemHelper.Click( driver, By.cssSelector( "button.popup-add-row-button" ) ); WebElement elemArg0 = this.elemHelper.FindElement(driver, By.id("arg_0")); this.elemHelper.Click(driver, By.cssSelector("button.popup-add-row-button")); WebElement elemArg1 = this.elemHelper.FindElement(driver, By.id("arg_1")); this.elemHelper.Click(driver, By.cssSelector("button.popup-add-row-button")); WebElement elemArg2 = this.elemHelper.FindElement(driver, By.id("arg_2")); assertNotNull(elemArg0); assertNotNull(elemArg1); assertNotNull(elemArg2); //Add the first color this.elemHelper.ClickAndSendKeys(driver, By.id("arg_0"), strColor3); //Add the second color this.elemHelper.ClickAndSendKeys(driver, By.id("arg_1"), strColor2); //Add the third color this.elemHelper.ClickAndSendKeys(driver, By.id("arg_2"), strColor1); //Submit this.elemHelper.Click(driver, By.id("popup_state0_buttonOk")); //Wait For Popup Disappear this.elemHelper.WaitForElementNotPresent(driver, By.id("popupbox")); //Check the colors array this.elemHelper.WaitForTextPresence(driver, By.xpath("//table[@id='table-cdfdd-components-properties']/tbody/tr[2]/td[2]"), "[\"" + strColor3 + "\",\"" + strColor2 + "\",\"" + strColor1 + "\"]"); String rangeColorArray = this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='table-cdfdd-components-properties']/tbody/tr[2]/td[2]")); assertEquals("[\"brown\",\"green\",\"blue\"]", rangeColorArray); //Add Intervals Array String strInterval0 = "100"; String strInterval1 = "50"; String strInterval2 = "25"; String strInterval3 = "0"; this.elemHelper.Click(driver, By.xpath("//table[@id='table-cdfdd-components-properties']/tbody/tr[3]/td[2]")); //We need to wait for the animation finish for the display popup this.elemHelper.FindElement(driver, By.id("popup")); //Add intervals //this.elemHelper.Click( driver, By.cssSelector( "button.popup-add-row-button" ) ); WebElement elemInterArg0 = this.elemHelper.FindElement(driver, By.id("arg_0")); this.elemHelper.Click(driver, By.cssSelector("button.popup-add-row-button")); // Add arg1 WebElement elemInterArg1 = this.elemHelper.FindElement(driver, By.id("arg_1")); this.elemHelper.Click(driver, By.cssSelector("button.popup-add-row-button")); // Add arg2 WebElement elemInterArg2 = this.elemHelper.FindElement(driver, By.id("arg_2")); this.elemHelper.Click(driver, By.cssSelector("button.popup-add-row-button")); // Add arg3 WebElement elemInterArg3 = this.elemHelper.FindElement(driver, By.id("arg_3")); assertNotNull(elemInterArg0); assertNotNull(elemInterArg1); assertNotNull(elemInterArg2); assertNotNull(elemInterArg3); //Add interval 0 this.elemHelper.ClickAndSendKeys(driver, By.id("arg_0"), strInterval3); //Add interval 1 this.elemHelper.ClickAndSendKeys(driver, By.id("arg_1"), strInterval2); //Add interval 2 this.elemHelper.ClickAndSendKeys(driver, By.id("arg_2"), strInterval1); //Add interval 3 this.elemHelper.ClickAndSendKeys(driver, By.id("arg_3"), strInterval0); // Submit this.elemHelper.ClickJS(driver, By.id("popup_state0_buttonOk")); //Wait For Popup Disappear this.elemHelper.WaitForElementNotPresent(driver, By.id("popupbox")); //Check if was saved String expectedIntervalArray = "[\"" + strInterval3 + "\",\"" + strInterval2 + "\",\"" + strInterval1 + "\",\"" + strInterval0 + "\"]"; this.elemHelper.WaitForTextPresence(driver, By.xpath("//table[@id='table-cdfdd-components-properties']/tbody/tr[3]/td[2]"), expectedIntervalArray); String actualIntervalsArray = this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='table-cdfdd-components-properties']/tbody/tr[3]/td[2]")); assertEquals(expectedIntervalArray, actualIntervalsArray); //Add Parameter String expectedParameter = "27"; this.elemHelper.Click(driver, By.xpath("//table[@id='table-cdfdd-components-properties']/tbody/tr[4]/td[2]")); this.elemHelper .FindElement(driver, By.xpath("//table[@id='table-cdfdd-components-properties']/tbody/tr[4]/td[2]/form/input")) .sendKeys(expectedParameter); this.elemHelper .FindElement(driver, By.xpath("//table[@id='table-cdfdd-components-properties']/tbody/tr[4]/td[2]/form/input")) .submit(); String actualParameter = this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='table-cdfdd-components-properties']/tbody/tr[4]/td[2]")); assertEquals(expectedParameter, actualParameter); //Add Height String expectedHeight = "321"; this.elemHelper.Click(driver, By.xpath("//table[@id='table-cdfdd-components-properties']/tbody/tr[6]/td[2]")); this.elemHelper .FindElement(driver, By.xpath("//table[@id='table-cdfdd-components-properties']/tbody/tr[6]/td[2]/form/input")) .sendKeys(expectedHeight); this.elemHelper .FindElement(driver, By.xpath("//table[@id='table-cdfdd-components-properties']/tbody/tr[6]/td[2]/form/input")) .submit(); String actualHeight = this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='table-cdfdd-components-properties']/tbody/tr[6]/td[2]")); assertEquals(expectedHeight, actualHeight); //Add Width String expectedWidth = "215"; this.elemHelper.Click(driver, By.xpath("//table[@id='table-cdfdd-components-properties']/tbody/tr[7]/td[2]")); this.elemHelper .FindElement(driver, By.xpath("//table[@id='table-cdfdd-components-properties']/tbody/tr[7]/td[2]/form/input")) .sendKeys(expectedWidth); this.elemHelper .FindElement(driver, By.xpath("//table[@id='table-cdfdd-components-properties']/tbody/tr[7]/td[2]/form/input")) .submit(); String actualWidth = this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='table-cdfdd-components-properties']/tbody/tr[7]/td[2]")); assertEquals(expectedWidth, actualWidth); /* * ## Step 3 */ Actions a = new Actions(driver); a.keyDown(Keys.SHIFT).sendKeys("g").keyUp(Keys.SHIFT).build().perform(); WebElement cggDialog = this.elemHelper.WaitForElementPresence(driver, By.id("cggDialog")); assertNotNull(cggDialog); String actualCggDialogTitle = this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//div[@id='cggDialog']/h3")); assertEquals("Choose what charts to render as CGG", actualCggDialogTitle); String actualChartNameTorender = this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//div[@id='cggDialog']/div/span")); assertEquals(expectedChartName, actualChartNameTorender); this.elemHelper.Click(driver, By.xpath("//div[@id='cggDialog']/div/input")); this.elemHelper.Click(driver, By.xpath("//div[@id='cggDialog']/div/button")); String actualUrl = this.elemHelper.GetAttribute(driver, By.xpath("//div[@id='cggDialog']/div/div/input"), "value"); String expectedURL = baseUrl + "plugin/cgg/api/services/draw?script=/system/pentaho-cdf-dd/resources/custom/components/cgg/charts/dial.js¶mcolors=" + strColor3 + "¶mcolors=" + strColor2 + "¶mcolors=" + strColor1 + "¶mscale=" + strInterval3 + "¶mscale=" + strInterval2 + "¶mscale=" + strInterval1 + "¶mscale=" + strInterval0 + "&height=" + expectedHeight + "&width=" + expectedWidth + "&outputType=png"; assertEquals(expectedURL, actualUrl); /* * ## Step 4 */ driver.get(expectedURL + "¶mvalue=25"); WebElement elemImg = this.elemHelper.FindElement(driver, By.cssSelector("img")); assertNotNull(elemImg); String actualImgUrl = this.elemHelper.GetAttribute(driver, By.cssSelector("img"), "src"); assertEquals(actualImgUrl, expectedURL + "¶mvalue=25"); }