Skip to content

Commit

Permalink
Added E2E Test for Exceptions lecture(TWP54)
Browse files Browse the repository at this point in the history
  • Loading branch information
its-ChaTTy committed Mar 10, 2024
1 parent 64f9da8 commit 0b58c0e
Showing 1 changed file with 74 additions and 0 deletions.
74 changes: 74 additions & 0 deletions tests/test_TWP54.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
def test_TWPl54_1(page):
page.goto("lectures/TWP54/TWP54_3_en.html")

# Run the exercise
page.click("#ac_l54_3a_en >> *css=button >> text=Run")

# Wait for the iframe to load
page.wait_for_selector('iframe')

# Get the iframe
frame = page.frame(url="about:srcdoc")

# Check if the iframe was found
if frame is None:
raise Exception("Could not find iframe")

page.frame(url="about:srcdoc").click("input")
# Fill input
page.frame(url="about:srcdoc").fill("input", "Lisbon")
# Click :nth-match(input, 2)
page.frame(url="about:srcdoc").click(":nth-match(input, 2)")
# Fill :nth-match(input, 2)
page.frame(url="about:srcdoc").fill(":nth-match(input, 2)", "Great Place!")
# Click :nth-match(input, 3)
page.frame(url="about:srcdoc").click(":nth-match(input, 3)")
# Fill :nth-match(input, 3)
page.frame(url="about:srcdoc").fill(":nth-match(input, 3)", "Wall Street")
# Click text=Save
page.frame(url="about:srcdoc").click("text=Save")
# Click :nth-match(input, 3)
page.frame(url="about:srcdoc").click(":nth-match(input, 3)")
# Fill :nth-match(input, 3)
page.frame(url="about:srcdoc").fill(":nth-match(input, 3)", "")
# Click text=Save
page.once("dialog", lambda dialog: dialog.dismiss())
page.frame(url="about:srcdoc").click("text=Save")

def test_TWPl54_2(page):
page.goto("lectures/TWP54/TWP54_3.html")

# Run the exercise
page.click("#ac_l54_3a >> *css=button >> text=Run")

# Wait for the iframe to load
page.wait_for_selector('iframe')

# Get the iframe
frame = page.frame(url="about:srcdoc")

# Check if the iframe was found
if frame is None:
raise Exception("Could not find iframe")

page.frame(url="about:srcdoc").click("input")
# Fill input
page.frame(url="about:srcdoc").fill("input", "Lisbon")
# Click :nth-match(input, 2)
page.frame(url="about:srcdoc").click(":nth-match(input, 2)")
# Fill :nth-match(input, 2)
page.frame(url="about:srcdoc").fill(":nth-match(input, 2)", "Great Place!")
# Click :nth-match(input, 3)
page.frame(url="about:srcdoc").click(":nth-match(input, 3)")
# Fill :nth-match(input, 3)
page.frame(url="about:srcdoc").fill(":nth-match(input, 3)", "Wall Street")
# Click text=Save
page.frame(url="about:srcdoc").click("text=Guardar")
# Click :nth-match(input, 3)
page.frame(url="about:srcdoc").click(":nth-match(input, 3)")
# Fill :nth-match(input, 3)
page.frame(url="about:srcdoc").fill(":nth-match(input, 3)", "")
# Click text=Save
page.once("dialog", lambda dialog: dialog.dismiss())
page.frame(url="about:srcdoc").click("text=Guardar")

0 comments on commit 0b58c0e

Please sign in to comment.