1

i m using the rad masked control for phone field.

telerik:RadMaskedTextBox ID="txtPhone1" runat="server" EnableAjaxSkinRendering="False" Mask="(###) ###-####" Skin="Hay" ZeroPadNumericRanges="False" MaxLength="20" TabIndex="30" Width="200px"></telerik:RadMaskedTextBox

when i m trying to add phone using watir, using this code

browser.text_field(:id => 'ctl00_ContentPlaceHolder1_Registration2_txtPhone1_text').set '7893457889'

only last value has been added. kindly help me out. how to fill masked value.

Chuck van der Linden
  • 6,660
  • 2
  • 28
  • 43
  • Please post HTML generated by the code you have provided, or link to a page, if it is public. – Željko Filipin Oct 21 '11 at 08:18
  • Is an example of the control you are trying to use? http://www.telerik.com/help/aspnet/input/maskedtextbox.html Or would this be a better example? http://demos.telerik.com/aspnet-ajax/input/examples/common/validation/defaultcs.aspx_field – Chuck van der Linden Oct 21 '11 at 19:04

2 Answers2

1

Using Watir-webdriver and the example from Teleriks demo site, and IE browser, I was able to set the value with

browser.text_field(:id,"RadMaskedTextBox1_text").set '1234567890'

This seemed to work just as expected, added the formatting, and seemed functional to me.

With Watir I was able to set it via using

browser.text_field(:id, 'RadMaskedTextBox1_text').value='1234567890'

However although the value showed up in the field, it was not formatted and I was never able to get it to actually validate that input. I tried firing various events such as onchange, to get the client side code to process it, but no joy. If I was using this tool I might consider calling the vendor or getting on their site and asking them for assistance at this point. (provided you need to use Watir)

If watir-webdriver is not a viable option for you (I like it for cross browser testing) then perhaps someone else can spend the time to dig a bit deeper. (I'm personally past the point where digging into this control to extend my own knowledge is worth my employers time...)

Possibly there might be some way around this with Rautomation, but I'm new enough with it where I don't immediately see an easy solution there.

Chuck van der Linden
  • 6,660
  • 2
  • 28
  • 43
0

OMG. This is so old. But I am going to add to it. When dealing with masked elements, I am successful using the following sendkeys technique instead of injecting the value into the inner element text. Send Ctrl-A to highlight everything, then start typing, then tab out of control.

e = @browser.text_field(id: OrderEntryPOM.stop_window_start_date)
e.send_keys [:control, 'a'], start_date, :tab
donvnielsen
  • 195
  • 1
  • 9