Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to modify value in ReadOnly TextBox
#1
Not Solved
Hello Experts,

I'm new to QTP and trying to write a Script. This script requires to change value (date) in a Readonly Textbox. I'm not sure how to accomplish this task. I've tried to set it's value with the following code but having error.

For refer here is code
-----------------------------------------------------------
Code:
Set var_date = Browser("MyPurolator Login - Purolator").Page("Purolator E-Ship Online").WebEdit("ServiceDate")
MsgBox var_date.GetTOProperty("default value")
var_date.SetTOProperty "default value", "2010-12-02"
MsgBox var_date.GetTOProperty ("default value")
Browser("MyPurolator Login - Purolator").Page("Purolator E-Ship Online").WebEdit(var_date).Set = "2010-12-09"
-----------------------------------------------------------
And Here is the Error message i'm getting when code reaches the last line.
----------------------------------------------------------
Code:
Run Error Object doesn't support this property or method: 'Browser(...).Page(...).WebEdit(...).Set'
Line (126): "Browser("MyPurolator Login - Purolator").Page("Purolator E-Ship Online").WebEdit(var_date).Set = "2010-12-09"".
----------------------------------------------------------

Some back ground on this issue as some of you might think what's the need to set value in read-only field.

The problem is it's a Calendar Field. A button is associated with it. Itself Calendar text box is read only. You click on this button beside this read-only field which shows Calendar drop down. The you choose a day number say 3, 5, 18 and so on. This Calendar read-only text field always show field by default date 1 week in advance. So user has to choose from Calendar Drop down to select today's date. I try to automate the process to click on this button and then choose the numbers(date). But the problem is these day's are 'Webelement'. Also if I start capturing them then I've to hold all 30 day's Webelements in OB. So I'm trying to come up with some way that I can use NOW() function to get today's date day and plug in this field.

For reference I've also attached a screen shot of this field and Calendar Drop down.

I hope this detail give you and others some idea. Can please someone show me how to do it?

Many thanks in advance.


Attached Files Image(s)
   
Reply
#2
Not Solved
First, the reason you are getting the error is that the line:

Code:
Browser("MyPurolator Login - Purolator").Page("Purolator E-Ship Online").WebEdit(var_date).Set = "2010-12-09"

has "=" after the .Set. It should be:

Code:
Browser("MyPurolator Login - Purolator").Page("Purolator E-Ship Online").WebEdit("ServiceDate").Set "2010-12-09"

However, if the the WebEdit really is read-only, you will still get an error (just one that says that the object is disabled). If you can capture the WebTable or WebElement that represents the calendar picker when it is open, you can click a child of it with descriptive programming. For this example, assume the calendar is a WebTable called "Calendar" and the days are TDs inside the table. If this is the case you will probably have to differentiate between the "disabled" days and the "enabled" days of the month. Almost always the class attribute is different. Assume the TDs that are "enabled" have the class attribute value of "validDays" that will uniquely identify the enabled "1" as opposed to the disabled "1" at the bottom of the calendar. The Date function (as opposed to the Now function) gets today's date without time.

Code:
'Code to click the button or image that opens the calendar e.g.:
'Browser("MyPurolator Login - Purolator").Page("Purolator E-Ship Online").Image("Calendar Button Image").Click

Browser("MyPurolator Login - Purolator").Page("Purolator E-Ship Online").WebTable("Calendar").WebElement("html tag:=TD", "class:=validDays", "innertext:=" & Day(Date)).Click

Again, this code won't actually run in your test, you will have to capture the calendar and figure out what makes the enabled days different from the disabled days. I am just trying to give you an idea on how to tackle the problem.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [UFT] [WPF] Trigger on TextBox robertosalemi 2 2,154 05-26-2016, 07:32 PM
Last Post: robertosalemi
  Verify that a dropdown Element is in Readonly mode with QTP. nilanjans 5 6,557 07-02-2012, 08:36 PM
Last Post: nilanjans
Exclamation Record a textbox Unleash Rajesh 0 1,971 03-17-2012, 11:18 AM
Last Post: Unleash Rajesh
  modify meetings in outlook renee 2 2,942 10-14-2009, 10:26 AM
Last Post: Saket
Question validate textbox nirmal_k1231 0 2,437 05-03-2009, 09:10 PM
Last Post: nirmal_k1231

Forum Jump:


Users browsing this thread: 1 Guest(s)