List of usage examples for org.openqa.selenium WebElement click
void click();
From source file:com.codescaping.automation.sample.pages.JBLMyAccountPage.java
License:Apache License
public void login() { // Load the first page loadMainPage();/* w w w.j ava 2s . c om*/ // Go to My Account page LinkHandler linkHandler = new LinkHandler(driver); try { linkHandler.selectLink(PropertiesRepository.getString("jblmyaccount.mainpage.link.myaccount"), PropertiesRepository.getString("jblmyaccount.mainpage.link.myaccount.waitfor")); } catch (DriverException de) { logger.error("Unable to open My Account page", de); } // Dismiss the Security Check dialog WindowHandler windowHandler = new WindowHandler(driver); WebElement dialog = windowHandler.switchToModalDialog(); dialog.click(); // Enter login details TextHandler textHandler = new TextHandler(driver); try { textHandler.writeText(PropertiesRepository.getString("jblearning.loginpage.textfield.username"), PropertiesRepository.getString("jblearning.loginpage.textfield.value.username")); textHandler.writeText(PropertiesRepository.getString("jblearning.loginpage.textfield.password"), PropertiesRepository.getString("jblearning.loginpage.textfield.value.password")); } catch (DriverException e) { logger.error("Unable to enter username and/or password", e); } //Login try { linkHandler.selectLink(PropertiesRepository.getString("jblearning.loginpage.link.login"), PropertiesRepository.getString("jblearning.loginpage.link.login.waitfor")); } catch (DriverException e) { logger.error("Unable to login", e); } }
From source file:com.cognifide.aet.job.common.modifiers.click.ClickModifier.java
License:Apache License
@Override public CollectorStepResult collect() throws ProcessingException { CollectorStepResult result;//from w w w.ja va2 s .c o m try { SeleniumWaitHelper.waitForElementToBeClickable(webDriver, getLocator(), getTimeoutInSeconds()); WebElement elementToClick = webDriver.findElement(getLocator()); elementToClick.click(); result = CollectorStepResult.newModifierResult(); } catch (TimeoutException e) { final String message = String.format("Element not found before timeout (%s seconds): '%s'", getTimeoutInSeconds(), getLocator().toString()); result = CollectorStepResult.newProcessingErrorResult(message); LOG.info(message); } catch (WebDriverException e) { final String message = String.format("Error while clicking element %s. Error: %s", getLocator().toString(), e.getMessage()); result = CollectorStepResult.newProcessingErrorResult(message); LOG.warn(message, e); } return result; }
From source file:com.cognifide.bdd.demo.tabs.BrowserTabsTest.java
License:Apache License
@Test public void switchBrowserTabs() { webDriver.navigate()//from ww w .j a v a 2 s.com .to(String.format("file://%s", new File("src/test/resources/tabs/tab_0.html").getAbsoluteFile())); WebElement tabLink = webDriver.findElement(By.id("tabLink")); assertTrue("Link1 is not visible", webElementUtils.isDisplayed(tabLink)); tabLink.click(); assertTrue("Incorrect opened tabs count", tabsHelper.isExpectedTabsCountOpened(2)); WebElement tabName = webDriver.findElement(By.id("tabName")); assertTrue("Tab0 is not opened", webElementUtils.isTextPresentInWebElement(tabName, "Tab0", Timeouts.SMALL)); tabsHelper.switchToNextTab(); tabName = webDriver.findElement(By.id("tabName")); assertTrue("Tab1 is not opened", webElementUtils.isTextPresentInWebElement(tabName, "Tab1", Timeouts.SMALL)); tabsHelper.switchToNextTab(); tabName = webDriver.findElement(By.id("tabName")); assertTrue("Tab0 is not opened", webElementUtils.isTextPresentInWebElement(tabName, "Tab0", Timeouts.SMALL)); tabsHelper.switchToPreviousTab(); tabName = webDriver.findElement(By.id("tabName")); assertTrue("Tab1 is not opened", webElementUtils.isTextPresentInWebElement(tabName, "Tab1", Timeouts.SMALL)); }
From source file:com.cognifide.qa.bb.aem.core.component.dialog.dialogfields.text.FontFormat.java
License:Apache License
private void clickFormatButton(WebElement button) { controlToolbar.selectText(); bobcatWait.until(input -> button.isEnabled()); button.click(); }
From source file:com.cognifide.qa.bb.aem.core.siteadmin.internal.TemplateListImpl.java
License:Apache License
@Override public void selectTemplate(String templateName) { WebElement template = templates.stream() .filter(t -> StringUtils.equals( t.findElement(By.cssSelector("coral-card-content coral-card-title")).getText(), templateName))/*w w w.j a va 2s .c om*/ .findFirst().orElseThrow(() -> new IllegalArgumentException("Template not found: " + templateName)); template.click(); }
From source file:com.cognifide.qa.bb.aem.dialog.classic.field.image.AemImageSetterHelper.java
License:Apache License
private void findImageInContentFinder(final String imageName) { frameSwitcher.switchTo("/"); AemContentFinder aemContentFinder = pageObjectInjector.inject(AemContentFinder.class); LOG.debug("injected content finder: '{}'", aemContentFinder); aemContentFinder.search(imageName);// ww w . jav a2s . com AemContentFinderTab currentTab = aemContentFinder.getCurrentTab(); aemContentFinder.changeToListViewIfNeeded(currentTab); WebElement image = currentTab.getImageWebElementByName(imageName); bobcatWait.withTimeout(Timeouts.MEDIUM).until(ExpectedConditions.elementToBeClickable(image)); image.click(); frameSwitcher.switchBack(); }
From source file:com.cognifide.qa.bb.aem.expectedconditions.ContentFinderActions.java
License:Apache License
/** * Clicks contentFinder tab and checks if it is active. * * @param tab tab to be showed//from www .jav a 2s .c o m * @return condition for tab to be active */ public static ExpectedCondition<Boolean> showContentFinderTab(final WebElement tab) { return new ExpectedCondition<Boolean>() { @Override public Boolean apply(WebDriver driver) { tab.click(); return tab.getAttribute(HtmlTags.Attributes.CLASS).contains(TAB_ACTIVE); } @Override public String toString() { return "Tab is not ready"; } }; }
From source file:com.cognifide.qa.bb.aem.expectedconditions.ContentFinderActions.java
License:Apache License
/** * Clicks contentFinder view and checks is it the active one now. * * @param view view to be showed//from ww w . j a va2s. c o m * @return condition for the view to be active */ public static ExpectedCondition<Boolean> showContentFinderView(final WebElement view) { return new ExpectedCondition<Boolean>() { @Override public Boolean apply(WebDriver driver) { view.click(); return view.findElement(By.xpath(VIEW_WRAPPER_XPATH)).getAttribute(HtmlTags.Attributes.CLASS) .contains(VIEW_ACTIVE); } @Override public String toString() { return String.format(VIEW_IS_NOT_READY); } }; }
From source file:com.cognifide.qa.bb.aem.expectedconditions.ContentFinderActions.java
License:Apache License
/** * Collapses content finder and checks if collapse button hides. * * @return condition for content finder to be collapsed *//*www . j a v a2 s.co m*/ public static ExpectedCondition<Boolean> collapse() { return driver -> { WebElement collapseButton = driver.findElement(By.cssSelector(COLLAPSE_BUTTON_CSS)); collapseButton.click(); return !collapseButton.isDisplayed(); }; }
From source file:com.cognifide.qa.bb.aem.expectedconditions.ContentFinderActions.java
License:Apache License
/** * Expands content finder and checks if expand button hides. * * @return condition for content finder to be expanded *//*from w w w . j ava 2 s . c o m*/ public static ExpectedCondition<Boolean> expand() { return new ExpectedCondition<Boolean>() { @Override public Boolean apply(WebDriver driver) { WebElement expandButton = driver.findElement(By.cssSelector(EXPAND_BUTTON_CSS)); expandButton.click(); return !expandButton.isDisplayed(); } @Override public String toString() { return String.format(VIEW_IS_NOT_READY); } }; }