Automation testing using selenium and python

  • I am new to automation testing. I am learning from last 2 months. My company needs a program to check multiple URLs and perform tests on them to see if the sites are working or not. If not working, then a report should be generated and an email should be sent to all with the report. I made a program to browse multiple URLS and also to should an email using SMTP. But the issue is that, I am unable to use the same code to login to multiple URLS. Also, I need to send no-reply email. I am unable to do so. Please help me if anyone is aware of it. I am using selenium and python language for my program.

  • With Python you could use subTest() to create a single unit tests which loops over multiple inputs.

    def test_login_multiple_urls(self):
        # setup driver here
        urls = ["", "", ""]
        for url in urls:
            with self.subTest(url=url):
                # more setup
                # some actions to test
                # some assert

    For sending as emails as no-reply define the FROM field to a mail address:

    msg = EmailMessage()
    msg['Subject'] = 'Test results'
    msg['From'] = ''

    Read more in the Python email documentation:

Log in to reply

Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2