Skip to content

How do I pick date from date picker (http://www.ksrtc.in/oprs-web/) #6

Open

Description

'''I want to pick date from calendar and want to click on "Search for Bus ''' ||| link to the Website this
So far this is my code :

from selenium.webdriver.common.by import By
from selenium_extensions.core import SeleniumDriver
from selenium.webdriver import ActionChains


class KSRTCBOT(SeleniumDriver):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)


    def goto_ksrtc(self):
        self.driver.get('http://www.ksrtc.in/oprs-web/')
        leaving_from = (By.ID, 'fromPlaceName')
        going_to = (By.ID, 'toPlaceName')
        date_of_departure = (By.ID, 'txtJourneyDate')
        pick_date_from_calender = (By.ID, 'ui-state-default')



        self.wait_for_element_to_be_present(leaving_from)
        self.wait_for_element_to_be_present(going_to)
        self.wait_for_element_to_be_present(date_of_departure)
        self.populate_text_field(leaving_from, 'Bengaluru')
        self.populate_text_field(going_to, 'Belagavi')
        #self.populate_text_field(date_of_departure, '11/09/2017')


#my_browser = (browser='chrome', executable_path = '/usr/local/share/chromedriver', headless = True)

bot = KSRTCBOT(browser='chrome', executable_path = '/usr/local/share/chromedriver')

bot.goto_ksrtc()
#bot.shutdown

Activity

  1. ghost changed the title [-]How do I pick date from [http://www.ksrtc.in/oprs-web/](this) website calendar[/-] [+]How do I pick date from [this](http://www.ksrtc.in/oprs-web/) website calendar[/+] on Sep 9, 2017
  2. pythad commented on Sep 9, 2017

    @pythad
    Owner

    I found date_of_departure to have input field set to readonly. This means the only way to populate it is to click on the date you want in the calendar.

    It will require a little bit more code and logic from your, but there is nothings else to do, because that's how the site works.

    P.S. I would recommend using XPATH to find a date to click

  3. changed the title [-]How do I pick date from [this](http://www.ksrtc.in/oprs-web/) website calendar[/-] [+]How do I pick date from date picker (http://www.ksrtc.in/oprs-web/)[/+] on Sep 9, 2017
  4. pythad commented on Sep 10, 2017

    @pythad
    Owner

    The problem is that for each date picker the code will differ. It's possible to write a snippet for Bootstrap date picker or Materialize one, but I think it's almost impossible to write a generic one.

    It shouldn't be that hard if you try. It will require a bit of selenium and understanding of how to locate elements by XPATH. Try it on your own and if you have some problems ask a question on Stack Overflow. If no one is willing to help you, feel free to share a link to the question at SO to my email.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions