Created
July 5, 2024 12:56
-
-
Save SarahElson/4fc93f92d3384993fc73824f913f8f52 to your computer and use it in GitHub Desktop.
Python Unit Testing: A Complete Tutorial
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import unittest | |
import HtmlTestRunner | |
import sys | |
sys.path.append(sys.path[0] + "/..") | |
from setup.setup import testSet | |
from locators.formLocators import formWebAction | |
set_up = testSet() | |
form = formWebAction(set_up.driver) | |
class formSampleTest(unittest.TestCase): | |
def test_unit_user_should_able_to_fill_form(self): | |
try: | |
form.getWeb("https://www.lambdatest.com/selenium-playground/input-form-demo") | |
set_up.testSetup() | |
title = form.getTitle() | |
self.assertIn("Selenium", title, "Selenium is not in title") | |
form.fillName("Idowu") | |
form.fillEmail("[email protected]") | |
form.fillPassword("secret") | |
form.fillCompany("Lambdatest") | |
form.fillWebsite("someweb.com") | |
form.fillCountry("Nigeria") | |
form.fillCity("A City") | |
form.fillAddress1("Den street") | |
form.fillAddress2("Den street") | |
form.fillState("Lagos") | |
form.fillZipCode("240100") | |
form.submit() | |
except AssertionError as e: | |
print("Something went wrong", e) | |
set_up.tearDown() | |
if __name__ == "__main__": | |
unittest.main(testRunner=HtmlTestRunner.HTMLTestRunner(output='DemoFormHTML_results')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment