I am dealing with Selenium-Java. For that I need to perform an automatization on a web page.
After recieving very good feedback last time I do have the challenge to find one of the objects I would like to click on.
The following HTML code defines the structure on the page:
<div class="cmp-answers" data-evaluation="0" data-style="sc" data-submit-on-answer-click="0" data-columns="1">
<label class="cmp-answer correct disabled">
<input type="radio" name="answer3425" data-question-id="3425" data-answer-id="16882" value="1" checked="" disabled="" data-misc-answer="0" autocomplete="off">
<div class="cmp-answer-ui">
<span class="cmp-answer-label"><p>Anwer No 1</p></span>
<span class="cmp-answer-feedback"></span>
</div>
</label>
<label class="cmp-answer disabled">
<input type="radio" name="answer3425" data-question-id="3425" data-answer-id="16884" value="1" disabled="" data-misc-answer="0" autocomplete="off">
<div class="cmp-answer-ui">
<span class="cmp-answer-label"><p>Answer No 2</p></span>
<span class="cmp-answer-feedback"></span>
</div>
</label>
<label class="cmp-answer disabled">
<input type="radio" name="answer3425" data-question-id="3425" data-answer-id="16883" value="1" disabled="" data-misc-answer="0" autocomplete="off">
<div class="cmp-answer-ui">
<span class="cmp-answer-label"><p>Answer No 3</p></span>
<span class="cmp-answer-feedback"></span>
</div>
</label>
</div>
These kindes of radio buttons provide three different options to choose:
Answer No1
Answer No2
Answer No3
For test reasons I would do the automatic click on Answer No1
.
Via the html analysis I copied the xPath
as well as the CSS finder information.
I used this information within the findElement
method like:
driver.findElement(By.cssSelector(...));`
or
driver.findElement(By.xpath(...));`
I copied the xPath
for different objects defined by the HTML code shown above and used it within the findElement
method.
Unfortunately none of these options leads to the fact that I was able to find or indicate the object via Selenium.
Therefore, my question. Is anyone of you experienced with that or faced the same or similar chalange? Is there any advice or solution how I can find the object via Selenium an (in the next step) click on that button.
Thank you in advance for any help.
As arguments I used the output of the html analysis (copy->xpath / copy-> css).
Moreover, in the next step I would like to execute click()
after finding the element itself.