-
Notifications
You must be signed in to change notification settings - Fork 0
/
5_explicit_wait.py
50 lines (39 loc) · 1.25 KB
/
5_explicit_wait.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import time
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.support.ui import WebDriverWait
driver = webdriver.Safari()
driver.set_window_size(1350, 768)
driver.get("https://www.expedia.co.in")
time.sleep(2)
# Go to flights tab
driver.find_element(
By.XPATH, '//*[@id="wizardMainRegionV2"]/div/div/div/div/ul/li[2]/a/span'
).click()
# Add journey details
time.sleep(2)
origin_element = driver.find_element(By.ID, "location-field-leg1-origin-menu")
origin_element.click()
time.sleep(2)
origin_element.send_keys("BOM")
time.sleep(2)
origin_element.send_keys(Keys.RETURN)
time.sleep(2)
destination_element = driver.find_element(By.ID, "location-field-leg1-destination-menu")
destination_element.click()
time.sleep(2)
destination_element.send_keys("DEL")
time.sleep(2)
origin_element.send_keys(Keys.RETURN)
time.sleep(2)
driver.find_element(
By.XPATH, '//*[@id="wizard-flight-pwa-1"]/div[3]/div[2]/button'
).click()
time.sleep(5)
direct_element = WebDriverWait(driver, 10).until(
expected_conditions.presence_of_element_located((By.ID, "NUM_OF_STOPS-0-w1t"))
)
direct_element.click()
driver.quit()