how to check if an object is disabled - xpath question

2,119 views
Skip to first unread message

Shah

unread,
Apr 30, 2009, 7:05:45 AM4/30/09
to selenium-users...@googlegroups.com
Hi Folks,

I have an object when I click it the name changes (from buy to bought) and its greyout (disabled).

I need to check if it has been greyout - here is the html:

before disabled:

<input type="button" itemid="2:11775969$000011775969001" class="buyButton" title="Buy this item" id="ctl00_mainContent_productDetailContent_artistSinglesTab_albumProductDetails_musicBuy_buyButton_buyButtonControl" onclick="if (!window.buy) return false; buy.Updating(this);basket.AddItem('2:11775969','000011775969001');buy.CloseAllBuyPopups();return false;__doPostBack('ctl00$mainContent$productDetailContent$artistSinglesTab$albumProductDetails$musicBuy$buyButton$buyButtonControl','')" value="" name="ctl00$mainContent$productDetailContent$artistSinglesTab$albumProductDetails$musicBuy$buyButton$buyButtonControl"/>

After disabled:

<input type="button" itemid="2:11775969$000011775969001" class="buyButton *buyDisabled*" title="Buy this item" id="ctl00_mainContent_productDetailContent_artistSinglesTab_albumProductDetails_musicBuy_buyButton_buyButtonControl" onclick="if (!window.buy) return false; buy.Updating(this);basket.AddItem('2:11775969','000011775969001');buy.CloseAllBuyPopups();return false;__doPostBack('ctl00$mainContent$productDetailContent$artistSinglesTab$albumProductDetails$musicBuy$buyButton$buyButtonControl','')" value="" name="ctl00$mainContent$productDetailContent$artistSinglesTab$albumProductDetails$musicBuy$buyButton$buyButtonControl" *disabled*=""/>

Any suggestion what I can use for the xpath? I tried //input[@name="ctl00$mainContent$productDetailContent$artistSinglesTab$albumProductDetails$musicBuy$buyButton$buyButtonControl" and @class="buyButton buyDisabled" but it does not find the disabled (i.e bought) button just the previous buy button. Any suggestions?

Also is it possible to get the name of the button (i.e buy/bought)?

Thanks for any help.

Tarun

unread,
Apr 30, 2009, 9:01:48 AM4/30/09
to selenium-users...@googlegroups.com
Does it reload the page before you get button disabled. If so then after waitForPageLoad you can use [isEditable |http://release.seleniumhq.org/selenium-remote-control/0.9.2/doc/java/com/thoughtworks/selenium/DefaultSelenium.html#isEditable(java.lang.String)]method to find status of button.

HTH

Shah

unread,
Apr 30, 2009, 9:55:16 AM4/30/09
to selenium-users...@googlegroups.com
IsEditable passes either way.

Anyway suggestions on the the xpath route or if i can even read the text on the button?

Cheers

Tarun

unread,
Apr 30, 2009, 10:03:34 AM4/30/09
to selenium-users...@googlegroups.com
I guess you can read label of button using DOM. As you might be aware of js execution from selenium. This should get you going.

Shah

unread,
Apr 30, 2009, 10:10:31 AM4/30/09
to selenium-users...@googlegroups.com
- I have solved it by addiing&nbsp; @disabled="" into my xpath.

Thanks for your help

Reply all
Reply to author
Forward
0 new messages