-
-
Notifications
You must be signed in to change notification settings - Fork 152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ATTENTION! Remove "out of the box" widgets support (complete internal implementation refactoring to make it simpler) #17
Comments
Привет, прежде всего спасибо за очень удобную библиотеку. Насколько я понял ты решил убрать поддержку Виджетов (SElement)? То есть теперь не будет возможности делать отдельным элементом допустим карточку пользователя которая используется на разных страницах? Жаль, ведь довольно удобная штука и вроде не мешает тем кто это не использует. (( |
There will be no out of the box support, like this: from selenium import webdriver
from selene.conditions import *
from selene.tools import *
from tests.todomvc.helpers.todomvc import given_active
def setup_module(m):
set_driver(webdriver.Firefox())
def teardown_module(m):
get_driver().quit()
class Task(SElement):
def delete(self):
self.hover()
self.s(".destroy").click()
class TodoMVC(SElement):
def init(self):
self.tasks = ss("#todo-list>li").of(self.Task)
self.footer = self.Footer("#footer")
# self.footer = s("#footer").of(self.Footer) # todo: add such syntax
def clear_completed(self):
self.footer.clear_completed.click()
self.footer.clear_completed.assure(hidden)
return self
class Task(SElement):
def toggle(self):
self.s(".toggle").click()
return self
class Footer(SElement):
def init(self):
self.clear_completed = self.s("#clear-completed")
def assure_items_left(self, number_of_active_tasks):
self.s("#todo-count>strong").assure(exact_text(str(number_of_active_tasks)))
def test_complete_task():
given_active("a", "b")
page = TodoMVC("#todoapp") # it's more widget than page... todo: rename to todomvc, etc...
page.tasks.find(text("b")).toggle()
page.clear_completed()
page.tasks.assure(texts("a"))
page.footer.assure_items_left(1) but you still can implement it through simple OOP Aggregation & Composition: from selene.conditions import exact_text, hidden, exact_texts
from selene.tools import set_driver, get_driver, ss, s
from selenium import webdriver
from helpers.todomvc import given_active
def setup_module(m):
set_driver(webdriver.Firefox())
def teardown_module(m):
get_driver().quit()
class Task(object):
def __init__(self, container):
self.container = container
def toggle(self):
self.container.find(".toggle").click()
return self
class Tasks(object):
def _elements(self):
return ss("#todo-list>li")
def _task_element(self, text):
return self._elements().findBy(exact_text(text))
def task(self, text):
return Task(self._task_element(text))
def should_be(self, *texts):
self._elements().should_have(exact_texts(*texts))
class Footer(object):
def __init__(self):
self.container = s("#footer")
self.clear_completed = self.container.find("#clear-completed")
def should_have_items_left(self, number_of_active_tasks):
self.container.find("#todo-count>strong").should_have(exact_text(str(number_of_active_tasks)))
class TodoMVC(object):
def __init__(self):
self.container = s("#todoapp");
self.tasks = Tasks()
self.footer = Footer()
def clear_completed(self):
self.footer.clear_completed.click()
self.footer.clear_completed.should_be(hidden)
return self
def test_complete_task():
given_active("a", "b")
page = TodoMVC()
page.tasks.task("b").toggle()
page.clear_completed()
page.tasks.should_be("a")
page.footer.should_have_items_left(1) There will be a bit more code to implement, but this code will be more KISS (Keep It Simple, Stupid). To code this way you need to know only what is OOP & Aggregation, what is nevertheless - basics that everyone should learn. To code the "old selene syntax way" you have to learn "selene specific syntax". This is completely not KISS:) It's like learning two languages: Python + Selene's DSL. I believe that learning one language is simpler :) than learning two:) Such "simpler" way, will also allow to simplify the internal Selene implementation so more people with start to contribute to the project. Currently the internal implementation is too complicated (because of this "out of the box widgets support") to get help from community:) |
…_by_condition tests fail, possible for some bug in cashing implementation - this will be fixed during #17 refactoring
…module to new SeleneDriver based implementation
…entation still exist in sources; harden implementation, ensured all tests passes (except order tests which should be refactored to the new style of widgets implementations)
…d - refactored old widgets example of tests for orderapp
I plan to remove current "widgets support".
Because
PLEASE, notify me if you use this feature now, so we can plan convenient "porting" to next "selene version".
The text was updated successfully, but these errors were encountered: