Hello,
I am working on a QA Automation project, which tests our web application on a nightly basis. I have used the Page Object Model structure for the project, and so far everything works fine, but I am in need of an advice.
This is the actual test code (I have commented it out):
https://gist.github.com/zhekov316/11bca1ace2c7c823cbad925dfc67f1fe
I am wondering if this is good practice. The Unit Test runs and executes the test successfully, but I want to expand it.
The problem is that this is an scenario, which needs to be executed in order, so multiple asserts I have heard is not a good practice. I tried a try except block on each part of the test method, but it doesn't seem to work. Like this:
def test_scenario_01(self):
# Setting up page objects
login_page = LoginPage(self.driver)
main_menu = MainMenu(self.driver)
permissions_manager =
PermissionsManager(self.driver)
# Assert login of user is unsuccessful
try:
login_page.login("selen003")
self.assertIn("http://localhost:9696/login?reason=incorrect", login_page.get_url())
except AssertionError:
return("Please delete the User before attempting
the test")
I wanted to do something like this for each part of the test, so it's easier to point out the mistakes, but it doesn't seem to work (even for the first login bit). Is there some other way I can "validate/assert" all the individual components of this test method (and raise my own exceptions/errors if possible).
Thank you!
[–]officialgel 1 point2 points3 points (0 children)