Only three lines in this code are highlighted with an *, but here’s what they mean:
First line:
class Iframe(unittest.TestCase):
This is declaring the class for the functions (test_Iframe and tearDown) that follow. A class is used to create “objects” in object oriented programming. Think of the class as the abstraction of data/procedures, while the object is the particular instance of the class.
Next line:
def tearDown(self):
self.driver.quit()
This section first declares a function with the def
keyword, and the function quits the driver, which was set as:
driver = self.driver
driver.maximize_window()
driver.get('http://www.toolsqa.com/iframe-practice-page/')
in the test_Iframe()
function.
Final line:
if __name__ == '__main__':
unittest.main()
This section simply executes the main function of the program. More details on this can be found here.
Let me know if you have any more questions!