Missed a file
This commit is contained in:
		
							parent
							
								
									71249f04ab
								
							
						
					
					
						commit
						858f7cccdf
					
				|  | @ -11,7 +11,7 @@ Feature: Add tasks to todo list | ||||||
| 
 | 
 | ||||||
|   Scenario: Add a new task to the todo list |   Scenario: Add a new task to the todo list | ||||||
|         Given I am on the todo list page |         Given I am on the todo list page | ||||||
|         When I enter "Buy groceries" in the title field |         When I enter 'Buy groceries' in the title field | ||||||
|         And I enter "2" in the estimate field |         And I enter '2' in the estimate field | ||||||
|         And I click the "Add" button |         And I click the 'Add' button | ||||||
|         Then the task "Buy groceries" with estimate "2" should be added to the todo list |         Then the task 'Buy groceries' with estimate '2' should be added to the todo list | ||||||
|  | @ -1,5 +0,0 @@ | ||||||
| How to run behave tutorial |  | ||||||
| 
 |  | ||||||
| 1. Running all behave features |  | ||||||
| 
 |  | ||||||
| run " behave tests/features/add-task.feature " |  | ||||||
|  | @ -1,38 +1,54 @@ | ||||||
| from behave import * | from behave import given, when, then | ||||||
| from webdriver_manager.chrome import ChromeDriverManager | from webdriver_manager.chrome import ChromeDriverManager | ||||||
| from selenium import webdriver | from selenium import webdriver | ||||||
| from selenium.webdriver.chrome.service import Service as ChromeService | from selenium.webdriver.chrome.service import Service as ChromeService | ||||||
| from selenium.webdriver.common.by import By | from selenium.webdriver.common.by import By | ||||||
|  | from selenium.webdriver.chrome.options import Options | ||||||
| 
 | 
 | ||||||
| @given(u'I am on the todo list page') | #THESE ARE EXAMPLES FILES. | ||||||
|  | #Todo delete these once we set a standard with our own tests | ||||||
|  | 
 | ||||||
|  | @given("I am on the todo list page") | ||||||
| def open_browser(context): | def open_browser(context): | ||||||
|     context.driver = webdriver.Chrome(service=ChromeService(ChromeDriverManager().install())) | 
 | ||||||
|  |     # Implementation of headless from https://stackoverflow.com/questions/46920243/how-to-configure-chromedriver-to-initiate-chrome-browser-in-headless-mode-throug | ||||||
|  |     # Stackoverflow post desribes what is goin on with options to enable headless chrome | ||||||
|  | 
 | ||||||
|  |     options = Options() | ||||||
|  |     options.add_argument("--headless") # Runs Chrome in headless mode. | ||||||
|  |     options.add_argument('--no-sandbox') # Bypass OS security model | ||||||
|  |     options.add_argument('start-maximized') #to maximize viewport this should still be headless | ||||||
|  |     options.add_argument('disable-infobars') | ||||||
|  |     options.add_argument("--disable-extensions") | ||||||
|  |     context.driver = webdriver.Chrome(options=options, service=ChromeService(ChromeDriverManager().install())) | ||||||
|     context.driver.implicitly_wait(5) |     context.driver.implicitly_wait(5) | ||||||
|     context.driver.get("http://127.0.0.1:5000/") |     context.driver.get("http://127.0.0.1:5000/") | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @when('I enter "{title}" in the title field') | @when("I enter '{title}' in the title field") | ||||||
| def step_impl(context, title): | def step_impl(context, title): | ||||||
|     title_field = context.driver.find_element(By.NAME, "title") |     title_field = context.driver.find_element(By.NAME, "title") | ||||||
|     title_field.send_keys(title) |     title_field.send_keys(title) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @when('I enter "{estimate}" in the estimate field') | @when("I enter '{estimate}' in the estimate field") | ||||||
| def step_impl(context, estimate): | def step_impl(context, estimate): | ||||||
|     estimate_field = context.driver.find_element(By.NAME, "estimate") |     estimate_field = context.driver.find_element(By.NAME, "estimate") | ||||||
|     estimate_field.send_keys(estimate) |     estimate_field.send_keys(estimate) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @when(u'I click the "Add" button') | @when("I click the 'Add' button") | ||||||
| def step_impl(context): | def step_impl(context): | ||||||
|     add_button = context.driver.find_element(By.XPATH, "//button[contains(text(),'Add')]") |     add_button = context.driver.find_element(By.XPATH, "//button[contains(text(),'Add')]") | ||||||
|     add_button.click() |     add_button.click() | ||||||
|     context.driver.implicitly_wait(5) |     context.driver.implicitly_wait(5) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @then('the task "{title}" with estimate "{estimate}" should be added to the todo list') | @then("the task '{title}' with estimate '{estimate}' should be added to the todo list") | ||||||
| def step_impl(context, title, estimate): | def step_impl(context, title, estimate): | ||||||
|     dump_text = context.driver.page_source |     dump_text = context.driver.page_source | ||||||
|     print(dump_text) |     print(dump_text) | ||||||
|     assert ("Buy groceries | 2" in dump_text) is True |     assert ("Buy groceries | 2" in dump_text) is True | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |  | ||||||
|  | @ -1,30 +1,39 @@ | ||||||
| from behave import * | from behave import given, when, then | ||||||
| from webdriver_manager.chrome import ChromeDriverManager | from webdriver_manager.chrome import ChromeDriverManager | ||||||
| from selenium import webdriver | from selenium import webdriver | ||||||
| from selenium.webdriver.chrome.service import Service as ChromeService | from selenium.webdriver.chrome.service import Service as ChromeService | ||||||
| from selenium.webdriver.common.by import By | from selenium.webdriver.common.by import By | ||||||
|  | from selenium.webdriver.chrome.options import Options | ||||||
| 
 | 
 | ||||||
