I try to check (click) this checkbox using an XPath but all my attempts so far has failed, because they click on the link in the legend (Lorem ipsum)
HTML source:
<div class="input-outer checkbox">
<div class="section-head sec-head2">
<!---->
<div class="pull-left">Tick this box</div>
<!----><!---->
<p aria-label="required" class="requiredAsteric">*</p>
</div>
<div class="input-validation">
<div class="input-icon-outer">
<!---->
<!---->
<!---->
<!---->
<input class="filled-in ng-untouched ng-pristine ng-invalid" type="checkbox" aria-label="Acceptera villkor" aria-required="true" aria-describedby="err_icon_prefix2_1" id="icon_prefix2_1"><!---->
<label class="leadform-checkbox" tabindex="0" for="icon_prefix2_1">
<div>
<p>Lorem ipsum dolor sit amet, consectetur <a href="https://www.google.com" target="_blank">adipiscing elit</a> adipiscing elit , sed do <a href="https://www.stackexchange.com" target="_blank">eiusmod tempor </a> incididunt ut labore et dolore magna aliqua.</p>
</div>
</label>
<!---->
</div>
</div>
</div>
So far I have tried these three XPaths but none of them worked.
//label[@class='leadform-checkbox']/div";
//input[@aria-label='Tick this box']";
(//div[@class='input-icon-outer'])[3]";
If I understand the HTML correctly (which I probably don't), they don't use the checkbox functionality built in into HTML but have created a CSS-class that contains a graphical element that looks like a checkbox. Now when I send a click to the div that uses this style the click ends up on the textual content of the div, rather than checkbox, and clicks the link found there.
Have I understand things correctly? How do I fix this/direct the click to the square?
Edit: There are two other text fields in this "dialog". I have no problems accessing them with these two XPaths:
String xpText = "//input[@aria-label='text']";
String xpNumber = "//input[@aria-label='number']";
All three elements are in the same iframe
. I perform several switches between the main content
and different iframes
before these steps.
The heading 2.2
is in the <div class="input-outer">
visible at the top of the screen shot of the HTML source above so I am pretty sure I am in the right frame/content. Besides, I could access the links in the text that belongs to this checkbox.
Included the whole dialog below to make it easier to get an overview.