-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update with the contents of Chapter 10 Section 6
- Loading branch information
Showing
4 changed files
with
89 additions
and
18 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
from selene.api import * | ||
import time | ||
|
||
# ToDo入力モーダルのPageクラス | ||
class TodoInputModal: | ||
# UIのセレクタ | ||
TITLE_SELECTOR = "#modal-todo-title" | ||
MEMO_SELECTOR = "#modal-todo-memo" | ||
PRIORITY_SELECT_SELECTOR = "#modal-todo-priority" | ||
PRIORITY_OPTION_SELECTOR = { | ||
"高": "#modal-todo-priority :nth-child(1)", | ||
"中": "#modal-todo-priority :nth-child(2)", | ||
"低": "#modal-todo-priority :nth-child(3)" | ||
} | ||
REGISTER_BUTTON_SELECTOR = "#register-button" | ||
|
||
def __init__(self, driver=None): | ||
self.driver = driver | ||
driver.s(".modal-title").should(be.visible) | ||
|
||
# パラメータを入力する | ||
def input_param(self, | ||
title_input_value, | ||
memo_input_value, | ||
priority_input_value): | ||
self.driver.s( | ||
self.TITLE_SELECTOR).set_value(title_input_value) | ||
time.sleep(1) | ||
self.driver.s( | ||
self.MEMO_SELECTOR).set_value(memo_input_value) | ||
self.driver.s( | ||
self.PRIORITY_SELECT_SELECTOR).click() | ||
self.driver.s( | ||
self.PRIORITY_OPTION_SELECTOR[priority_input_value])\ | ||
.click() | ||
|
||
# 登録ボタンをクリックする | ||
def click_register(self): | ||
self.driver.s(self.REGISTER_BUTTON_SELECTOR).click() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from selene.api import * | ||
from .todo_input_modal import TodoInputModal | ||
|
||
# ToDo一覧のPageクラス | ||
class TodoListPage: | ||
URL = 'http://127.0.0.1:8002/index.html' | ||
REGISTER_BUTTON_SELECTOR = "#new-todo" | ||
TODO_LIST_SELECTOR = "#todo-list tr" | ||
TODO_TITLE_CELL_SELECTOR = "td:nth-of-type(2)" | ||
|
||
def __init__(self, driver=None): | ||
self.driver = driver | ||
|
||
# ToDo一覧を新規で開く | ||
def open_page(self): | ||
self.driver.get(self.URL) | ||
|
||
# ToDo登録ボタンを入力する | ||
def click_register(self): | ||
self.driver.s(self.REGISTER_BUTTON_SELECTOR).click() | ||
return TodoInputModal(self.driver) | ||
|
||
# 引数のタイトルが画面上に存在するかチェックする | ||
def is_exist_title(self, title): | ||
exist_flg = False | ||
self.driver.s("#todo-list").should(be.visible) | ||
todo_elements = self.driver.ss(self.TODO_LIST_SELECTOR) | ||
for todo_element in todo_elements: | ||
todo_title_cell = todo_element.s( | ||
self.TODO_TITLE_CELL_SELECTOR) | ||
if todo_title_cell.text.find(title): | ||
exist_flg = True | ||
return exist_flg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,30 @@ | ||
from selene.api import * | ||
from pages.todo_list_page import TodoListPage | ||
|
||
# ToDo新規登録のテストシナリオ | ||
class TestTodoInputSelene: | ||
class TestTodoInputPageobj: | ||
|
||
def test_ToDoを一件登録する(self, driver): | ||
|
||
param_title = "CATCH the GLORY" | ||
param_memo = "新時代、熱狂しろ!" | ||
param_priority = "低" | ||
|
||
expected_title = "CATCH the GLORY" | ||
|
||
todo_list_page = TodoListPage(driver) | ||
|
||
# 画面を開く | ||
driver.get('http://127.0.0.1:8002/index.html') | ||
todo_list_page.open_page() | ||
|
||
# 登録ボタンをタップする | ||
driver.s("#new-todo").click() | ||
driver.s(".modal-title").should(be.visible) | ||
todo_input_modal = todo_list_page.click_register() | ||
|
||
# 各入力欄に値を入力する | ||
driver.s("#modal-todo-title").set_value("CATCH the GLORY") | ||
driver.s("#modal-todo-memo").set_value("新時代、熱狂しろ!") | ||
driver.s("#modal-todo-priority").click() | ||
driver.s("#modal-todo-priority :nth-child(3)").click() | ||
todo_input_modal.input_param( | ||
param_title, param_memo, param_priority) | ||
|
||
# 登録ボタンをタップする | ||
driver.s("#register-button").click() | ||
todo_input_modal.click_register() | ||
|
||
# 入力した内容が表示されていることを確認 | ||
driver.s("#todo-list").should(be.visible) | ||
assert_flg = False | ||
todo_elements = driver.ss("#todo-list tr") | ||
for todo_element in todo_elements: | ||
if todo_element.s("td:nth-of-type(2)")\ | ||
.text.find("CATCH the GLORY"): | ||
assert_flg = True | ||
assert assert_flg | ||
assert todo_list_page.is_exist_title(expected_title) |