1

I have a problem with this checkbox. I tried to click searching element with id, name, XPath, CSS Selector and contains text and still I could not click on this checkbox. Additionally, I've tried with another site with similar HTML code and on this site, it was enough to look for id and click. Any ideas?

<div class="agree-box-term">
    <input tabindex="75" id="agree" name="agree" type="checkbox" value="1">
    <label for="agree" class="checkbox-special">* Zapoznałam/em się z <a href="https://worldbox.pl/content/regulamin,27.html" target="_blank">Regulaminem sklepu internetowego</a> i akceptuję jego postanowienia.<br></label>
</div>

Here is my Python code https://codeshare.io/5zo0Jj

13
  • 2
    check if it is inside any frame.If possible to share entire html? Commented Mar 13, 2019 at 14:40
  • yep, it is possible, where share u this code? Commented Mar 13, 2019 at 14:45
  • can you share here Commented Mar 13, 2019 at 14:47
  • codeshare.io/aVn1Q9 Commented Mar 13, 2019 at 14:49
  • about 1115 line Commented Mar 13, 2019 at 14:50

4 Answers 4

1

I have used javaScript Executor and it clicks on the element.However I have also checked webdriver click is not working.

driver.execute_script("arguments[0].click();", driver.find_element_by_id("agree"))
Sign up to request clarification or add additional context in comments.

3 Comments

Could you explain me why it works only with javaScript Executor?
When WebDriver click doesn’t work.you should use JavaScript executor to interact with element.However this is not a good practice but there is no alternatives.
But why it happens like that?
1

I don't know why this is, but in my experience some boxes don't accept click but do accept a 'mousedown' trigger.

try:

driver.execute_script('$("div.agree-box-term input#agree").trigger("mousedown")')

This solution does rely on jquery being on the page, if it's not we can write it in javascript

Comments

0
r = driver.find_element_by_xpath("//*[@id="form-order"]/div[2]/div[4]/label")
r.click()

Does this work for you? Sometimes it's just a question of selecting the right xpath, or adding the brackets after click.

1 Comment

selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id='form-order']/div[2]/div[4]/label"}
0

Does your code contain nested html tags? For example:

<html>

    <div>

        <p> Some text </p>

        <html>
            That block can't be traversed!
        </html>

    </div>

</html>

Anything inside the second HTML tags can't be traversed/accessed. Try to see if that's the case.


In any other case the following code ran perfectly fine for your snippet:

driver.find_element_by_css_selector('#agree').click()

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.