-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_integration.py
More file actions
76 lines (63 loc) · 2.45 KB
/
test_integration.py
File metadata and controls
76 lines (63 loc) · 2.45 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import os
import pytest
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
driver_path = os.getenv("DRIVER_PATH")
driver = webdriver.Chrome(driver_path)
browser = driver.get("http://localhost:5000/")
@pytest.fixture(scope='session', autouse=True)
def integration_tests():
yield
driver.close()
driver.quit()
print("donedonedone")
def test_artists_link():
table_type = "artists"
_test_link(table_type)
_test_link_click_result(table_type, 2)
def _test_link(table_type):
link = driver.find_element_by_id(f"{table_type}Link")
link.click()
def _test_link_click_result(table_type, num_of_columns):
try:
datatable = WebDriverWait(driver, 3).until(EC.presence_of_all_elements_located(
(By.ID, f"{table_type}Table_wrapper")
))
except Exception as e:
assert datatable
columns = driver.find_elements(By.XPATH, f"//table[@id=\"{table_type}Table\"]/thead/tr/th")
assert len(columns) == num_of_columns
driver.implicitly_wait(3)
rows = driver.find_elements(By.XPATH, f"//table[@id=\"{table_type}Table\"]/tbody/tr")
assert len(rows)
def test_artwork_link():
table_type = "artwork"
_test_link(table_type)
_test_link_click_result(table_type, 4)
def test_neighbourhood_dropdown():
neighbourhood = driver.find_element_by_id("neighbourhoodCollapseButton")
neighbourhood.click()
neighbourhoodCollapse= driver.find_element_by_id("neighbourhoodCollapse")
assert neighbourhoodCollapse.is_displayed()
def test_neighbourhood_link():
link = driver.find_element_by_xpath('//*[@id="neighbourhoodCollapse"]/ul/li/a[2]')
link.click()
_test_link_click_result("Downtown", 4)
def test_pagination():
table_type = "artists"
_test_link(table_type)
page = driver.find_element_by_xpath(f"//*[@id=\"{table_type}Table_paginate\"]/ul/li[4]/a")
page.click()
driver.implicitly_wait(3)
rows = driver.find_elements(By.XPATH, f"//table[@id=\"{table_type}Table\"]/tbody/tr")
assert len(rows)
def test_search():
table_type = "artists"
_test_link(table_type)
search = driver.find_element_by_xpath(f"//*[@id=\"{table_type}Table_filter\"]/label/input")
search.send_keys("art")
driver.implicitly_wait(3)
rows = driver.find_elements(By.XPATH, f"//table[@id=\"{table_type}Table\"]/tbody/tr")
assert len(rows)