DEV Community

Cover image for Write your first test in Selenium Python
Dilpreet Johal
Dilpreet Johal

Posted on

Write your first test in Selenium Python

Let’s take a look at how to write your first browser test in Python using the SeleniumBase framework. You can check out my article here to learn more about the SeleniumBase framework.

⚙️ Setup & Installation

First off, we need to install the necessary packages and dependencies to set up our project. Here’s what we need to install:

  • Python3
  • SeleniumBase framework
  • Chromedriver (can be installed using SeleniumBase)

Check out my video below to see how to set up the project in PyCharm and install all the above packages –

✍️ Write your first test

Once all the packages have been installed, we can get started with writing our first test.

Scenario: Open the home page of the test website and assert the title and the logo.

Selenium Python Test

🏃 Run tests in SeleniumBase

SeleniumBase relies on pytest as its test runner. So, just the way you would run tests in pytest, you can do the same in SeleniumBase also. Simply run the pytest command and it will start running your tests.

Once completed, you will see the results in a terminal similar to this –

pytest test runner results

Check out the video below to see how to write your first test in Selenium Python –

📧 Subscribe to my mailing list to get access to more content like this
👍 Follow automationbro on Twitter for the latest updates


I love coffees! And, if this post helped you out and you would like to support my work, you can do that by clicking on the button below and buying me a cup of coffee -

Buy me a coffee

You can also support me by liking and sharing this content.

Thanks for reading!

Discussion (0)