List of usage examples for org.openqa.selenium WebElement click
void click();
From source file:com.citrix.g2w.webdriver.pages.managewebinar.ManageRegistrationSettingsPage.java
License:Open Source License
/** * select mandatory check box fields.//from ww w . j a va 2s.c o m * * @param question * (id of short and multiple question) * @param required * (flag to set required and not required fields for custom * registration questions) */ public void setMandatoryCheckBoxField(final String question, final boolean required) { String questionId = this.driver .findElement(By.xpath("//a[text()='" + question + "']/../..//input[@type='checkbox']")) .getAttribute("id"); JavascriptExecutor js = (JavascriptExecutor) this.driver; StringBuilder script = new StringBuilder(); script.append("var element = document.getElementById('" + questionId + "');"); script.append("element.checked='" + required + "';"); WebElement checkBox = this.driver.findElement(By.id(questionId)); if (this.driver instanceof HtmlUnitDriver) { if (required) { js.executeScript(script.toString()); checkBox.click(); } } else { if (required) { this.setCheckBox(this.driver.findElement(By.id(questionId)), required); } } }
From source file:com.citrix.g2w.webdriver.pages.recordings.MyRecordingsPage.java
License:Open Source License
/** * Navigate to the recordingViews page for a given recording * @param recordingId Recording Id// ww w . j a va 2 s . c o m * @return Recording Views Page */ public RecordingViewsPage gotoRecordingViewPage(String recordingId) { WebElement recordingViewsLink = this.driver .findElement(By.xpath("//ul[@class='table-data-row']/li/a[contains(@href,'" + recordingId + "')]")); recordingViewsLink.click(); return new RecordingViewsPage(this.driver); }
From source file:com.citrix.g2w.webdriver.pages.registration.RegistrationPage.java
License:Open Source License
public void clickWebinarsSizeLink() { WebElement recurringWebinarsSizeLink = findClickableElement(By.xpath("//a[@class='recurring-sessions']")); recurringWebinarsSizeLink.click(); this.logger.logWithScreenShot("Clicked the link to expand webinar timings.", this.driver); }
From source file:com.citrix.g2w.webdriver.pages.reports.GenerateReportsPage.java
License:Open Source License
/** * Method to navigate to Report Page./*from ww w . ja v a2 s . com*/ * */ public void generateReport(String reportType, String dateRange) { String webinarNameXpath = "//input[@class='choose-report']"; int retryAttempts = 3; switch (ReportType.valueOf(reportType)) { case Registration: this.reportType_REGISTRATION.click(); case Attendee: this.reportType_ATTENDEE.click(); case Performance: this.reportType_PERFORMANCE.click(); case Recording: this.reportType_RECORDING.click(); case Survey: this.reportType_SURVEY.click(); } this.dateRange_trig.click(); WebElement chooseDateRange = driver .findElement(By.xpath("//div[@id='dateRange__menu']/ul/li[contains(@title, dateRange)]")); chooseDateRange.click(); while (retryAttempts >= 0) { try { if (this.findVisibleElement(By.xpath(webinarNameXpath)) != null) { break; } } catch (Exception e) { try { Thread.sleep(1000); } catch (InterruptedException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } retryAttempts--; } this.showWebinarsButton.click(); } this.logger.logWithScreenShot("After navigating to Survey Report Page", this.driver); }
From source file:com.citrix.g2w.webdriver.tests.BaseWebDriverTest.java
License:Open Source License
/** * This is used to cleanup a single recording for a user. The user is expected to be in a logged out state. *///from w w w . j a v a 2 s . c om public void cleanup() { MyWebinarsPage myWebinarPage = loginG2W(getEmail(), getPassword()); myWebinarPage.gotoMyRecordingsPage(); List<WebElement> removeLinks = this.webDriver .findElements(By.xpath("//a[contains(@href,'#removeRecording')]")); while (removeLinks.size() != 0) { removeLinks.get(0).click(); // Not checking for success or failure WebElement confirmButton = this.webDriver.findElement(By.xpath("//a[@id='removeButton']")); confirmButton.click(); removeLinks = this.webDriver.findElements(By.xpath("//a[contains(@href,'#removeRecording')]")); } logger.logWithScreenShot("Cleanup - Deleted recording", this.webDriver); }
From source file:com.coderoad.automation.common.util.old.BasePage.java
License:Open Source License
/** * this method selects the options from the combobox. * //from w w w . j a va 2 s.co m * @param dropDown the drop down * @param option the option */ protected void selectOptionIn(WebElement dropDown, String option) { String triggerId = dropDown.getAttribute("id"); dropDown.findElement(By.id(triggerId)).click(); List<WebElement> options = getDriver().findElements(By.xpath("//li[@role='option']")); for (WebElement opt : options) { if (opt.getText().equals(option)) { opt.click(); break; } } }
From source file:com.coderoad.automation.common.util.old.BasePage.java
License:Open Source License
/** * select the model from the list of vehicle models. * //from w ww . j a v a2 s . com * @param models the models * @param modelCode the model code * @throws InterruptedException the interrupted exception */ public void selectVehicleModel(List<WebElement> models, String modelCode) throws InterruptedException { waitForVisibility(models.get(0)); for (WebElement model : models) { if (model.getText().equals(modelCode)) { model.click(); break; } } Thread.sleep(1000); }
From source file:com.coderoad.automation.common.util.PageUtil.java
License:Open Source License
/** * Method to set date in a date picker//from w w w. ja va2 s . c om * @author Ruth Chirinos * @param driver the WebDriver * @param xpathDatePicker the xpath of the datePicker * @param vehicleSelectionPage * year - the year minus 1900. * month - the month between 0-11. * date - the day of the month between 1-31. * @throws InterruptedException * @throws ParseException */ public static boolean setDateInDatePicker(WebDriver driver, String xpathDatePicker, Date dateRequested) throws InterruptedException, ParseException { Calendar dateRequestedCalendar = DateUtil.getCalendarForDate(dateRequested); LogUtil.log("Date for changing is > " + DateUtil.format(dateRequestedCalendar, DateUtil.DATE_MONTH_ABBREVIATION), LogLevel.LOW); boolean processOk = false; String dateSelectedString = ""; Date dateSelected = null; SimpleDateFormat simpleFormat = new SimpleDateFormat(DateUtil.DATE_MONTH_YEAR_FMT); WebElement datePicker = driver.findElement(By.xpath(xpathDatePicker)); datePicker.click(); WebElement monthYearElement = driver .findElement(By.xpath("//div[@class='x-datepicker-month']/div/div/a/span[1]")); WebElement daySelected = driver.findElement(By.xpath("//*[contains(@class, 'x-datepicker-selected')]/a")); dateSelectedString = daySelected.getAttribute("innerHTML") + " " + monthYearElement.getAttribute("innerHTML"); dateSelected = simpleFormat.parse(dateSelectedString); WebElement pickerPrevEl = driver.findElement( By.xpath("//div[@class='x-datepicker-header']/a[contains(@class, 'x-datepicker-prev')]")); WebElement pickerNextEl = driver.findElement( By.xpath("//div[@class='x-datepicker-header']/a[contains(@class, 'x-datepicker-next')]")); //Choosing the year while (dateRequested.getYear() < dateSelected.getYear()) { pickerPrevEl.click(); monthYearElement = driver.findElement(By.xpath("//div[@class='x-datepicker-month']/div/div/a/span[1]")); dateSelectedString = daySelected.getAttribute("innerHTML") + " " + monthYearElement.getAttribute("innerHTML"); dateSelected = simpleFormat.parse(dateSelectedString); } while (dateRequested.getYear() > dateSelected.getYear()) { pickerNextEl.click(); monthYearElement = driver.findElement(By.xpath("//div[@class='x-datepicker-month']/div/div/a/span[1]")); dateSelectedString = daySelected.getAttribute("innerHTML") + " " + monthYearElement.getAttribute("innerHTML"); dateSelected = simpleFormat.parse(dateSelectedString); } //Choosing the months while (dateRequested.getMonth() < dateSelected.getMonth()) { pickerPrevEl.click(); monthYearElement = driver.findElement(By.xpath("//div[@class='x-datepicker-month']/div/div/a/span[1]")); dateSelectedString = daySelected.getAttribute("innerHTML") + " " + monthYearElement.getAttribute("innerHTML"); dateSelected = simpleFormat.parse(dateSelectedString); } while (dateRequested.getMonth() > dateSelected.getMonth()) { pickerNextEl.click(); monthYearElement = driver.findElement(By.xpath("//div[@class='x-datepicker-month']/div/div/a/span[1]")); dateSelectedString = daySelected.getAttribute("innerHTML") + " " + monthYearElement.getAttribute("innerHTML"); dateSelected = simpleFormat.parse(dateSelectedString); } //Choosing the day WebElement dateWidget = driver.findElement(By.className("x-datepicker-inner")); List<WebElement> columns = dateWidget.findElements(By.tagName("td")); int aux = 0; for (WebElement cell : columns) { if (cell.getText().equals(dateRequested.getDate() + "")) { processOk = cell.getAttribute("class").contains("x-datepicker-active"); if (processOk) { cell.findElement(By.tagName("a")).click(); ; LogUtil.log("The date was selected.", LogLevel.LOW); aux = 1; break; } } } if (aux == 0) { LogUtil.log("The date selected is not enabled.", LogLevel.LOW); } return processOk; }
From source file:com.coderoad.automation.rocketTruedx.RocketTruedxNaBasePage.java
License:Open Source License
/** * this method sets the state of the checkbox. * /*from ww w . j a va2s .co m*/ * @param fieldName the field name * @param state the state */ protected void setCheckBoxState(WebElement fieldName, boolean state) { String id = fieldName.getAttribute("id"); String classStr = fieldName.getAttribute("class"); TestLogger.logDebug(id + ":" + classStr); WebElement checkboxElem = getDriver().findElement(By.id(id + "-inputEl")); // rememberMeCb-inputEl if (classStr.contains("x-form-cb-checked")) if (!state) { checkboxElem.click(); } else { TestLogger.logDebug("Check box already Checked"); } else { if (state) { checkboxElem.click(); } else { TestLogger.logDebug("Check box already unchecked"); } } classStr = fieldName.getAttribute("class"); TestLogger.logDebug(id + ":" + classStr + ":" + state); }
From source file:com.coderoad.automation.rocketTruedx.RocketTruedxNaBasePage.java
License:Open Source License
/** * this method selects the options from the combobox. * /*from ww w .ja v a 2 s. co m*/ * @param dropDown the drop down * @param option the option */ protected void selectOptionIn(WebElement dropDown, String option) { String triggerId = dropDown.getAttribute("id"); WebElement arrow = dropDown.findElement(By.id(triggerId)); if (arrow.isDisplayed()) { arrow.click(); } WaitUtil.waitUntil(5); List<WebElement> options = getDriver().findElements(By.xpath("//li[@role='option']")); for (WebElement opt : options) { if (opt.getText().equalsIgnoreCase(option)) { click(opt); WaitUtil.waitUntil(2); break; } } }