0

Checkbox is present inside label with link of terms of use

<label class="field-item-header" for="fragment-1996782958_acceptAgreement">
I agree to the 
<a target="_blank" href="example.com/terms-of-use">Terms of Use.</a>
</label>

previously i was able to click on checkbox but now its clicking on link of terms of use

I have used following xpath to locate checkbox

I_AGREE_CHECKBOX = By.xpath("//div[@class='account-information']/fieldset[2]/ul/li[2]/span[1]/label");

and

I_AGREE_CHECKBOX = By.xpath("//*[contains(text(), 'I agree to the')]");

Please give me some idea so that i can click on checkbox only not on Terms of use Thanks in advance

stest
  • 21
  • 1
  • 2

1 Answers1

0

Try using the following expression:

//*[text()[contains(.,'I agree to the'))]]
aberna
  • 5,594
  • 2
  • 28
  • 33
  • I have used xpath given by you //*[text()[contains(.,'I agree to the')]] still it clicks on link Terms of Use link – stest Feb 23 '15 at 10:33
  • I cant share it its confidential – stest Feb 23 '15 at 11:44
  • to have access to the content of the for attribute which I suppose is used to activate the checkbox, use //*[text()[contains(.,'I agree to the')]]/@for – aberna Feb 23 '15 at 12:09
  • By using `//*[text()[contains(.,'I agree to the')]]/@for` TimeoutException thrown – stest Feb 23 '15 at 12:22
  • without access to the code I built a simulation environment here: http://codebeautify.org/Xpath-Tester and the expression is correct. Any more info about your settings ? The issue could be related to Selenium. Check here http://stackoverflow.com/questions/17947290/query-related-to-explicit-wait-wait-untilexpectedconditions-visibilityofelemen and http://sqa.stackexchange.com/questions/10144/timeoutexception-when-trying-to-identify-dropdown-element-in-last-iteration-of-f – aberna Feb 23 '15 at 12:23