|  | #THESE ARE EXAMPLES FILES. | ||||||
|  | #Todo delete these once we set a standard with our own tests | ||||||
| 
 | 
 | ||||||
| @given(u'the user is on the todo list page') | @given("the user is on the todo list page") | ||||||
| def open_browser(context): | def open_browser(context): | ||||||
|     context.driver = webdriver.Chrome(service=ChromeService(ChromeDriverManager().install())) |     options = Options() | ||||||
|  |     options.add_argument("--headless") # Runs Chrome in headless mode. | ||||||
|  |     options.add_argument('--no-sandbox') # Bypass OS security model | ||||||
|  |     options.add_argument('start-maximized') #to maximize viewport this should still be headless | ||||||
|  |     options.add_argument('disable-infobars') | ||||||
|  |     options.add_argument("--disable-extensions") | ||||||
|  |     context.driver = webdriver.Chrome(options=options, service=ChromeService(ChromeDriverManager().install())) | ||||||
|     context.driver.implicitly_wait(5) |     context.driver.implicitly_wait(5) | ||||||
|     context.driver.get("http://127.0.0.1:5000/") |     context.driver.get("http://127.0.0.1:5000/") | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @then(u'the page should have a text field to enter the title of the task') | @then("the page should have a text field to enter the title of the task") | ||||||
| def check_task_title_textbox(context): | def check_task_title_textbox(context): | ||||||
|     status = context.driver.find_element(By.NAME, "title").is_displayed() |     status = context.driver.find_element(By.NAME, "title").is_displayed() | ||||||
|     assert status is True |     assert status is True | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @then(u'the page should have a text field to enter the estimate of hours needed to complete the task') | @then("the page should have a text field to enter the estimate of hours needed to complete the task") | ||||||
| def check_task_estimate_textbox(context): | def check_task_estimate_textbox(context): | ||||||
|     status = context.driver.find_element(By.NAME, "estimate").is_displayed() |     status = context.driver.find_element(By.NAME, "estimate").is_displayed() | ||||||
|     assert status is True |     assert status is True | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @then(u'the page should have a button to add the task') | @then("the page should have a button to add the task") | ||||||
| def check_task_add_button(context): | def check_task_add_button(context): | ||||||
|     status = context.driver.find_element(By.XPATH, "//button[contains(text(),'Add')]").is_displayed() |     status = context.driver.find_element(By.XPATH, "//button[contains(text(),'Add')]").is_displayed() | ||||||
|     assert status is True |     assert status is True | ||||||
|  |  | ||||||
|  | @ -1,11 +0,0 @@ | ||||||
| How to run unit tests |  | ||||||
| 
 |  | ||||||
| unit tests must follow the "test*.py" regex to be picked up |  | ||||||
| 
 |  | ||||||
| 1. Individual tests |  | ||||||
| 
 |  | ||||||
| run " python .\tests\unit\test_example.py " |  | ||||||
| 
 |  | ||||||
| 2. Run all unit tests |  | ||||||
| 
 |  | ||||||
| run "  python -m unittest discover -s ./tests/unit " |  | ||||||
		Loading…
	
		Reference in New Issue