How to clear a date picker using webdriver - webdriver

I want to clear and insert a new value in a date picker.
when I use this code, it's just appending the new date with the existing one by default.
here is my code:
driver.findElement(By.className("subheader")).click();
driver.findElement(By.xpath("html/body/div[3]/div/div/div[2]/div/div/div[2]/div/div[1]/div/input[1]")).clear();
driver.findElement(By.xpath("html/body/div[3]/div/div/div[2]/div/div/div[2]/div/div[1]/div/input[1]")).sendKeys("01/01/2013");
Thank you
I want to clear and then insert new value for date.

Its case sensitive, use
driver.FindElement(By.XPath("html/body/div[3]/div/div/div[2]/div/div/div[2]/div/div[1]/div/input[1]")).Clear();
As you have a very long XPath string create a variable to make it easier to read
var datePicker = driver.FindElement(By.XPath("html/body/div[3]/div/div/div[2]/div/div/div[2]/div/div[1]/div/input[1]"));
datePicker.Clear();
datePicker.SendKeys("01/01/2013");
Hope this solves your problem.

Related

How to stop Time data being appended to Today() (powerapps and excel)

I am trying to use powerapps to create a submission form for users.
The issue is that I have one field for submission date.
All I want is the short date added to the table column when the user clicks submit.
What I get is the shortdate with
YYYY-MM-DDTHH:MM:SS.SSOZ
I have tried:
Text(Today(), "[%-en-US]YYYY-MM-DD")
Text(Today(), DateTimeFormat.ShortDate)
Left(Text(Today(), "[%-en-US]YYYY-MM-DD"),10)
Left(Text(Today(), DateTimeFormat.ShortDate),10)
I have tried setting the excel table field to "Text"
I have tried setting it back to date and using just the short date without conversion.
Is there any end to this madness?
Thanks!
Text(Today(),DateTimeFormat.ShortDate)
This should do the trick;
DateValue(Text(Now()))

How to get the value of `write_date` to a variable

In odoo every model will be having a write_date column which will store the last edited time and date of the record.I want to take the value of that field to a variable/ field. But when I print this , it is printing False . What to do.?
code
variable = self.write_date
Thanks in Advance..
The problem is that you're getting in self a new recordset (odoo.models.NewId object at 0x7fe0c05717d0). Therefore, you're trying to get the write_date of a record which has not been created yet. If the record has never been updated (even not created), it's not going to have a value in write_date.
Remember that write_date stores the latest date in which the record was updated.
So, first, at least, you must create the record, and then, you will be able to apply this: variable = self.write_date.
But take a look at this:
What's happening with these transient models' IDs?
May be you get the write_date without creating the record, give a try to this: variable = self._origin.write_date.
Even though we can see a field named write_date in the table, First of all, what we have to do is that you have to add a field named write_date into your model and then try the same.
write_date = fields.Datetime(string='Write Date') solved my problem.Thanks everyone for helping.

Google App Maker: Add a field with the current date/time

new to app maker (and ready to fall in love)
I want every new row to have a field with the date+time that the row was created at. How can I do that?
If you'd like to base your answer on existing code, please base it on the project-list example
Thanks!
Add a new field to the Data model (e.g. Projects) called, say DateCreated, of type Date.
In the onCreate event of the Data Model ('Projects'), add the line:
record.DateCreated = new Date();
To check your work, add the DateCreated field to the Main page by copying the DueDate field and changing the data binding name to DateCreated.

ASP: Time picker

I was using a time picker which returns the date and time together. This was making for me problems since i am comparing this value with a database column of type time only. Tried another free time picker control but when assigning it to a repeater and when it comes to define the data source of repeater and writting the SQL Query I cant select the time picker control from the drop down list simply because it is not available.
any other time picker controls with a stylish look and effecient?
Regards.
I'm not sure about a control which fits your exact needs but you should be able to convert the .net DateTime to a TimeSpan which you could then compare against the sql Time datatype
DateTime myDateTime = DateTime.Now;
TimeSpan myTimeSpan = new TimeSpan(myDateTime.Hour, myDateTime.Minute, myDateTime.Second, myDateTime.Millisecond);

Asp.Net Sql Auto-Increment for Wall Post

I have a table that contains three columns.
"UserId" type-nvarchar
"PostAuthorId" type-nvarchar
"Post" type-text
This table will contain "wall" posts like in facebook for each user's page. I am going to use a gridview on each user's page to display the posts. The issue is I want to display them with the latest(most current) post being first and the earliest post being last.
I have never used autoincrement before and I am not sure if that is the answer. If it is, I do not know how to use it. I thought about adding a date posted column and then ordering by date.
If I end up using the date column, I could also display the date on the post. Is there a way to convert the date to a readable format?
What is the best way of implementing this type of ordering?
If you use AutoIcrement the first record will start with 1 and each record will increment from there. (default setting)
If you want to sort them by newest first do an ORDER BY ID DESC
I would suggest making a column called wallPostID then setting that to AutoIncrement and also your Primary Key
Date Formating:
If you are displaying this data in a gridView
Go to Edit Columns on your grid view
CLick on the Date field under "Selected Fields" on the bottom left
Under "BoundField properties" on the right Go to Data -> DataFormatString
{0:d} will display as 1/1/2010
This site has more info in string formatting
http://msdn.microsoft.com/en-us/library/fht0f5be.aspx
A datetime column would definitely work for something like this. Assuming you are using MS-SQL, you can also attach a default value to the column using a built-in function like GETDATE(). That way, you only have to input the data that matters and the database will take care of adding the datetime column.
For converting a datetime to a readable format try:
DateTime postDate;
string value = postDate.ToShortDateString();
You should always use an ID field that auto increments. Can also be used as your PK
I would suggest the DateTime field rather than the autoincrement simply because it will not only serve as an effective Sort field, it also preserves information that you may well want to display. If you want the most recent first you'll sort using the Date and a "DESC" modifier:
Select ... Order By [Date] DESC;
When you retrieve the data, you can retrieve it as a DateTime and modify it using C#. You can use "ToShortDateString()" as suggested by mdresser if you just wish to show the date or ToString("...") if you wish to show the time as well. You can also use SQL to convert it into a string before retrieving it:
convert(Varchar(10), #mydatetime, 101)
If you look in MSDN you'll see the various conversion codes (101 is the code used above) that can be used to translate the date in various ways.
UPDATE: You may want to use an autoincrementing field for your application for reasons other than your expressed need to sort wall entries. They are easy to use - just mark the field as an Identity if using SQL Server (other DBs are similar). As far as using them in your program, just think of the field as an Int field that you never have to set.
Now, why would you use a auto-incrementing field? Perhaps the most straightforward reason is so that they give you have an easy way to identify each record. For example, if you permit people to alter or delete their wall entries, the auto-incrementing field is ideal as it gives you a way to easily look up each record (each record will be assigned its own, unique value). You might put an "x" next to the record like StackOverflow does and make it a call back with the UID (auto-increment) value. Note that you should set up your primary key on the UID field if you'll be doing this.
Now, if you find them useful for this reason then you could also sort by the UID. I would still store the date so that you can provide Date and Time feedback as to when an entry was made on the wall but this would no longer be your indexed or sorted field.

Resources