samedi 5 décembre 2020

Convetion of test functions in Selenium with Python

I want to test an internal web application and I want the code (Selenium & Python) to be well-organized and clean. I have a question of what is the convetion of writing test functions, for example:

def test_access accesing the web portal and checking if the page loads def test_login acessing the web portal and checking if the page loads and then if login succeeds.

In the above example I have 2 functions and the test_login function is test_access function plus checking if login succeeds.

  1. In that case is it correct in test code to do something like this:
def test_access:
     # do sth 

def test login:
    test_access()
    #check if login succeeds
  1. Or should be every test function be written without invoking the previous test function? Or is it correct to repeat the code within test functions?

  2. What if the test funtion that I want to implement consists of accessing the web portal, logging in, then checking every attribute of the page after the login. In that case should be it one function doing all this actions or should it be chunked into more but smaller functions?

Aucun commentaire:

Enregistrer un commentaire