ClearBowl/selenium/test.py

65 lines
2.6 KiB
Python
Raw Normal View History

2019-12-09 11:02:46 +01:00
#!/usr/bin/env python3
import unittest
from selenium import webdriver
class ClearBowlTest(unittest.TestCase):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
2019-12-09 11:15:18 +01:00
self.driver = self.set_chrome()
2019-12-09 11:02:46 +01:00
self.base_url = "https://clearbowl.herokuapp.com"
def test_login(self):
email = 'artnow@st.amu.edu.pl'
password = 'Tester#123'
self.driver.get(f'{self.base_url}/login')
self.driver.find_element_by_xpath("//input[@placeholder='Email']").send_keys(email)
self.driver.find_element_by_xpath("//input[@placeholder='Hasło']").send_keys(password)
self.driver.find_element_by_xpath("//button[@class='ivu-btn ivu-btn-primary']").click()
self.driver.find_element_by_xpath(f"//div[contains(text(),'Witaj, {email}')]")
2020-01-19 20:07:30 +01:00
def test_recipes(self):
self.driver.get(f'{self.base_url}/recipes')
self.driver.find_element_by_xpath("//div[@class='ivu-table-wrapper ivu-table-wrapper-with-border']")
self.driver.find_element_by_xpath("//div[@class='ivu-table-header']")
self.driver.find_element_by_xpath("//div[@class='ivu-table-body']")
self.driver.find_element_by_xpath("//span[contains(text(),'Prosty przepis na pyszne nale')]")
def test_recipe_card(self):
self.driver.get(f'{self.base_url}/recipes/8')
self.driver.find_element_by_xpath("//p[contains(text(),'niki')]")
self.driver.find_element_by_xpath("//b[contains(text(),'ywcze:')]")
self.driver.find_element_by_xpath("//b[contains(text(),'adniki:')]")
self.driver.find_element_by_xpath("//p[contains(text(),'Prosty przepis na pyszne nale')]")
self.driver.find_element_by_xpath("//span[contains(text(),'adko ciasto. Doda')]")
def test_products(self):
self.driver.get(f'{self.base_url}/products')
self.driver.find_element_by_xpath("//div[@class='ivu-table-wrapper ivu-table-wrapper-with-border']")
self.driver.find_element_by_xpath("//div[@class='ivu-table-header']")
self.driver.find_element_by_xpath("//div[@class='ivu-table-body']")
self.driver.find_element_by_xpath("//span[contains(text(),'Agrest')]")
2019-12-09 11:15:18 +01:00
# options for running within Jenkins
@staticmethod
def set_chrome():
options = webdriver.ChromeOptions()
options.add_argument('--headless')
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')
2019-12-09 11:31:54 +01:00
driver = webdriver.Chrome(options=options)
driver.implicitly_wait(15)
return driver
2019-12-09 11:15:18 +01:00
2019-12-09 11:02:46 +01:00
def tearDown(self):
self.driver.quit()
if __name__ == '__main__':
unittest.main()