List of usage examples for org.openqa.selenium.interactions Actions click
public Actions click(WebElement target)
From source file:com.liferay.faces.portal.test.showcase.inputrichtext.InputRichTextDefaultValueTester.java
License:Open Source License
@Test public void runInputRichTextGeneralTest() { // 1. Navigate to the "inputRichText" "Default Value" use case. BrowserDriver browserDriver = getBrowserDriver(); navigateToUseCase(browserDriver, "inputRichText", "default-value"); // 2. Verify that "<p>This is some <strong>bold</strong> text<br />\nand this is some <em>italic</em> text.</p>" // appears in the *Model Value*. WaitingAsserter waitingAsserter = getWaitingAsserter(); waitingAsserter.assertTextPresentInElement( "<p>This is some <strong>bold</strong> text<br />\nand this is some <em>italic</em> text.</p>", modelValue1Xpath);/*w w w . j a v a 2 s . co m*/ // 3. Before the text "ld text and this is some italic text.", type "ld o". browserDriver.switchToFrame(CK_EDITOR_IFRAME_XPATH); Actions insertText = browserDriver.createActions(BODY_XPATH); WebElement body = browserDriver.findElementByXpath(BODY_XPATH); insertText.click(body); for (int i = 0; i < "ld text and this is some italic text.".length(); i++) { insertText.sendKeys(Keys.LEFT); } insertText.perform(); browserDriver.sendKeysToElement(BODY_XPATH, "ld o"); // 4. Click the *Submit* button. String expectedText = "<p>This is some <strong>bold old</strong> text<br />\nand this is some <em>italic</em> text.</p>"; submitRichText(browserDriver, submitButton1Xpath, 1, expectedText); //J- // 5. Verify that // "<p>This is some <strong>bold old</strong> text<br />\nand this is some <em>italic</em> text.</p>" appears in // the *Model Value*. //J+ waitingAsserter.assertTextPresentInElement(expectedText, modelValue1Xpath); }
From source file:com.liferay.faces.portal.test.showcase.inputrichtext.InputRichTextTester.java
License:Open Source License
protected static void selectTextAndSendKeys(BrowserDriver browserDriver, String completeText, String textToSelect, CharSequence... keys) { if (!completeText.contains(textToSelect)) { throw new IllegalArgumentException( "\"" + completeText + "\" does not contain \"" + textToSelect + "\""); }// ww w .ja va 2s . c o m Actions boldAndItalicize = browserDriver.createActions(BODY_XPATH); WebElement body = browserDriver.findElementByXpath(BODY_XPATH); boldAndItalicize.click(body); for (int i = 0; i < completeText.length(); i++) { boldAndItalicize.sendKeys(Keys.LEFT); } int beginIndex = completeText.indexOf(textToSelect); for (int i = 0; i < beginIndex; i++) { boldAndItalicize.sendKeys(Keys.RIGHT); } boldAndItalicize.keyDown(Keys.SHIFT); for (int i = 0; i < textToSelect.length(); i++) { boldAndItalicize.sendKeys(Keys.RIGHT); } boldAndItalicize.keyUp(Keys.SHIFT); boldAndItalicize.perform(); browserDriver.sendKeysToElement(BODY_XPATH, keys); }
From source file:com.liferay.faces.test.selenium.browser.internal.BrowserDriverImpl.java
License:Open Source License
@Override public Action createClickElementAction(String elementXpath) { Actions actions = createActions(elementXpath); WebElement webElement = findElementByXpath(elementXpath); actions = actions.click(webElement); return actions.build(); }
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); }/* w w w . j a v a 2s. c o m*/ } shiftClick.keyUp(Keys.SHIFT).perform(); }
From source file:com.nabla.project.fronter.selenium.tests.helper.SeleniumHelper.java
License:Open Source License
public static void testRowSelectionUsingControlKey(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 second and fourth row from Table using Control Key. // Row Index start at 0 final Actions builder = new Actions(driver); builder.click(tableRowsInput.get(1)).keyDown(Keys.CONTROL).click(tableRowsInput.get(3)).keyUp(Keys.CONTROL) .build().perform();//from w ww .j a va 2 s. c o m // Verify Selected Row Table shows X rows selected Assert.assertEquals(expectedRows, tableRowsOutput.size()); }
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.NFHS.PageObjects.UserAccountPage.java
public void courseEvaluation() throws Exception { Actions builder = new Actions(driver); builder.click(webElementProperty("evaluation_rb1")).perform(); builder.click(webElementProperty("evaluation_rb2")).perform(); builder.click(webElementProperty("evaluation_rb3")).perform(); builder.click(webElementProperty("evaluation_rb4")).perform(); builder.click(webElementProperty("evaluation_rb5")).perform(); builder.click(webElementProperty("evaluation_rb6")).perform(); }
From source file:com.NFHS.PageObjects.UserAccountPage.java
public void coursePage() throws Exception { driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); webElementProperty("mycourses").click(); webElementProperty("completecoursebutton").click(); if (webElementProperty("introduction").getText().equals("Introduction")) { System.out.println("next button is disabled"); System.out.println(webElementProperty("nextbutton").isEnabled()); Actions builder = new Actions(driver); builder.click(webElementProperty("1strdbtn")).perform(); if (webElementProperty("cc_submitbutton").isEnabled()) { driver.manage().timeouts().implicitlyWait(5, TimeUnit.MINUTES); webElementProperty("cc_submitbutton").click(); }/*from ww w. j av a2 s .com*/ //2 question selected Thread.sleep(2000); builder.click(webElementProperty("1strdbtn")).perform(); if (webElementProperty("cc_submitbutton").isEnabled()) { webElementProperty("cc_submitbutton").click(); } Thread.sleep(2000); //3 question selected builder.click(webElementProperty("1strdbtn")).perform(); if (webElementProperty("cc_submitbutton").isEnabled()) { webElementProperty("cc_submitbutton").click(); } Thread.sleep(2000); //4 question selecte builder.click(webElementProperty("1strdbtn")).perform(); if (webElementProperty("cc_submitbutton").isEnabled()) { webElementProperty("cc_submitbutton").click(); } Thread.sleep(2000); //5 question selected builder.click(webElementProperty("1strdbtn")).perform(); if (webElementProperty("cc_submitbutton").isEnabled()) { webElementProperty("cc_submitbutton").click(); } Thread.sleep(2000); //6 question selected builder.click(webElementProperty("1strdbtn")).perform(); if (webElementProperty("cc_submitbutton").isEnabled()) { webElementProperty("cc_submitbutton").click(); } Thread.sleep(2000); //7 question selected builder.click(webElementProperty("1strdbtn")).perform(); if (webElementProperty("cc_submitbutton").isEnabled()) { webElementProperty("cc_submitbutton").click(); } Thread.sleep(2000); //8 question selected builder.click(webElementProperty("1strdbtn")).perform(); if (webElementProperty("cc_submitbutton").isEnabled()) { webElementProperty("cc_submitbutton").click(); } Thread.sleep(2000); //9 question selected builder.click(webElementProperty("1strdbtn")).perform(); if (webElementProperty("cc_submitbutton").isEnabled()) { webElementProperty("cc_submitbutton").click(); } Thread.sleep(2000); //10 question selected builder.click(webElementProperty("1strdbtn")).perform(); if (webElementProperty("cc_submitbutton").isEnabled()) { webElementProperty("cc_submitbutton").click(); } Thread.sleep(2000); //11 question selected builder.click(webElementProperty("1strdbtn")).perform(); if (webElementProperty("cc_submitbutton").isEnabled()) { webElementProperty("cc_submitbutton").click(); } Thread.sleep(1000); nextButtonClick(); } /*System.out.println("Before 4 if enabled"); driver.manage().timeouts().implicitlyWait(2, TimeUnit.MINUTES); if(webElementProperty("3breadcrumb").isEnabled() || !webElementProperty("4breadcrumb").isEnabled()) { driver.manage().timeouts().implicitlyWait(2, TimeUnit.MINUTES); WebElement nextbtn=webElementProperty("nextbutton"); if(nextbtn.isEnabled()) { nextbtn.click(); } } System.out.println("before 5 is enabled"); driver.manage().timeouts().implicitlyWait(2, TimeUnit.MINUTES); if(webElementProperty("4breadcrumb").isEnabled() || !webElementProperty("5breadcrumb").isEnabled()) { driver.manage().timeouts().implicitlyWait(2, TimeUnit.MINUTES); WebElement nextbtn=webElementProperty("nextbutton"); if(nextbtn.isEnabled()) { nextbtn.click(); } } Thread.sleep(2000); oneEnabledTwoDisabled(); twoEnabledThreeDisabled(); isThreeEnabled(); oneEnabledTwoDisabled(); twoEnabledThreeDisabled(); isThreeEnabled(); nextButtonClick(); twoEnabledThreeDisabled(); threeEnabledFourDisabled(); isFourEnabled(); oneEnabledTwoDisabled(); twoEnabledThreeDisabled(); threeEnabledFourDisabled(); isFourEnabled(); oneEnabledTwoDisabled(); isTwoEnabled(); oneEnabledTwoDisabled(); twoEnabledThreeDisabled(); threeEnabledFourDisabled(); isFourEnabled(); oneEnabledTwoDisabled(); webElementProperty("unit3_Img1").click(); webElementProperty("unit3_Img2").click(); nextButtonClick(); isThreeEnabled(); nextButtonClick(); nextButtonClick(); isOneEnabled(); if(webElementProperty("1breadcrumb").isEnabled()) { Thread.sleep(5000); //1 question selected Actions builder =new Actions(driver); builder.click(webElementProperty("1strdbtn")).perform(); if(webElementProperty("cc_submitbutton").isEnabled()) { webElementProperty("cc_submitbutton").click(); } //2 question selected Thread.sleep(2000); builder.click(webElementProperty("1strdbtn")).perform(); if(webElementProperty("cc_submitbutton").isEnabled()) { webElementProperty("cc_submitbutton").click(); } Thread.sleep(2000); builder.click(webElementProperty("1strdbtn")).perform(); //3 question selected if(webElementProperty("cc_submitbutton").isEnabled()) { webElementProperty("cc_submitbutton").click(); } Thread.sleep(2000); //4 question selecte builder.click(webElementProperty("1strdbtn")).perform(); if(webElementProperty("cc_submitbutton").isEnabled()) { webElementProperty("cc_submitbutton").click(); } Thread.sleep(2000); //5 question selected builder.click(webElementProperty("1strdbtn")).perform(); if(webElementProperty("cc_submitbutton").isEnabled()) { webElementProperty("cc_submitbutton").click(); } Thread.sleep(2000); //6 question selected builder.click(webElementProperty("1strdbtn")).perform(); if(webElementProperty("cc_submitbutton").isEnabled()) { webElementProperty("cc_submitbutton").click(); } Thread.sleep(2000); //7 question selected builder.click(webElementProperty("1strdbtn")).perform(); if(webElementProperty("cc_submitbutton").isEnabled()) { webElementProperty("cc_submitbutton").click(); } Thread.sleep(2000); //8 question selected builder.click(webElementProperty("1strdbtn")).perform(); if(webElementProperty("cc_submitbutton").isEnabled()) { webElementProperty("cc_submitbutton").click(); } Thread.sleep(2000); //9 question selected builder.click(webElementProperty("1strdbtn")).perform(); if(webElementProperty("cc_submitbutton").isEnabled()) { webElementProperty("cc_submitbutton").click(); } Thread.sleep(2000); //10 question selected builder.click(webElementProperty("1strdbtn")).perform(); if(webElementProperty("cc_submitbutton").isEnabled()) { webElementProperty("cc_submitbutton").click(); } Thread.sleep(2000); //11 question selected builder.click(webElementProperty("1strdbtn")).perform(); if(webElementProperty("cc_submitbutton").isEnabled()) { webElementProperty("cc_submitbutton").click(); } WebElement nextbtn1=webElementProperty("nextbutton"); if(nextbtn1.isEnabled()) { nextbtn1.click(); } } JavascriptExecutor js=(JavascriptExecutor)driver; js.executeScript("scroll(0,200)"); nextButtonClick(); oneEnabledTwoDisabled(); isTwoEnabled(); isOneEnabled(); isOneEnabled(); courseEvaluation(); webElementProperty("evaluation_submit").click(); webElementProperty("download_certificate").click();*/ }
From source file:com.pentaho.ctools.cde.reference.AddinReferenceEdit.java
License:Apache License
/** * * @param value//from ww w . j a v a 2 s . c o m */ private void ChangeFontSize(String value) { this.log.info("ChangeFontSize"); driver.get(PageUrl.ADDIN_REFERENCE_EDIT); //Expand first row - Title this.elemHelper.ClickJS(driver, By.xpath("//table[@id='table-cdfdd-layout-tree']/tbody/tr[5]/td/span")); //Click in HTML to open the Properties Actions acts = new Actions(driver); acts.click(this.elemHelper.FindElement(driver, By.xpath("//table[@id='table-cdfdd-layout-tree']/tbody/tr[6]/td[1]"))); acts.build().perform(); //Click in field 'Font Size' to be editable this.elemHelper.ClickJS(driver, By.xpath("//table[@id='table-cdfdd-layout-properties']/tbody/tr[3]/td[2]")); //Write 34 this.elemHelper.FindElement(driver, By.name("value")).clear(); this.elemHelper.SendKeys(driver, By.name("value"), value); this.elemHelper.FindElement(driver, By.name("value")).submit(); this.bFontChanged = true; //Save the changes this.elemHelper.ClickJS(driver, By.linkText("Save")); //Wait for element present and invisible this.elemHelper.WaitForElementVisibility(driver, By.xpath("//div[@id='notifyBar']")); this.elemHelper.WaitForElementInvisibility(driver, By.xpath("//div[@id='notifyBar']")); }
From source file:com.pentaho.ctools.cde.require.AddinReferenceEdit.java
License:Apache License
/** * * @param value//from w ww. ja v a 2s. c o m */ private void ChangeFontSize(String value) { this.log.info("ChangeFontSize"); driver.get(PageUrl.ADDIN_REFERENCE_REQUIRE_EDIT); //Expand first row - Title this.elemHelper.ClickJS(driver, By.xpath("//table[@id='table-cdfdd-layout-tree']/tbody/tr[5]/td/span")); //Click in HTML to open the Properties Actions acts = new Actions(driver); acts.click(this.elemHelper.FindElement(driver, By.xpath("//table[@id='table-cdfdd-layout-tree']/tbody/tr[6]/td[1]"))); acts.build().perform(); //Click in field 'Font Size' to be editable this.elemHelper.ClickJS(driver, By.xpath("//table[@id='table-cdfdd-layout-properties']/tbody/tr[3]/td[2]")); //Write 34 this.elemHelper.FindElement(driver, By.name("value")).clear(); this.elemHelper.SendKeys(driver, By.name("value"), value); this.elemHelper.FindElement(driver, By.name("value")).submit(); this.bFontChanged = true; //Save the changes this.elemHelper.ClickJS(driver, By.linkText("Save")); //Wait for element present and invisible this.elemHelper.WaitForElementVisibility(driver, By.xpath("//div[@id='notifyBar']")); this.elemHelper.WaitForElementInvisibility(driver, By.xpath("//div[@id='notifyBar']")); }