How to verify disabled text?

2,435 views
Skip to first unread message

Jon

unread,
Aug 17, 2010, 6:29:08 AM8/17/10
to Selenium Users
All,

I am trying to test that when a tickbox is selected javascript
populates a disabled textbox.

Selenium doesn't seem to be able to read the data in the disabled
textbox.

Is there a way in which I can make Selenium read this data?

Ta

Jon

Bindu Laxminarayan

unread,
Aug 18, 2010, 7:29:10 PM8/18/10
to Selenium Users
Jon,

You can get the value with the storeAttribute Selenium IDE function.
GetAttribute for Selenium RC function. See,
http://www.hexbytes.com/category/automation/selenium/selenium-ide/storeattribute/
for the example.

Thanks
Bindu Laxminarayan

Yuping Zhong

unread,
Aug 19, 2010, 1:09:21 AM8/19/10
to seleniu...@googlegroups.com
Anyone knows how to verify the disabled button or disabled link???

Thanks!

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/selenium-users?hl=en.


Niraj Kumar

unread,
Aug 19, 2010, 3:21:03 AM8/19/10
to seleniu...@googlegroups.com
Yes we can verify weather a button is disabled with this command

<tr>
    <td>verifyAttribute</td>
    <td>//input[@name='apply']@disabled</td>
    <td>disabled</td>
</tr>

or

<tr>
    <td>verifyAttribute</td>
    <td>//input[@name='apply']@disabled</td>
    <td>true</td>
</tr>

<input type="submit" disabled="disabled" value="Apply" name="apply" class="textbutton">



 But if this button is enabled you wont get the attribute disabled

<input type="submit" value="Apply" name="apply" class="textbutton">
--
Thanks & Regard,
Niraj Kumar

Yuping Zhong

unread,
Aug 19, 2010, 4:09:41 AM8/19/10
to seleniu...@googlegroups.com
Hi Niraj,

Thanks for your reply.

But there is another way to disabled the button/link is used the Javascript.So the cannot find the disabled attribute in input.

Do you know how to verify this?

Thanks!

Fishbowler

unread,
Aug 19, 2010, 8:20:45 AM8/19/10
to Selenium Users
Bindu,

I had the same problem as Jon, but couldn't use the solution you
provided, and I think it's for the same reason as Jon.
I'm not an XPath expert by any stretch, but it seems that Selenium's
XPath searches, or perhaps just Selenium's *Attribute functions (e.g.
storeAttribute), are treating the page "as delivered".

In this case, the DOM is altered by JavaScript after the page is
rendered.

I couldn't quite work out how to get the DOM locator to work, and
wasn't confident it would work any better than the XPath locator.
We ended up solving this with a JavaScript solution.

Here's how we did it. The checkbox chkPopulate fills text input
txtValue when checked, but is unchecked when the page loads.

<tr>
<td>assertEval</td>
<td>window.document.getElementById("txtValue").value</td>
<td></td>
</tr>

<tr>
<td>click</td>
<td>chkPopulate</td>
<td></td>
</tr>

<tr>
<td>assertEval</td>
<td>window.document.getElementById("txtValue").value</td>
<td>*My Test Data*</td>
</tr>


Hope this helps Jon, and anyone else who stumbles upon it.


Fishbowler


On Aug 19, 12:29 am, Bindu Laxminarayan <bindu.laxminara...@gmail.com>
wrote:
> Jon,
>
> You can get the value with the storeAttribute Selenium IDE function.
> GetAttribute for Selenium RC function. See,http://www.hexbytes.com/category/automation/selenium/selenium-ide/sto...
> for the example.
>
> Thanks
> Bindu Laxminarayan
>
> On Aug 17, 4:29 am, Jon <jonathanro...@gmail.com> wrote:
>
>
>
> > All,
>
> > I am trying to test that when a tickbox is selected javascript
> > populates adisabledtextbox.
>
> > Selenium doesn't seem to be able to read the data in thedisabled
> > textbox.
>
> > Is there a way in which I can make Selenium read this data?
>
> > Ta
>
> > Jon- Hide quotedtext-
>
> - Show quotedtext-

Abhi

unread,
Aug 19, 2010, 2:46:21 AM8/19/10
to Selenium Users
Hi Jon,
As per my understanding you want to get data from disabled text box.
following code should worked for that.

selenium.getValue("xpath=id('textboxID')");


Thanks,
Abhijit

Abhi

unread,
Aug 19, 2010, 2:56:48 AM8/19/10
to Selenium Users
Hi,
You can use method selenium.isEditable(elemnetLocator) to check
whether button is disabled.
If result of this method is false then element is disabled.

Although you cannot use this method for links. I tried to use it for
links but selenium gave error as element is not input element .

Thanks,
Abhijit

On Aug 19, 10:09 am, Yuping Zhong <littlezhong...@gmail.com> wrote:
> Anyone knows how to verify the disabled button or disabled link???
>
> Thanks!
>
> On Thu, Aug 19, 2010 at 7:29 AM, Bindu Laxminarayan <
>
>
>
> bindu.laxminara...@gmail.com> wrote:
> > Jon,
>
> > You can get the value with the storeAttribute Selenium IDE function.
> > GetAttribute for Selenium RC function. See,
>
> >http://www.hexbytes.com/category/automation/selenium/selenium-ide/sto...
> > for the example.
>
> > Thanks
> > Bindu Laxminarayan
>
> > On Aug 17, 4:29 am, Jon <jonathanro...@gmail.com> wrote:
> > > All,
>
> > > I am trying to test that when a tickbox is selected javascript
> > > populates a disabled textbox.
>
> > > Selenium doesn't seem to be able to read the data in the disabled
> > > textbox.
>
> > > Is there a way in which I can make Selenium read this data?
>
> > > Ta
>
> > > Jon
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Selenium Users" group.
> > To post to this group, send email to seleniu...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > selenium-user...@googlegroups.com<selenium-users%2Bunsubscribe@go oglegroups.com>
> > .

Yuping Zhong

unread,
Aug 19, 2010, 11:29:05 PM8/19/10
to seleniu...@googlegroups.com
Thanks Abhi,your method is really good!

To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages