Unable to click on Button using Selenium Python












-2















I'm trying to click on this button to go to the next page, but for some reason, I'm unable to. I tried xpath, css, and class selectors as well as the data-trekkie-id attribute, but nothing I have tried worked. Any help? Code below:



<div class="step__footer" data-step-footer="">
<button name="button" type="submit" class="step__footer__continue-btn btn " data-trekkie-id="continue_to_shipping_method_button" aria-busy="false">
<span class="btn__content">
Continue to shipping method
</span>
</button>
</div>









share|improve this question

























  • any error or exception when you click to it?

    – thanh le
    Nov 15 '18 at 1:02






  • 1





    That isn't code; that's html, and it's only half of the equation. Show us the code.

    – John Gordon
    Nov 15 '18 at 1:31


















-2















I'm trying to click on this button to go to the next page, but for some reason, I'm unable to. I tried xpath, css, and class selectors as well as the data-trekkie-id attribute, but nothing I have tried worked. Any help? Code below:



<div class="step__footer" data-step-footer="">
<button name="button" type="submit" class="step__footer__continue-btn btn " data-trekkie-id="continue_to_shipping_method_button" aria-busy="false">
<span class="btn__content">
Continue to shipping method
</span>
</button>
</div>









share|improve this question

























  • any error or exception when you click to it?

    – thanh le
    Nov 15 '18 at 1:02






  • 1





    That isn't code; that's html, and it's only half of the equation. Show us the code.

    – John Gordon
    Nov 15 '18 at 1:31
















-2












-2








-2








I'm trying to click on this button to go to the next page, but for some reason, I'm unable to. I tried xpath, css, and class selectors as well as the data-trekkie-id attribute, but nothing I have tried worked. Any help? Code below:



<div class="step__footer" data-step-footer="">
<button name="button" type="submit" class="step__footer__continue-btn btn " data-trekkie-id="continue_to_shipping_method_button" aria-busy="false">
<span class="btn__content">
Continue to shipping method
</span>
</button>
</div>









share|improve this question
















I'm trying to click on this button to go to the next page, but for some reason, I'm unable to. I tried xpath, css, and class selectors as well as the data-trekkie-id attribute, but nothing I have tried worked. Any help? Code below:



<div class="step__footer" data-step-footer="">
<button name="button" type="submit" class="step__footer__continue-btn btn " data-trekkie-id="continue_to_shipping_method_button" aria-busy="false">
<span class="btn__content">
Continue to shipping method
</span>
</button>
</div>






python selenium selenium-webdriver xpath css-selectors






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 15 '18 at 10:56









DebanjanB

43k94383




43k94383










asked Nov 15 '18 at 0:58









Frank DiGiacomo KnarF THUNDER Frank DiGiacomo KnarF THUNDER

74




74













  • any error or exception when you click to it?

    – thanh le
    Nov 15 '18 at 1:02






  • 1





    That isn't code; that's html, and it's only half of the equation. Show us the code.

    – John Gordon
    Nov 15 '18 at 1:31





















  • any error or exception when you click to it?

    – thanh le
    Nov 15 '18 at 1:02






  • 1





    That isn't code; that's html, and it's only half of the equation. Show us the code.

    – John Gordon
    Nov 15 '18 at 1:31



















any error or exception when you click to it?

– thanh le
Nov 15 '18 at 1:02





any error or exception when you click to it?

– thanh le
Nov 15 '18 at 1:02




1




1





That isn't code; that's html, and it's only half of the equation. Show us the code.

– John Gordon
Nov 15 '18 at 1:31







That isn't code; that's html, and it's only half of the equation. Show us the code.

– John Gordon
Nov 15 '18 at 1:31














2 Answers
2






active

oldest

votes


















0














As per the HTML to invoke click() method on the button with text as Continue to shipping method you need to induce WebDriverWait and you can use either of the following solutions:





  • Using CSS_SELECTOR:



    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "button.step__footer__continue-btn.btn[data-trekkie-id='continue_to_shipping_method_button']>span.btn__content"))).click()



  • Using XPATH:



    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//button[@class='step__footer__continue-btn btn' and @data-trekkie-id='continue_to_shipping_method_button']/span[@class='btn__content']"))).click()



  • Note : You have to add the following imports :



    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support import expected_conditions as EC







