List of usage examples for org.openqa.selenium By cssSelector
public static By cssSelector(String cssSelector)
From source file:com.daarons.transfer.UploadTask.java
License:Apache License
private void inputFilePath(String filePath) { WebElement fileInput = longWait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector( "body > div > div > div.transfer.transfer--half-panel > div > div.scrollable.transfer__contents > div.scrollable__content > div.uploader__files > form > input[type=\"file\"]"))); fileInput.sendKeys(filePath);/*from www . j ava 2 s. c o m*/ }
From source file:com.daarons.transfer.UploadTask.java
License:Apache License
private boolean isUploadTimeAvailable(WebDriverWait wait) { //checks to see if the time until the upload is finished is on the screen boolean isUploadTimeAvailable; try {//from w w w . j a v a 2s . c om isUploadTimeAvailable = wait.until((ExpectedCondition<Boolean>) (WebDriver driver2) -> driver2 .findElement(By.cssSelector( "body > div > div > div.transfer.transfer--half-panel > div > div.transfer__contents > p:nth-child(4)")) .getText().length() != 0); } catch (org.openqa.selenium.TimeoutException ex) { log.error("Time until upload is finished could not be found", ex); isUploadTimeAvailable = false; //remove and make false at start of method } return isUploadTimeAvailable; }
From source file:com.daarons.transfer.UploadTask.java
License:Apache License
private boolean isLinkAvailable(WebDriverWait wait) { //checks to see if the download link is ready boolean isLinkAvailable; try {/*w ww . j a v a 2 s.c om*/ isLinkAvailable = wait.until(ExpectedConditions.textToBePresentInElementLocated(By.cssSelector( "body > div > div > div.transfer.transfer--half-panel > div > div.transfer__contents > p"), "Copy your download link:")); } catch (org.openqa.selenium.TimeoutException ex) { log.error("The download link for the file could not be found", ex); isLinkAvailable = false; } return isLinkAvailable; }
From source file:com.daarons.transfer.UploadTask.java
License:Apache License
private int getUploadTime(WebDriverWait wait) { WebElement timeLeftElement = wait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector( "body > div > div > div.transfer.transfer--half-panel > div > div.transfer__contents > p:nth-child(4)"))); // then get the text in the time_left element & calculate the time to upload String timeLeft = timeLeftElement.getText(); int until;// w ww . j av a 2 s.co m if (timeLeft.matches("(.*)hour(.*)") || timeLeft.matches("(.*)hours(.*)")) { //hours timeLeft = timeLeft.replaceAll("\\D+", ""); if (timeLeft.isEmpty()) { until = 60; } else { until = new Integer(timeLeft) * 60; } } else if (timeLeft.matches("(.*)under a minute(.*)")) { // < 1min until = 1; } else { //everything else but mostly 'minutes' timeLeft = timeLeft.replaceAll("\\D+", ""); try { until = new Integer(timeLeft); } catch (NumberFormatException ex) { log.error("The upload time did not contains integers", ex); until = 1; } } return until; }
From source file:com.daarons.transfer.UploadTask.java
License:Apache License
private void logOut() { WebElement accountLink = longWait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector( "body > div > div > nav > ul > li.nav__item.nav_item--expanded.nav__item--active > ul > li:nth-child(4) > a"))); accountLink.click();/*from w w w. j a v a2 s .c o m*/ WebElement signOutButton = longWait .until(ExpectedConditions.presenceOfElementLocated(By.className("account__signout"))); signOutButton.click(); }
From source file:com.day.cq.social.comments.CloudServiceMTIT.java
@Test public void testConfigureTIFOnPublish() throws InterruptedException { browseTo(getURL(cloudServiceMTPage), true); WebElement tranIntegration = driver.findElement(By.cssSelector("div.product.machine-translation a")); tranIntegration.click();//from w w w. ja v a2s .co m assertTrue("Unable to find configuration button", isElementPresent(By.cssSelector("#machine-translation-more"))); WebElement defaultConfig = driver .findElement(By.linkText("Default configuration (Translation Integration configuration)")); defaultConfig.click(); assertTrue("Unable to find go to translation integration button", isElementPresent(By.linkText("Go to Translation Integration Framework"))); assertTrue("Unable to find edit button", isElementPresent(By.id("cq-gen13"))); WebElement edit = driver.findElement(By.id("cq-gen14")); assertEquals("Edit", edit.getText()); edit.click(); assertTrue("Unable to find edit component", isElementPresent(By.id("cq-gen40"))); assertEquals("Edit Component", driver.findElement(By.id("cq-gen40")).getText()); assertEquals("Machine Translation Configuration", driver.findElement(By.id("ext-comp-1010")).getText()); assertEquals("Go to Translation Integration Framework", driver.findElement(By.cssSelector("#ext-comp-1014 a")).getText()); assertTrue("Unable to find category", isElementPresent(By.id("ext-comp-1024"))); }
From source file:com.day.cq.social.comments.CloudServiceMTIT.java
@Test public void testConfigureMSConnectorOnPublish() throws InterruptedException { browseTo(getURL(cloudServiceMTPage), true); WebElement msConnector = driver.findElement(By.cssSelector("div.product.msft-translation a")); msConnector.click();/*from w w w . jav a 2 s. co m*/ assertTrue("Unable to find configuration button", isElementPresent(By.cssSelector("#msft-translation-more"))); assertTrue("Unable to find default configuration", isElementPresent( By.linkText("Microsoft Translator Default Configuration (Microsoft Translation Configuration)"))); assertTrue("Unable to find trail configuration", isElementPresent( By.linkText("Microsoft Translator Trial License (Microsoft Translation Configuration)"))); WebElement defaultConfig = driver.findElement( By.linkText("Microsoft Translator Default Configuration (Microsoft Translation Configuration)")); defaultConfig.click(); WebElement edit = driver.findElement(By.id("cq-gen14")); edit.click(); WebElement label = driver.findElement(By.cssSelector("#x-form-el-ext-comp-1021 input")); WebElement attribution = driver.findElement(By.cssSelector("#x-form-el-ext-comp-1022 input")); WebElement workspaceID = driver.findElement(By.cssSelector("#x-form-el-ext-comp-1023 input")); WebElement clientID = driver.findElement(By.cssSelector("#x-form-el-ext-comp-1024 input")); WebElement clientSecret = driver.findElement(By.cssSelector("#x-form-el-ext-comp-1025 input")); label.clear(); label.sendKeys("test"); attribution.clear(); attribution.sendKeys("test"); workspaceID.clear(); workspaceID.sendKeys("test"); clientID.clear(); clientID.sendKeys("AdobeAEMTrial"); clientSecret.clear(); clientSecret.sendKeys("AEMTrialAccount9468uTp"); WebElement verifyButton = driver.findElement(By.id("cq-gen65")); verifyButton.click(); WebElement okButton = driver.findElement(By.id("cq-gen90")); okButton.click(); okButton = driver.findElement(By.id("cq-gen44")); okButton.click(); Thread.sleep(2000); List<WebElement> property = driver.findElements(By.cssSelector("#cq-gen8 li")); Iterator it = property.iterator(); it.next(); assertEquals("Translation Label: test", ((WebElement) it.next()).getText()); }
From source file:com.dhenton9000.selenium.generic.GenericAutomationRepository.java
/** * generate the By selector/*from ww w . j a v a 2 s.co m*/ * * @param selectorChoice the desired selector, eg by css Selector * @param selectorValue the string to search for * @return the By element */ public static By generateSelectorBy(SELECTOR_CHOICE selectorChoice, String selectorValue) { By selectorBy = null; switch (selectorChoice) { case id: selectorBy = By.id(selectorValue); break; case name: selectorBy = By.name(selectorValue); break; case className: selectorBy = By.className(selectorValue); break; case linkText: selectorBy = By.linkText(selectorValue); break; case xpath: selectorBy = By.xpath(selectorValue); break; case tagName: selectorBy = By.tagName(selectorValue); break; case cssSelector: selectorBy = By.cssSelector(selectorValue); break; case partialLinkText: selectorBy = By.partialLinkText(selectorValue); break; case wicketPathMatch: selectorBy = WicketBy.wicketPathMatch(selectorValue); break; case wicketPathContains: selectorBy = WicketBy.wicketPathContains(selectorValue); break; default: throw new AssertionError("unable to match selector " + selectorChoice.name()); } return selectorBy; }
From source file:com.dukescript.api.selenium.ExternalWebViewTest.java
License:Open Source License
@Test public void withModelAndExistingWebView() throws InterruptedException { WebElement element = driver.findElement(By.id("target")); Assert.assertEquals("Hello", element.getText()); WebElement button = driver.findElement(By.id("button")); button.click();/*from w w w. ja v a 2 s.com*/ Assert.assertEquals("World", element.getText()); WebElement input = driver.findElement(By.id("input")); input.clear(); input.sendKeys("DukeScript"); button.click(); Assert.assertEquals("DukeScript", element.getText()); WebElement findElement = driver.findElement(By.cssSelector(".bla")); Assert.assertNotNull(findElement); Assert.assertEquals("DukeScript", findElement.getText()); List<WebElement> findElements = driver.findElements(By.cssSelector(".bla")); Assert.assertEquals(1, findElements.size()); }
From source file:com.dukescript.api.selenium.FindsByTest.java
License:Open Source License
@Test public void withModel() { // please note that this method is not executed in BrwsrCtx // to allow seeing updates in the Browser while debugging a test WebElement element = driver.findElement(By.id("target")); Assert.assertEquals("Hello", element.getText()); WebElement button = driver.findElement(By.id("button")); button.click();//from ww w . j a va 2s . c o m Assert.assertEquals("World", element.getText()); WebElement input = driver.findElement(By.id("input")); input.clear(); input.sendKeys("DukeScript"); button.click(); Assert.assertEquals("DukeScript", element.getText()); WebElement findElement = driver.findElement(By.cssSelector(".bla")); Assert.assertNotNull(findElement); Assert.assertEquals("DukeScript", findElement.getText()); }