List of usage examples for org.openqa.selenium Keys HOME
Keys HOME
To view the source code for org.openqa.selenium Keys HOME.
Click Source Link
From source file:com.cengage.mindtap.keywords.EvernotePageActions.java
public void editNote() throws AWTException { waitTOSync();//from www. j a v a 2 s .c om waitTOSync(); element("editNote").click(); element("Note_Title").clear(); element("Note_Title").sendKeys("Instructor edited Note"); switchToDefaultContent(); switchToDockIFrame(); switchToFrame("tinymce_editor_area_ifr"); waitTOSync(); WebElement element = driver.findElement(By.id("tinymce")); driver.findElement(By.id("tinymce")).clear(); System.out.println("Editing note description in text input"); //element.sendKeys(Keys.CONTROL + "a"); element.sendKeys(Keys.CONTROL + "b"); element.sendKeys("bold edited"); element.sendKeys(Keys.CONTROL + "b"); element.sendKeys(Keys.ENTER); element.sendKeys(Keys.CONTROL + "i"); element.sendKeys("Italics edited"); element.sendKeys(Keys.ENTER); element.sendKeys(Keys.CONTROL + "i"); element.sendKeys("hyperlinked"); element.sendKeys(Keys.chord(Keys.SHIFT, Keys.HOME)); waitTOSync(); switchToDefaultContent(); switchToDockIFrame(); element("hyperlink").click(); windowHandle = driver.getWindowHandle(); ArrayList<String> tabs2 = new ArrayList<String>(driver.getWindowHandles()); driver.switchTo().window(tabs2.get(1)); element("linkBox").clear(); element("linkBox").sendKeys("http://google.com"); element("LinkInsert").click(); waitTOSync(); driver.switchTo().window(windowHandle); System.out.println("window switched"); switchToDefaultContent(); switchToDockIFrame(); switchToFrame("tinymce_editor_area_ifr"); waitTOSync(); waitTOSync(); waitTOSync(); waitTOSync(); waitTOSync(); waitTOSync(); Assert.assertTrue(element("linkedText").isDisplayed(), "text is not linked"); switchToDefaultContent(); switchToDockIFrame(); element("updateNode_Button").click(); waitTOSync(); String addedNote_Title = driver.findElement(By.xpath(".//ul[@class='plain']/li[1]/a")).getText(); System.out.println(addedNote_Title); Assert.assertTrue(addedNote_Title.contains("edited Note"), "edited note is not displayed"); WebElement bold = driver.findElement(By.xpath("//strong[contains(text(),'bold edited')]")); Assert.assertTrue(bold.isDisplayed(), "bold text does not appear"); WebElement italics = driver.findElement(By.xpath("//em[contains(text(),'Italics edited')]")); Assert.assertTrue(italics.isDisplayed(), "italics text does not appear"); ReportMsg.info("Instructor successfuly edited note"); }
From source file:com.cengage.mindtap.keywords.ReadingActivityPageAction.java
public void addLinkToTextBox() { WebElement element = driver.findElement(By.id("tinymce")); element.sendKeys("linked text"); // waitTOSync(); element.sendKeys(Keys.chord(Keys.SHIFT, Keys.HOME)); waitTOSync();//w w w.j av a2 s .c o m waitTOSync(); switchToDefaultContent(); waitTOSync(); switchToFrame(element("modelOptionsEditFrame1")); waitTOSync(); executeJavascript("document.getElementsByClassName('mceIcon mce_link')[0].click();"); // element("hyperlink").click(); windowHandle = driver.getWindowHandle(); ArrayList<String> tabs2 = new ArrayList<String>(driver.getWindowHandles()); driver.switchTo().window(tabs2.get(1)); element("linkBox").clear(); element("linkBox").sendKeys("http://google.com"); element("linkTitle").clear(); element("linkTitle").sendKeys("Google"); element("linkInsert").click(); waitTOSync(); driver.switchTo().window(windowHandle); System.out.println("window switched"); switchToDefaultContent(); switchToFrame(element("modelOptionsEditFrame1")); switchToFrame("bodyText_ifr"); waitTOSync(); waitTOSync(); Assert.assertTrue(element("linkedText").isDisplayed(), "text is not linked"); }
From source file:com.coderoad.automation.common.util.old.BasePage.java
License:Open Source License
/** * Clear text. * * @param fieldName the field name */ protected void clearText(WebElement fieldName) { fieldName.sendKeys(Keys.SHIFT, Keys.HOME, Keys.BACK_SPACE); }
From source file:com.cognifide.qa.bb.aem.dialog.classic.field.AemRichText.java
License:Apache License
/** * Sets the cursor at the beginning of the current line. * * @return This instance. */ public AemRichText setCursorAtStartingPos() { return type(Keys.HOME); }
From source file:com.cognifide.qa.bb.aem.dialog.classic.field.AemRichText.java
License:Apache License
/** * Selects text in the text area between indices provided as parameters. * * @param startPos the beginning position * @param endPos the ending position/*from w ww . ja v a 2 s .c o m*/ * @return This instance. */ public AemRichText selectText(int startPos, int endPos) { switchToTextArea(); try { actions.sendKeys(Keys.chord(Keys.CONTROL, Keys.HOME)).perform(); for (int i = 0; i < startPos; i++) { actions.sendKeys(Keys.ARROW_RIGHT).perform(); } actions.keyDown(Keys.SHIFT); for (int i = 0; i < endPos - startPos; i++) { actions.sendKeys(Keys.ARROW_RIGHT); } actions.keyUp(Keys.SHIFT).perform(); return this; } finally { frameSwitcher.switchBack(); } }
From source file:com.gargoylesoftware.htmlunit.selenium.TypingTest.java
License:Apache License
/** * A test.//from w w w .jav a2 s . co m */ @Test public void homeAndEndAndPageUpAndPageDownKeys() { final WebDriver driver = getWebDriver("/javascriptPage.html"); final WebElement element = driver.findElement(By.id("keyReporter")); element.sendKeys("abc" + Keys.HOME + "0" + Keys.LEFT + Keys.RIGHT + Keys.PAGE_UP + Keys.PAGE_DOWN + Keys.END + "1" + Keys.HOME + "0" + Keys.PAGE_UP + Keys.END + "111" + Keys.HOME + "00"); assertThat(element.getAttribute("value"), is("0000abc1111")); }
From source file:com.gargoylesoftware.htmlunit.selenium.TypingTest.java
License:Apache License
/** * A test.//from w w w . j ava 2 s. c o m */ @Test public void chordControlHomeShiftEndDelete() { final WebDriver driver = getWebDriver("/javascriptPage.html"); final WebElement result = driver.findElement(By.id("result")); final WebElement element = driver.findElement(By.id("keyReporter")); element.sendKeys("!\"#$%&'()*+,-./0123456789:;<=>?@ ABCDEFG"); element.sendKeys(Keys.HOME); element.sendKeys("" + Keys.SHIFT + Keys.END); assertThat(result.getText(), containsString(" up: 16")); element.sendKeys(Keys.DELETE); assertThat(element.getAttribute("value"), is("")); }
From source file:com.gargoylesoftware.htmlunit.selenium.TypingTest.java
License:Apache License
/** * A test./*from w ww. j a va 2s .c o m*/ */ @Test public void chordReveseShiftHomeSelectionDeletes() { final WebDriver driver = getWebDriver("/javascriptPage.html"); final WebElement result = driver.findElement(By.id("result")); final WebElement element = driver.findElement(By.id("keyReporter")); element.sendKeys("done" + Keys.HOME); assertThat(element.getAttribute("value"), is("done")); element.sendKeys("" + Keys.SHIFT + "ALL " + Keys.HOME); assertThat(element.getAttribute("value"), is("ALL done")); element.sendKeys(Keys.DELETE); assertThat(element.getAttribute("value"), is("done")); element.sendKeys("" + Keys.END + Keys.SHIFT + Keys.HOME); assertThat(element.getAttribute("value"), is("done")); // Note: trailing SHIFT up here assertThat(result.getText().trim(), containsString(" up: 16")); element.sendKeys("" + Keys.DELETE); assertThat(element.getAttribute("value"), is("")); }
From source file:com.hotwire.selenium.desktop.widget.DropDownSelector.java
License:Open Source License
/** * Select item from drop-down by its visible text *//*from w w w . j ava 2s.c o m*/ public void selectByVisibleText(String itemText) { if (StringUtils.isEmpty(itemText)) { return; } if (nativeDropDown.isDisplayed()) { Select startTimeCarSelect = new Select(nativeDropDown); startTimeCarSelect.selectByVisibleText(itemText); return; } By href = By.cssSelector(String.format("a[id^='%s']", nativeDropDown.getAttribute("id"))); new WebDriverWait(webDriver, TIMEOUT).until(ExpectedConditions.presenceOfAllElementsLocatedBy(href)); WebElement customDropDown = webDriver.findElement(href); customDropDown.click(); customDropDown.sendKeys(Keys.HOME); By elementSelector = By.xpath("//div[contains(@class,'ui-selectmenu-open')]//a[text()='" + itemText + "']"); WebElement element = webDriver.findElement(elementSelector); element.click(); }
From source file:com.liferay.faces.test.FACES1427PortletTest.java
License:Open Source License
@Test @RunAsClient//from w w w .j a va 2 s.c om @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")); }