Skip to content

Commit 5521c6d

Browse files
committed
Refactor logic to TodoPage and page fixture
1 parent 8ba654f commit 5521c6d

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

tests/test_todo.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,26 @@
1+
import pytest
12
from pylenium.driver import Pylenium
3+
from pylenium.element import Element, Elements
4+
5+
6+
class TodoPage:
7+
def __init__(self, py: Pylenium):
8+
self.py = py
9+
10+
def goto(self) -> 'TodoPage':
11+
self.py.visit('https://lambdatest.github.io/sample-todo-app/')
12+
return self
13+
14+
def get_todo_by_name(self, name: str) -> Element:
15+
return self.py.getx(f"//*[text()='{name}']").parent()
16+
17+
def get_all_todos(self) -> Elements:
18+
return self.py.find("li[ng-repeat*='todo']")
19+
20+
21+
@pytest.fixture
22+
def page(py: Pylenium):
23+
return TodoPage(py).goto()
224

325

426
def test_check_first_item(py: Pylenium):

0 commit comments

Comments
 (0)