share|improve this answer































    0














    This should work:



    driver.find_element_by_xpath("//*[contains(local-name(), 'button') and contains(@class, 'step__footer__continue-btn')]").click()





    share|improve this answer























      Your Answer






      StackExchange.ifUsing("editor", function () {
      StackExchange.using("externalEditor", function () {
      StackExchange.using("snippets", function () {
      StackExchange.snippets.init();
      });
      });
      }, "code-snippets");

      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "1"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53310984%2funable-to-click-on-button-using-selenium-python%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      0














      As per the HTML to invoke click() method on the button with text as Continue to shipping method you need to induce WebDriverWait and you can use either of the following solutions:





      • Using CSS_SELECTOR:



        WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "button.step__footer__continue-btn.btn[data-trekkie-id='continue_to_shipping_method_button']>span.btn__content"))).click()



      • Using XPATH:



        WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//button[@class='step__footer__continue-btn btn' and @data-trekkie-id='continue_to_shipping_method_button']/span[@class='btn__content']"))).click()



      • Note : You have to add the following imports :



        from selenium.webdriver.support.ui import WebDriverWait
        from selenium.webdriver.common.by import By
        from selenium.webdriver.support import expected_conditions as EC







      share|improve this answer




























        0














        As per the HTML to invoke click() method on the button with text as Continue to shipping method you need to induce WebDriverWait and you can use either of the following solutions:





        • Using CSS_SELECTOR:



          WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "button.step__footer__continue-btn.btn[data-trekkie-id='continue_to_shipping_method_button']>span.btn__content"))).click()



        • Using XPATH:



          WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//button[@class='step__footer__continue-btn btn' and @data-trekkie-id='continue_to_shipping_method_button']/span[@class='btn__content']"))).click()



        • Note : You have to add the following imports :



          from selenium.webdriver.support.ui import WebDriverWait
          from selenium.webdriver.common.by import By
          from selenium.webdriver.support import expected_conditions as EC







        share|improve this answer


























          0












          0








          0







          As per the HTML to invoke click() method on the button with text as Continue to shipping method you need to induce WebDriverWait and you can use either of the following solutions:





          • Using CSS_SELECTOR:



            WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "button.step__footer__continue-btn.btn[data-trekkie-id='continue_to_shipping_method_button']>span.btn__content"))).click()



          • Using XPATH:



            WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//button[@class='step__footer__continue-btn btn' and @data-trekkie-id='continue_to_shipping_method_button']/span[@class='btn__content']"))).click()



          • Note : You have to add the following imports :



            from selenium.webdriver.support.ui import WebDriverWait
            from selenium.webdriver.common.by import By
            from selenium.webdriver.support import expected_conditions as EC







          share|improve this answer













          As per the HTML to invoke click() method on the button with text as Continue to shipping method you need to induce WebDriverWait and you can use either of the following solutions:





          • Using CSS_SELECTOR:



            WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "button.step__footer__continue-btn.btn[data-trekkie-id='continue_to_shipping_method_button']>span.btn__content"))).click()



          • Using XPATH:



            WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//button[@class='step__footer__continue-btn btn' and @data-trekkie-id='continue_to_shipping_method_button']/span[@class='btn__content']"))).click()



          • Note : You have to add the following imports :



            from selenium.webdriver.support.ui import WebDriverWait
            from selenium.webdriver.common.by import By
            from selenium.webdriver.support import expected_conditions as EC








          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 15 '18 at 10:57









          DebanjanBDebanjanB

          43k94383




          43k94383

























              0














              This should work:



              driver.find_element_by_xpath("//*[contains(local-name(), 'button') and contains(@class, 'step__footer__continue-btn')]").click()





              share|improve this answer




























                0














                This should work:



                driver.find_element_by_xpath("//*[contains(local-name(), 'button') and contains(@class, 'step__footer__continue-btn')]").click()





                share|improve this answer


























                  0












                  0








                  0







                  This should work:



                  driver.find_element_by_xpath("//*[contains(local-name(), 'button') and contains(@class, 'step__footer__continue-btn')]").click()





                  share|improve this answer













                  This should work:



                  driver.find_element_by_xpath("//*[contains(local-name(), 'button') and contains(@class, 'step__footer__continue-btn')]").click()






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 15 '18 at 12:19









                  AlichinoAlichino

                  7801617




                  7801617






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53310984%2funable-to-click-on-button-using-selenium-python%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Florida Star v. B. J. F.

                      Error while running script in elastic search , gateway timeout

                      Adding quotations to stringified JSON object values