Example usage for org.openqa.selenium By id

List of usage examples for org.openqa.selenium By id

Introduction

In this page you can find the example usage for org.openqa.selenium By id.

Prototype

public static By id(String id) 

Source Link

Usage

From source file:ca.nrc.cadc.search.integration.SearchResultsPage.java

License:Open Source License

CAOMObservationDetailsPage openObservationDetails(final int rowNumber) throws Exception {
    click(By.id(String.format(OBSERVATION_DETAILS_LINK_LOCATOR, rowNumber)));

    return new CAOMObservationDetailsPage(driver);
}

From source file:ca.nrc.cadc.UserStorageBrowserPage.java

License:Open Source License

public void doLogin(String username, String password) throws Exception {
    sendKeys(loginUsername, username);/*from w  w  w .  j av a  2  s  . co  m*/
    sendKeys(loginPassword, password);
    click(submitLoginButton);
    waitForElementPresent(By.id("logout"));
}

From source file:ca.nrc.cadc.UserStorageBrowserPage.java

License:Open Source License

public void createNewFolder(String foldername) throws Exception {
    newdropdownButton.click();/*from   w ww .  j av  a2  s . c  o  m*/
    newFolder.click();
    WebElement newfolderInput = (new WebDriverWait(driver, 10))
            .until(ExpectedConditions.elementToBeClickable(By.id("fname")));

    sendKeys(newfolderInput, foldername);

    WebElement createFolderButton = find(xpath("//button[contains(text(),\"Create Folder\")]"));
    createFolderButton.click();

    if (isJqiMsgShowing(CONFIRMATION_MSG)) {
        clickButton(OK);
    } else {
        throw new Exception("Could not create folder " + foldername);
    }
}

From source file:ca.nrc.cadc.UserStorageBrowserPage.java

License:Open Source License

public String togglePublicAttributeForRow(int rowNum) throws Exception {
    String currentPermission = "";
    WebElement editIcon = find(xpath("//span[contains(@class, 'glyphicon-edit')]"));
    editIcon.click();//www .  j a  v a  2  s  .c  o m
    WebElement permissionCheckbox = (new WebDriverWait(driver, 10))
            .until(ExpectedConditions.elementToBeClickable(By.id("publicPermission")));

    currentPermission = permissionCheckbox.getAttribute("checked");
    click(permissionCheckbox);
    clickButton(SAVE);

    // confirm folder delete
    if (isJqiMsgShowing(SUCCESSFUL)) {
        clickButton(OK);
    } else {
        throw new Exception("Permissions editing not successful for row : " + rowNum);
    }

    return currentPermission;
}

From source file:ca.pe.cjsigouin.testinator.selenium.WebDriverMain.java

