44
loading...
This website collects cookies to deliver better user experience
pip install screenpy
python -m screenpy-quickstart.py
\test_suite_folder
\features #this is where the actual test files will live
+ feature1.py
+ ...
\user_interface # files containing locators and/or URLs for each page
+page1.py
+ ...
from screenpy.actor import Actor, AnActor
from selenium.webdriver import Firefox
from screenpy.abilities import BrowseTheWeb
Anton = AnActor.named("Anton").who_can(BrowseTheWeb.using(Firefox()))
from screenpy import Target
from screenpy.actions import Click
#the string to use as a locator for the element can be a CSS selector or an xpath string
GOOGLE_LINK = Target.the("http://www.google.com").located_by("css select")
Anton.attempts_to(Click.the(GOOGLE_LINK))
from screenpy.questions import Text
from screenpy.resolutions import ReadsExactly
GOOGLE_MESSAGE = Target.the("google_message").located_by("div:nth-of-type(1) > .rc .st")
Anton.should_see_the((Text.of(GOOGLE_MESSAGE), ReadsExactly("Test"))
/feature/test_iframe.py
import unittest
from screenpy import AnActor, given, then, when
from screenpy.abilities import BrowseTheWeb
from screenpy.actions import Open, SwitchTo
from screenpy.pacing import act, scene
from screenpy.questions import Text
from screenpy.resolutions import ReadsExactly
from tasks import start
from user_interface.iframe import CONTENT, URLI, IFRAME
class TestFrames(unittest.TestCase):
def setUp(self):
self.actor = AnActor.named("Anton").who_can (BrowseTheWeb.using_firefox())
@act("Perform")
@scene("SwitchTo")
def test_switch_to_iframe(self):
Anton = self.actor
given(Anton).attempts_to(Open.their_browser_on(URL))
when(Anton).attempts_to(SwitchTo.the(IFRAME))
then(Anton).should_see_the(
(Text.of_the(CONTENT_BOX), ReadsExactly("Your content goes here."))
)
def tearDown(self):
self.actor.exit()
/user_interface/iframe.py
# Locators and URL for the Iframe page.
from screenpy import Target
URLI = "http://the-internet.herokuapp.com/iframe"
IFRAME = Target.the("Iframe").located_by("#mce_0_ifr")
CONTENT = Target.the("The content box").located_by("p")