from .support import PyScriptTest
class TestPyButton(PyScriptTest):
def test_on_click(self):
self.pyscript_run(
"""
import js
def on_click(evt):
js.console.log('clicked!')
"""
)
assert self.console.log.lines[0] == self.PY_COMPLETE
self.page.locator("text=my button").click()
self.page.locator("text=my button").click()
assert self.console.log.lines[-2:] == ["clicked!", "clicked!"]
def test_deprecated_element(self):
self.pyscript_run(
"""
import js
def on_click(evt):
js.console.log('clicked!')
"""
)
banner = self.page.locator(".py-warning")
banner_content = banner.inner_text()
expected = (
"The element is deprecated, create a function with your "
'inline code and use