button is not clicked in selenium

Env

  • python 3.8.17
  • selenium 4.11.2
  • chrome version : 115.0.5790.170 (arm64)

Problem

enter image description here

The Register button in the screenshot above is not clicked in Selenium.

Error message

selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted: Element is not clickable at point (600, 841)
  (Session info: chrome=115.0.5790.170)

using developer tools, section tags are returned to this coordinate
enter image description here
The section tag is the highest parent tag

html full code

    <body>
    <!-- Loader -->
    <div id="preloader" style="visibility: hidden; opacity: 0;">
        <div id="status">
            <div class="spinner">
                <div class="double-bounce1"></div>
                <div class="double-bounce2"></div>
            </div>
        </div>
    </div>
    <!-- Loader -->
    
    <div class="back-to-home rounded d-none d-sm-block">
        <a href="index.html" class="btn btn-icon btn-primary"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-home icons"><path d="M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"></path><polyline points="9 22 9 12 15 12 15 22"></polyline></svg></a>
    </div>
    
    <section class="bg-half-150 d-table w-100 bg-light">
        <div class="container">
            <div class="row justify-content-center">
                <div class="col-lg-5 col-md-8">
                    <img src="/static/layout/images/logo-marp.png" height="60" class="mx-auto d-block" alt="">
                    <div class="card login-page bg-white shadow mt-4 rounded border-0">
                        <div class="card-body">
                            <h4 class="text-center">Sign Up</h4>
                            <form action="/signup" method="post">
                                <div class="row">
                                    
                                        <div class="col-md-12">
                                            <div class="mb-3">
                                                <label class="form-label">Username <span class="text-danger">*</span></label>
                                                <input type="text" name="username" maxlength="150" autofocus="" class="form-control" required="" id="id_username">
                                            </div>
                                        </div>
                                    
                                        <div class="col-md-12">
                                            <div class="mb-3">
                                                <label class="form-label">Email address <span class="text-danger">*</span></label>
                                                <input type="email" name="email" maxlength="254" class="form-control" id="id_email">
                                            </div>
                                        </div>
                                    
                                        <div class="col-md-12">
                                            <div class="mb-3">
                                                <label class="form-label">Password <span class="text-danger">*</span></label>
                                                <input type="password" name="password1" autocomplete="new-password" class="form-control" required="" id="id_password1">
                                            </div>
                                        </div>
                                    
                                        <div class="col-md-12">
                                            <div class="mb-3">
                                                <label class="form-label">Password confirmation <span class="text-danger">*</span></label>
                                                <input type="password" name="password2" autocomplete="new-password" class="form-control" required="" id="id_password2">
                                            </div>
                                        </div>
                                    
                                        <div class="col-md-12">
                                            <div class="mb-3">
                                                <label class="form-label">Region <span class="text-danger">*</span></label>
                                                <input type="text" name="region" maxlength="200" class="form-control" required="" id="id_region">
                                            </div>
                                        </div>
                                    
                                        <div class="col-md-12">
                                            <div class="mb-3">
                                                <label class="form-label">Phone number <span class="text-danger">*</span></label>
                                                <input type="text" name="phone_number" maxlength="200" class="form-control" required="" id="id_phone_number">
                                            </div>
                                        </div>
                                    
    
                                    <div class="col-md-12">
                                        <div class="d-grid">
    
                                            <input type="submit" class="btn btn-primary" value="Register" name="register" id="register">
                                        </div>
                                    </div>
    
                                    
                                </div>
                            </form>
                        </div>
                    </div><!---->
                </div> <!--end col-->
            </div><!--end row-->
        </div> <!--end container-->
    </section>
    <!-- Hero End -->
    <!-- Login Page End Here -->
    <!-- jquery-->
    <script src="/static/layout/js/jquery.min.js"></script>
    <script src="/static/layout/js/bootstrap.bundle.min.js"></script>
    <!-- simplebar -->
    <script src="/static/layout/js/simplebar.min.js"></script>
    <!-- Select2 -->
    <script src="/static/layout/js/select2.min.js"></script>
    <script src="/static/layout/js/select2.init.js"></script>
    <!-- Icons -->
    <script src="/static/layout/js/feather.min.js"></script>
    <!-- Main Js -->
    <script src="/static/layout/js/app.js"></script>
    
    
    
    </body>

seleninum code

def find_and_send(self, by, key, values):
    target = self.selenium.find_element(by, key)
    target.send_keys(values)
    self.selenium = WebDriver()
    self.selenium.implicitly_wait(100)

   # insert field value

def main(self):
    self.selenium.get("{}/signup".format(self.live_server_url))
    self.find_and_send(By.NAME, "username", id)
    self.find_and_send(By.ID, "id_email", "[email protected]")
    self.find_and_send(By.NAME, "password1", "q1w2e3r4Q!W@E#R$")
    self.find_and_send(By.NAME, "password2", "q1w2e3r4Q!W@E#R$")
    self.find_and_send(By.NAME, "region", "seoul")
    self.selenium.find_element(By.NAME, "phone_number").clear()
    self.find_and_send(By.NAME, "phone_number", "01000000000")

    # click sign up button
    self.selenium.find_element(By.ID, 'register').click() # <-- ⚠️ not working!!!

Solve

this problem is solved in the following way.

# click sign up button
self.selenium.find_element(By.ID, 'register').click()
# click sign up button
button=self.selenium.find_element(By.ID, 'register')
self.selenium.execute_script("arguments[0].click();", button)

Question

My question is why this problem occurred.

  • You haven’t explained the actual problem. Are you saying that you successfully call the find_element() and click()` functions, but the form is somehow not submitted?

    – 




  • @JohnGordon tks rely, You’re right. call find_element().click() successfully, but it didn’t work. I want to find the button tag, but selenium retuned section tag in selenium. and i don’t know why python self.selenium.find_element(By.ID, 'register').click()

    – 




Leave a Comment