Skip to content

Instantly share code, notes, and snippets.

@andy-takker
Created April 15, 2023 09:21
Show Gist options
  • Select an option

  • Save andy-takker/683009b58de9ee7bbac337bd64530a05 to your computer and use it in GitHub Desktop.

Select an option

Save andy-takker/683009b58de9ee7bbac337bd64530a05 to your computer and use it in GitHub Desktop.
selenium checking
import time
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.options import Options
def click_on_suggestion(ind=0):
suggestion_el = driver.find_elements(By.CLASS_NAME, "rzd-suggestion-block")
suggestion_els = suggestion_el[ind].find_elements(By.TAG_NAME, "li")
suggestion_els[1].click()
options = Options()
options.add_argument('--no-sandbox')
options.add_argument("--headless")
options.add_argument('--disable-dev-shm-usage')
options.add_argument("--remote-debugging-port=19222") # this
driver = webdriver.Chrome(executable_path='./chromedriver', options=options)
driver.get('https://www.rzd.ru/')
print('Get page')
time.sleep(5)
el_from = driver.find_element(By.ID, "direction-from")
el_from.send_keys('Москва')
time.sleep(1)
click_on_suggestion()
time.sleep(1)
el_to = driver.find_element(By.ID, "direction-to")
el_to.send_keys('Шахты')
time.sleep(1)
click_on_suggestion(1)
time.sleep(1)
el_date_from = driver.find_element(By.ID, "datepicker-from")
el_date_from.send_keys('20.06.2023')
time.sleep(1)
btn = driver.find_elements(By.CLASS_NAME, "rzd-go-to-result-button")[0]
btn.click()
time.sleep(5)
print(driver.current_url)
driver.quit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment