Class DateTimeField

java.lang.Object

public class DateTimeField
extends TextField
Represents an instance of One.form.DateTimeField.
  • Field Details

    • dateTriggerEl

      protected org.openqa.selenium.WebElement dateTriggerEl
    • timeTriggerEl

      protected org.openqa.selenium.WebElement timeTriggerEl
    • datePopupEl

      protected org.openqa.selenium.WebElement datePopupEl
    • relativeDatePopupEl

      protected org.openqa.selenium.WebElement relativeDatePopupEl
    • dateTextInputEl

      protected org.openqa.selenium.WebElement dateTextInputEl
  • Constructor Details

  • Method Details

    • setValueAsToday

      public void setValueAsToday()
    • setValue

      public void setValue​(java.util.Calendar date)
    • setValue

      public void setValue​(java.util.Date date)
    • typeValue

      protected void typeValue​(java.lang.String val)
      DateTimeField trims the typed text to remove any spaces from the value. This causes issues when sendKeys() is a bit slow in typing value and removes spaces in between characters. To avoid this copy the value in clipboard and paste in field at once.
      Overrides:
      typeValue in class TextField
    • getValueAsCalendar

      public java.util.Calendar getValueAsCalendar()
    • openDatePopup

      public void openDatePopup()
    • setRelativeDateByDays

      public void setRelativeDateByDays​(int days)
      Sets value of DateTimeField relative to the current date.
      Parameters:
      days - -Number of days relative to the current date. Example: To set date '12 days ago' use setRelativeDateByDays(-12). To set date 'Today' use setRelativeDateByDays(0). To set date '3 days from now' use setRelativeDateByDays(3)
    • setRelativeDateByWeeks

      public void setRelativeDateByWeeks​(int weeks)
      Sets value of DateTimeField relative to the current date.
      Parameters:
      weeks - -Number of weeks relative to the current date. Example: To set date '2 weeks ago' use setRelativeDateByWeeks(-2). To set date 'This Week' use setRelativeDateByWeeks(0). To set date '3 weeks from now' use setRelativeDateByWeeks(3)
    • setRelativeDateByMonths

      public void setRelativeDateByMonths​(int months)
      Sets value of DateTimeField relative to the current date by months.
      Parameters:
      months - -Number of months relative to the current date. Example: To set date '2 months ago' use setRelativeDateByMonths(-2). To set date 'This Month' use setRelativeDateByMonths(0). To set date '3 months from now' use setRelativeDateByMonths(3)
    • setRelativeDateByYears

      public void setRelativeDateByYears​(int years)
      Sets value of DateTimeField relative to the current date by months.
      Parameters:
      years - -Number of years relative to the current date. Example: To set date '2 years ago' use setRelativeDateByYears(-2). To set date 'This Year' use setRelativeDateByYears(0). To set date '3 years from now' use setRelativeDateByYears(3)
    • openTimePopup

      public void openTimePopup()
      Used to open the Time drop down of DateTimeField. The popup can be closed by calling closeDatePopup() of this class.
    • closeDatePopup

      public void closeDatePopup()
      This method will close the Date Time field pop up if open by clicking on the Text field of DateTimeField
    • getRelativeDatePopupEl

      public org.openqa.selenium.WebElement getRelativeDatePopupEl()
      There are two parts of Date Time field pop up element. One is the Calendar part and another is the Relative Date part. This method will return the WebElement of Relative part of Date Time field pop up. Can be used to access the components of Relative Date.
      Returns:
      WebElement
    • getDatePopupEl

      public org.openqa.selenium.WebElement getDatePopupEl()
      There are two parts of Date Time field pop up element. One is the Calendar part and another is the Relative Dates part. This method will return the WebElement of Calendar part of Date Time field pop up. Can be used to access the components of calender.
      Returns:
      WebElement
    • getRelativeDateSelectionText

      public java.lang.String getRelativeDateSelectionText()
      This method will return the selection text of the relative date by first opening the date time field pop up and then reading the selection text e.g. if "20 days from now" is selected as the relative date. This method will read the selection text and return "Selection: 20 days from now"
      Parameters:
      date - field for which the selection text is being read
      Returns:
      Selection text of the date field or Null if not relative date is selected.