Selenium input date on disabled datepicker












3















I'm trying to input of my own choice of date but i am stuck click disabled datepicker.

If i click on datepicker it pops up and ask to click on the date even for a month I have to click more.
I'm confused here what to do.



URL



http://finra-markets.morningstar.com/BondCenter/TRACEMarketAggregateStats.jsp


My code so far.



from selenium import webdriver
from time import sleep
driver = webdriver.Chrome('path') # No Path Problem just changed here
driver.get('http://finra-markets.morningstar.com/BondCenter/TRACEMarketAggregateStats.jsp')
sleep(6)
date = driver.find_element_by_class_name("date-btn")
date.click()
sleep(4)
selector = driver.find_element_by_css_selector('[val="2017-10-11"]')
selector.click()
sleep(5)


this is not working..!










share|improve this question



























    3















    I'm trying to input of my own choice of date but i am stuck click disabled datepicker.

    If i click on datepicker it pops up and ask to click on the date even for a month I have to click more.
    I'm confused here what to do.



    URL



    http://finra-markets.morningstar.com/BondCenter/TRACEMarketAggregateStats.jsp


    My code so far.



    from selenium import webdriver
    from time import sleep
    driver = webdriver.Chrome('path') # No Path Problem just changed here
    driver.get('http://finra-markets.morningstar.com/BondCenter/TRACEMarketAggregateStats.jsp')
    sleep(6)
    date = driver.find_element_by_class_name("date-btn")
    date.click()
    sleep(4)
    selector = driver.find_element_by_css_selector('[val="2017-10-11"]')
    selector.click()
    sleep(5)


    this is not working..!










    share|improve this question

























      3












      3








      3








      I'm trying to input of my own choice of date but i am stuck click disabled datepicker.

      If i click on datepicker it pops up and ask to click on the date even for a month I have to click more.
      I'm confused here what to do.



      URL



      http://finra-markets.morningstar.com/BondCenter/TRACEMarketAggregateStats.jsp


      My code so far.



      from selenium import webdriver
      from time import sleep
      driver = webdriver.Chrome('path') # No Path Problem just changed here
      driver.get('http://finra-markets.morningstar.com/BondCenter/TRACEMarketAggregateStats.jsp')
      sleep(6)
      date = driver.find_element_by_class_name("date-btn")
      date.click()
      sleep(4)
      selector = driver.find_element_by_css_selector('[val="2017-10-11"]')
      selector.click()
      sleep(5)


      this is not working..!










      share|improve this question














      I'm trying to input of my own choice of date but i am stuck click disabled datepicker.

      If i click on datepicker it pops up and ask to click on the date even for a month I have to click more.
      I'm confused here what to do.



      URL



      http://finra-markets.morningstar.com/BondCenter/TRACEMarketAggregateStats.jsp


      My code so far.



      from selenium import webdriver
      from time import sleep
      driver = webdriver.Chrome('path') # No Path Problem just changed here
      driver.get('http://finra-markets.morningstar.com/BondCenter/TRACEMarketAggregateStats.jsp')
      sleep(6)
      date = driver.find_element_by_class_name("date-btn")
      date.click()
      sleep(4)
      selector = driver.find_element_by_css_selector('[val="2017-10-11"]')
      selector.click()
      sleep(5)


      this is not working..!







      python python-3.x selenium selenium-webdriver selenium-chromedriver






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 21 '18 at 1:11









      Ashfaque MarfaniAshfaque Marfani

      7412




      7412
























          1 Answer
          1






          active

          oldest

          votes


















          1














          Af first, you need to click 'previous month' button until you have a necessary year and month displayed. (in your case you need October 2017). The code of the loop may look like this:



          date = driver.find_element_by_class_name("date-btn")
          date.click()
          sleep(4)
          #getting element representing previous month button
          prev_month = driver.find_element_by_class_name("pm")
          #starting a loop that will click prev_month button untill calendar for October 2017 is shown
          # use .text because getText() does not work here
          while driver.find_element_by_class_name("titleCont").text != "Oct 2017"
          prev_month.click()
          #You can play around this sleep's value. or just remove it completely
          sleep(2)
          #Calendar should now be opened on Oct 2017 so we can look for desired date '11 october 2017
          selector = driver.find_element_by_css_selector('[val="2017-10-11"]')
          selector.click()
          sleep(5)


          When you make it work. Consider replacing sleeps with smart waits official doc, similar question answered






          share|improve this answer





















          • 1





            Thankyou. I did some edits to run it after getting webelement error.

            – Ashfaque Marfani
            Nov 21 '18 at 12:03






          • 1





            awesome! Thanks for edits. My bad... I don't use phyton so was kinda guessing.

            – Vladimir Efimov
            Nov 21 '18 at 12:55











          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%2f53403933%2fselenium-input-date-on-disabled-datepicker%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          Af first, you need to click 'previous month' button until you have a necessary year and month displayed. (in your case you need October 2017). The code of the loop may look like this:



          date = driver.find_element_by_class_name("date-btn")
          date.click()
          sleep(4)
          #getting element representing previous month button
          prev_month = driver.find_element_by_class_name("pm")
          #starting a loop that will click prev_month button untill calendar for October 2017 is shown
          # use .text because getText() does not work here
          while driver.find_element_by_class_name("titleCont").text != "Oct 2017"
          prev_month.click()
          #You can play around this sleep's value. or just remove it completely
          sleep(2)
          #Calendar should now be opened on Oct 2017 so we can look for desired date '11 october 2017
          selector = driver.find_element_by_css_selector('[val="2017-10-11"]')
          selector.click()
          sleep(5)


          When you make it work. Consider replacing sleeps with smart waits official doc, similar question answered






          share|improve this answer





















          • 1





            Thankyou. I did some edits to run it after getting webelement error.

            – Ashfaque Marfani
            Nov 21 '18 at 12:03






          • 1





            awesome! Thanks for edits. My bad... I don't use phyton so was kinda guessing.

            – Vladimir Efimov
            Nov 21 '18 at 12:55
















          1














          Af first, you need to click 'previous month' button until you have a necessary year and month displayed. (in your case you need October 2017). The code of the loop may look like this:



          date = driver.find_element_by_class_name("date-btn")
          date.click()
          sleep(4)
          #getting element representing previous month button
          prev_month = driver.find_element_by_class_name("pm")
          #starting a loop that will click prev_month button untill calendar for October 2017 is shown
          # use .text because getText() does not work here
          while driver.find_element_by_class_name("titleCont").text != "Oct 2017"
          prev_month.click()
          #You can play around this sleep's value. or just remove it completely
          sleep(2)
          #Calendar should now be opened on Oct 2017 so we can look for desired date '11 october 2017
          selector = driver.find_element_by_css_selector('[val="2017-10-11"]')
          selector.click()
          sleep(5)


          When you make it work. Consider replacing sleeps with smart waits official doc, similar question answered






          share|improve this answer





















          • 1





            Thankyou. I did some edits to run it after getting webelement error.

            – Ashfaque Marfani
            Nov 21 '18 at 12:03






          • 1





            awesome! Thanks for edits. My bad... I don't use phyton so was kinda guessing.

            – Vladimir Efimov
            Nov 21 '18 at 12:55














          1












          1








          1







          Af first, you need to click 'previous month' button until you have a necessary year and month displayed. (in your case you need October 2017). The code of the loop may look like this:



          date = driver.find_element_by_class_name("date-btn")
          date.click()
          sleep(4)
          #getting element representing previous month button
          prev_month = driver.find_element_by_class_name("pm")
          #starting a loop that will click prev_month button untill calendar for October 2017 is shown
          # use .text because getText() does not work here
          while driver.find_element_by_class_name("titleCont").text != "Oct 2017"
          prev_month.click()
          #You can play around this sleep's value. or just remove it completely
          sleep(2)
          #Calendar should now be opened on Oct 2017 so we can look for desired date '11 october 2017
          selector = driver.find_element_by_css_selector('[val="2017-10-11"]')
          selector.click()
          sleep(5)


          When you make it work. Consider replacing sleeps with smart waits official doc, similar question answered






          share|improve this answer















          Af first, you need to click 'previous month' button until you have a necessary year and month displayed. (in your case you need October 2017). The code of the loop may look like this:



          date = driver.find_element_by_class_name("date-btn")
          date.click()
          sleep(4)
          #getting element representing previous month button
          prev_month = driver.find_element_by_class_name("pm")
          #starting a loop that will click prev_month button untill calendar for October 2017 is shown
          # use .text because getText() does not work here
          while driver.find_element_by_class_name("titleCont").text != "Oct 2017"
          prev_month.click()
          #You can play around this sleep's value. or just remove it completely
          sleep(2)
          #Calendar should now be opened on Oct 2017 so we can look for desired date '11 october 2017
          selector = driver.find_element_by_css_selector('[val="2017-10-11"]')
          selector.click()
          sleep(5)


          When you make it work. Consider replacing sleeps with smart waits official doc, similar question answered







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 21 '18 at 12:55









          Ashfaque Marfani

          7412




          7412










          answered Nov 21 '18 at 5:42









          Vladimir EfimovVladimir Efimov

          700412




          700412








          • 1





            Thankyou. I did some edits to run it after getting webelement error.

            – Ashfaque Marfani
            Nov 21 '18 at 12:03






          • 1





            awesome! Thanks for edits. My bad... I don't use phyton so was kinda guessing.

            – Vladimir Efimov
            Nov 21 '18 at 12:55














          • 1





            Thankyou. I did some edits to run it after getting webelement error.

            – Ashfaque Marfani
            Nov 21 '18 at 12:03






          • 1





            awesome! Thanks for edits. My bad... I don't use phyton so was kinda guessing.

            – Vladimir Efimov
            Nov 21 '18 at 12:55








          1




          1





          Thankyou. I did some edits to run it after getting webelement error.

          – Ashfaque Marfani
          Nov 21 '18 at 12:03





          Thankyou. I did some edits to run it after getting webelement error.

          – Ashfaque Marfani
          Nov 21 '18 at 12:03




          1




          1





          awesome! Thanks for edits. My bad... I don't use phyton so was kinda guessing.

          – Vladimir Efimov
          Nov 21 '18 at 12:55





          awesome! Thanks for edits. My bad... I don't use phyton so was kinda guessing.

          – Vladimir Efimov
          Nov 21 '18 at 12:55




















          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%2f53403933%2fselenium-input-date-on-disabled-datepicker%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







          這個網誌中的熱門文章

          Xamarin.form Move up view when keyboard appear

          Post-Redirect-Get with Spring WebFlux and Thymeleaf

          Anylogic : not able to use stopDelay()