Created
April 15, 2023 09:21
-
-
Save andy-takker/683009b58de9ee7bbac337bd64530a05 to your computer and use it in GitHub Desktop.
selenium checking
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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