How to put Sysdate to a cell field

Ranorex Studio, Spy, Recorder, and Driver.
Priyanshu
Posts: 30
Joined: Wed May 22, 2019 5:48 am

How to put Sysdate to a cell field

Post by Priyanshu » Fri Jul 19, 2019 10:08 am

Hi Team,

I am facing issue while providing current system date to a cell field of a table.

path tracked by ranorex of the field
table[@name='sgImplants']/?/?/cell[@name='sgImplants' and @columnindex='2']

trying to provide the date with below code
autopsyRepo.Barhusmeddelande.SgImplants.Element.SetAttributeValue("Text", System.DateTime.Now.ToShortDateString());
But it is not working , Please suggest the solution.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: How to put Sysdate to a cell field

Post by odklizec » Fri Jul 19, 2019 10:21 am

Hi,

Could you please upload a Ranorex snapshot (NOT screenshot) of the element in question? Without seeing, at very least, Ranorex snapshot, it's impossible to tell what's wrong. Also, have you tried KeySequence instead of SetValue action? SetValue action may not invoke assigned mouse/keyboard events of given table/cell, so it should be used with caution.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

Priyanshu
Posts: 30
Joined: Wed May 22, 2019 5:48 am

Re: How to put Sysdate to a cell field

Post by Priyanshu » Fri Jul 19, 2019 1:26 pm

Hi ,

PFA the snapshot. Also tried keysequence but for date value its not working.
You do not have the required permissions to view the files attached to this post.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: How to put Sysdate to a cell field

Post by odklizec » Fri Jul 19, 2019 2:20 pm

Hi,

Thanks for the snapshot.

At first, it seems you are using Ranorex 9.0, which is somewhat buggy. So I would recommend to update it with most recent 9.1.1. I don't think this will fix your problem, but you know, one never knows? ;)

At next, what do you mean that keysequence does not work with date value? So it does work with simple string? And what exactly happens, if you use SetValue?

BTW, have you tried to click in given cell (to set focus), before entering text?

And one more thing. The cell seems to be identified as Header cell! Are you sure it's possible to enter text in such cell? Have you tried to enter the text manually?
HeaderCell.png
You do not have the required permissions to view the files attached to this post.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

Priyanshu
Posts: 30
Joined: Wed May 22, 2019 5:48 am

Re: How to put Sysdate to a cell field

Post by Priyanshu » Mon Jul 22, 2019 6:35 am

Hi,
I am trying to say here is its a cell field , so when I am setAttributeValue after providing click it says cell is readonly , But I am able to put value manually.

Another question how do you set sysdate is any field ? Since this is not text box and its a cell I am facing such issue.

manish
Certified Professional
Certified Professional
Posts: 53
Joined: Fri Aug 10, 2018 12:46 pm

Re: How to put Sysdate to a cell field

Post by manish » Mon Jul 22, 2019 10:14 am

Hi,

Could you please try

Code: Select all

	autopsyRepo.Barhusmeddelande.SgImplants.Element.Text = System.DateTime.Now.ToShortDateString().ToString();

If this does not work, would it be possible for you to upload another screenshot of the application where the date is filled in the cell so that we get a better look at the element.

BR
Manish

Priyanshu
Posts: 30
Joined: Wed May 22, 2019 5:48 am

Re: How to put Sysdate to a cell field

Post by Priyanshu » Mon Jul 22, 2019 1:15 pm

Hi Manish,

I tried your solution but getting below error
'Element' does not contain a definition for 'Text' and no extension method 'Text' accepting a first argument of type 'Element' could be found (are you missing a using directive or an assembly reference?)

Also PFA screenShot of the application
You do not have the required permissions to view the files attached to this post.

manish
Certified Professional
Certified Professional
Posts: 53
Joined: Fri Aug 10, 2018 12:46 pm

Re: How to put Sysdate to a cell field

Post by manish » Tue Jul 23, 2019 8:28 am

Hi,

Please try the below snippet

Code: Select all

autopsyRepo.Barhusmeddelande.SgImplants.Text = System.DateTime.Now.ToShortDateString().ToString()
This should work and set the date in the datum field.

In the previous post, I mean if it would be possible for you to upload another snapshot of the the application with the date field filled with a valid value. Sorry for the confusion.

Priyanshu
Posts: 30
Joined: Wed May 22, 2019 5:48 am

Re: How to put Sysdate to a cell field

Post by Priyanshu » Tue Jul 23, 2019 1:07 pm

Hi Manish,

I tried new solution which gave me below error

Property or indexer 'Cell.Text' cannot be assigned to -- it is read only (CS0200) -

PFA snapshot of cell field with filled value.
You do not have the required permissions to view the files attached to this post.

manish
Certified Professional
Certified Professional
Posts: 53
Joined: Fri Aug 10, 2018 12:46 pm

Re: How to put Sysdate to a cell field

Post by manish » Tue Jul 23, 2019 2:06 pm

HI,

The only fields that I can see that correspond to the date values are Text and Name and there is no field that identifies the cell to be read only.
I have a few questions. Does the cell become active only after you click on it? Is the value filled by you manually or is it filled automatically by pressing some button on your application?

In any case, could you try clicking on the cell first to make it active and then try setting the value for date and see if it works

Code: Select all


	autopsyRepo.Barhusmeddelande.SgImplants.Click(Location.Center);
	autopsyRepo.Barhusmeddelande.SgImplants.Text = System.DateTime.Now.ToShortDateString().ToString();

Manish

Priyanshu
Posts: 30
Joined: Wed May 22, 2019 5:48 am

Re: How to put Sysdate to a cell field

Post by Priyanshu » Wed Jul 24, 2019 6:00 am

Hi Manish,

I tried your solution ,after provide click on the cell , but it did not work
Property or indexer 'Cell.Text' cannot be assigned to -- it is read only (CS0200) -

I manually provided the value in the cell not automatically by application.

Ranorex spy also detects as enabled as true for cell

User avatar
N612
Posts: 135
Joined: Mon Jul 11, 2016 4:01 pm

Re: How to put Sysdate to a cell field

Post by N612 » Fri Jul 26, 2019 8:43 pm

Have you tried a simple key-sequence action (coded version below)?

Code: Select all

autopsyRepo.Barhusmeddelande.SgImplants.PressKeys(System.DateTime.Now.ToShortDateString());

Priyanshu
Posts: 30
Joined: Wed May 22, 2019 5:48 am

Re: How to put Sysdate to a cell field

Post by Priyanshu » Thu Sep 26, 2019 7:03 am

Hi ,
Thanks for your help,
Below cod worked
autopsyRepo.Barhusmeddelande.SgImplants1.PressKeys(System.DateTime.Now.ToShortDateString());