-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_with_fixture.py
More file actions
34 lines (28 loc) · 1.5 KB
/
test_with_fixture.py
File metadata and controls
34 lines (28 loc) · 1.5 KB
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
import time
from selenium.webdriver.common.by import By
from selenium.webdriver.remote.webelement import WebElement
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
def test_open_page(driver):
driver.get("https://openweathermap.org/")
driver.maximize_window()
assert "https://openweathermap.org/" in driver.current_url
def test_check_page_title(driver):
print(driver.title)
assert driver.title == 'Сurrent weather and forecast - OpenWeatherMap'
def test_fill_search_city_field(driver):
driver.get('https://openweathermap.org/')
WebDriverWait(driver, 10).until_not(EC.presence_of_element_located(
(By.CSS_SELECTOR, 'div.owm-loader-container > div')))
search_city_field = driver.find_element(By.CSS_SELECTOR, "input[placeholder='Search city']")
search_city_field.send_keys('New York')
search_button = driver.find_element(By.CSS_SELECTOR, "button[class ='button-round dark']")
search_button.click()
search_option = WebDriverWait(driver, 15).until(EC.element_to_be_clickable(
(By.CSS_SELECTOR, 'ul.search-dropdown-menu li:nth-child(1) span:nth-child(1)')))
search_option.click()
expected_city = 'New York City, US'
WebDriverWait(driver, 20).until(EC.text_to_be_present_in_element(
(By.CSS_SELECTOR, '.grid-container.grid-4-5 h2'), 'New York'))
displayed_city = driver.find_element(By.CSS_SELECTOR, '.grid-container.grid-4-5 h2').text
assert displayed_city == expected_city