public static void main(String[] args) {

    System.setProperty("webdriver.gecko.driver", "/home/krystofurr/Programs/selenium/geckodriver");
    System.setProperty("webdriver.chrome.driver", "/home/krystofurr/Programs/selenium/chromedriver");

    //     WebDriver driver = new FirefoxDriver();
    WebDriver driver = new ChromeDriver();
    //     WebDriver driver = new InternetExplorerDriver();

    //Puts an Implicit wait, Will wait for 10 seconds before throwing exception
    driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

    //Launch website
    driver.navigate().to(CommonConstants.HOST + CommonConstants.URL_LOGIN);

    driver.findElement(By.id("emailAddress")).sendKeys("cjsigouin@gov.pe.ca");
    driver.findElement(By.id("password")).sendKeys("Test12345!");
    driver.findElement(By.id("loginButton")).click();

    WebDriverWait wait = new WebDriverWait(driver, 5);
    wait.until(/* w  ww . j av a  2  s. co  m*/
            ExpectedConditions.elementToBeClickable(By.xpath(".//*[@id='serviceWellSection']/div[2]/div/a/b")));

    driver.get(CommonConstants.HOST + CommonConstants.URL_RESERVE_NAME_INTRO);
    WebDriverWait wait2 = new WebDriverWait(driver, 5);

    wait2.until(ExpectedConditions.elementToBeClickable(By.xpath(ReserveNameElement.INTRO_BUTTON_CANCEL)));
    driver.findElement(By.xpath(ReserveNameElement.INTRO_RADIO_RESERVE_NAME)).click();
    //     driver.findElement(By.xpath(ReserveNameElement.INTRO_SELECT_COMPANY_TYPE)).sendKeys("Incorp");

    Select dropdown = new Select(driver.findElement(By.xpath(ReserveNameElement.INTRO_SELECT_COMPANY_TYPE)));
    dropdown.selectByVisibleText("Incorporated");
    driver.findElement(By.xpath(ReserveNameElement.INTRO_BUTTON_NEXT)).click();

    //     WebDriver driver = new FirefoxDriver();
    //     LoginTester login = new LoginTester(driver);
    //     IncorporatedTester tester = new IncorporatedTester(driver);
    //
    //     login.start();

    //     //Maximize the browser
    //     driver.manage().window().maximize();
    //     tester.start();
    //     tester.stop();

    //     // Click on Math Calculators
    //     driver.findElement(By.xpath(".//*[@id='hcalc']/table/tbody/tr/td[2]/div[3]/a")).click();
    //     
    //     // Click on Percent Calculators
    //     driver.findElement(By.xpath(".//*[@id='content']/ul[1]/li[3]/a")).click();
    //     
    //     // Enter value 10 in the first number of the percent Calculator
    //     driver.findElement(By.id("cpar1")).sendKeys(data.getNumberText(2));
    //     
    //     // Enter value 50 in the second number of the percent Calculator
    //     driver.findElement(By.id("cpar2")).sendKeys(data.getNumberText(2));
    //     
    //     // Click Calculate Button
    //     driver.findElement(By.xpath(".//*[@id='content']/table[1]/tbody/tr[2]/td/input[2]")).click();
    //   
    //     
    //     // Get the Result Text based on its xpath
    //     String result = driver.findElement(By.xpath(".//*[@id='content']/p[2]/font/b")).getText();
    //   
    //     
    //     // Print a Log In message to the screen
    //     System.out.println(" The Result is " + result);

    //Close the Browser.
    driver.close();
}

From source file:cc.kune.selenium.KuneSeleniumDefaults.java

License:GNU Affero Public License

/**
 * Show title slide.//from  w  ww . j a  v a 2  s.  c om
 * 
 * @param title
 *          the title
 * @param description
 *          the description
 * @param token
 *          the token
 */
public void showTitleSlide(final String title, final String description, final String token) {
    gotoToken(TokenUtils.subtitle(title, description, token));
    sleep(4000);
    if (subtitlePopup == null) {
        subtitlePopup = webdriver
                .findElement(By.id(SeleniumConstants.GWTDEV + SubtitlesWidget.SUBTITLE_MANAGER_ID));
    }
    subtitlePopup.click();
    // SeleniumUtils.moveMouseToAndClick(webdriver, subtitlePopup, 100, 100);
}

From source file:cc.kune.selenium.PageObject.java

License:GNU Affero Public License

/**
 * Gets the by id./*from  w ww . j av a  2s  .com*/
 * 
 * @param id
 *          the id
 * @return the by id
 */
public WebElement getById(final String id) {
    return webdriver.findElement(By.id(UIObject.DEBUG_ID_PREFIX + id));
}

From source file:cc.kune.selenium.PageObject.java

License:GNU Affero Public License

/**
 * Checks if is element present./*from w  w  w. j  ava2s.co m*/
 * 
 * @param id
 *          the id
 * @return true, if is element present
 */
public boolean isElementPresent(final String id) {
    final Wait<WebDriver> wait = new WebDriverWait(webdriver, 5);
    final WebElement element = wait.until(visibilityOfElementLocated(By.id(id)));
    return element != null;
}

From source file:cc.kune.selenium.PageObject.java

License:GNU Affero Public License

/**
 * Checks if is present./* w  w  w .  j av a  2 s .  c om*/
 * 
 * @param element
 *          the element
 * @return true, if is present
 */
public boolean isPresent(final WebElement element) {
    // FIXME: find a better way to do this
    try {
        getWebDriver().findElement(By.id(element.getAttribute("id")));
        return true;
    } catch (final NoSuchElementException e) {
        return false;
    }
}

From source file:CertMaven.pageObjects.DriverPage.java

public DriverReportsPage DriverPageClickContinueButton() throws Throwable

{
    waitWhileAjaxCompletesUptoAMinute();
    //waitTillVisible("policyDataGatherForm:next");
    driver.findElement(By.id("policyDataGatherForm:next")).click();
    return new DriverReportsPage(driver);
}