Articles | July 12, 2023

Automated tests: Selenium + Python vs Selenium + Java

The world of IT and QA is changing rapidly, and the popularity of some of the tools is passing. Which choose? Read the article and learn about the advantages and disadvantages of combining Selenium with two of the most popular programming languages today: Java and Python.

Automated tests: Selenium + Python vs Selenium + Java

As a (future) TAE (Test Automation Engineer) focusing on Selenium, you may get to the point where you need to make a decision on which way you go and what tools and languages you are going to use for testing. Life changes rapidly in the IT and QA world and some of the ones that were popular in the past are not attractive any more. As usual, there are probably a number of different factors that could play a role in making such a decision for you. In this article I will try to help you with that by briefly showcasing the pros and cons of using Selenium with two of the most popular languages nowadays: Java and Python.

Java and Python  

Each of them is well-established, platform-independent, object-oriented and part of a large, supportive community. When it comes to selecting Selenium language bindings (read Java or Python here), you should first understand some key differences between them. 

Selenium supports a wide range of programming languages for test automation. Java and Python are the top choices for binding with Selenium in this context. 

A programming language or a scripting language? 

One of the main questions that could come to mind when comparing Java and Python could be: is Python/Java a programming language or a scripting language? 

Basically, all scripting languages are considered to be programming languages. The main difference between them is that programming languages are compiled, whereas scripting languages are interpreted. Scripting languages are slower than programming languages and usually sit behind them. 

You can find a brief comparison in the link below: Interpreter vs compiler  

Python 

Python can be called a scripting language as well as a programming language since it works both as a compiler and an interpreter. Standard Python can compile Python code into bytecodes and then interpret it just like Java and C. 

“However, considering the historical relationship between the general-purpose programming language and the scripting language, it would be more appropriate to say that Python is a programming language that works nicely as a scripting language too”. 

An interpreter is a layer of software that works as a bridge between the program and the system hardware to keep the code running. The Python interpreter is an application that is responsible for running Python scripts. 

nearshore 2023.11.xx graphic 1 4

Java 

Java is generally faster and more efficient than Python because it is a compiled language. As an interpreted language, Python has simpler, more concise syntax than Java. It can perform the same function as Java in fewer lines of code. In Java, the data types of variables should be declared before using them, unlike for Python. You can then decide what appeals more to you here. 

nearshore 2023.11.xx graphic 2 1 1

What is easier to learn: Java or Python?  

Another question you may have, especially when you are new to programming, is: how quickly can you learn Java vs Python? 

And there is no doubt here that Python is the winner. As mentioned above, its syntax is shorter and easier to digest. Java has more complex prototyping; for example, it burdens your code with additional declarations and restrictions. 

Choose Python then if you have a short ramp-up period in which to learn. 

The list of key factors to take into consideration before making a decision: 

  • Job opportunities: still more jobs for Java. 
  • Job changes / migrations: thanks to scripting, it’s easier for Python if you switch to, for example, DevOps. 
  • Object oriented: both Python and Java rely on object programming so if you know one of them, you have a good starting point for the other. 
  • Platform independent: both Python and Java binaries (bytecodes), once generated, can be executed on any supported platforms thanks to their own virtual machines (PVM and JVM respectively). 
  • Simplicity: Python is easier to use thanks to its simpler syntax.  
  • Execution: as a scripting language, Python has the ability to run your script code directly using its interpreter instead of directly running a compiler (like Javac for Java). 
  • Performance / execution speed: Java has the advantage here as it is faster (can be JIT-compiled to be more efficient). 
  • Popularity / support: Java wins out here, as solutions based on Java are more popular and it has a very large supporting community. 
  • Python is a statically typed language (performs type checking at runtime, meaning you can have a code that fails at the very last moment of execution). 
  • Java is a dynamically typed language (performs type checking at compile time, meaning that you catch problems in your code earlier in the development process). 
  • Extendibility: since Java is more popular, more plugins, APIs, frameworks and libraries are available on the market than for Python. 

Test automation – what options do you have? 

Selenium satisfies a specific need in the test automation world. It is only for browsers. If you want to quickly start automating your test cases, Selenium IDE is your friend here, as it allows you to rapidly start automating tests.  

The test steps you perform in a browser are directly transformed into a set of commands thanks to Selenese, which is Selenium IDE’s built-in language. It is very simple. Moreover, after storing your tests in a set of Selenese commands, you can aggregate them into test suites and finally export to your preferred Selenium bindings (e.g., Java, Python, etc.). 

Selenese and Selenium IDE is a good start, but the more you dig into the subject of web application automation, the more you see its constraints. 

To properly test a modern web application with its dynamically changed content (e.g., using AJAX or JS technologies) you are going to need to start looking for some more advanced options. That’s where Selenium WebDriver comes in, along with its Selenium-specific language bindings. Selenium WebDriver is often used as a basis for testing web applications.  

According to the A4Q Selenium 4 Tester syllabus: 

„Selenium, when used for testing web applications, needs some testing frameworks. The Selenium engine, as a standalone tool, only exposes its native APIs as methods or functions to the TAE. The TAE must then program a testing framework to use these APIs to carry out the tests required. A testing framework can be conceived from scratch or existing frameworks could be used. The Selenium project supports multiple testing frameworks in diverse languages” such as:  

Whether you use your own testing framework or not, you need to drive your test execution somehow. Many TAEs use some unit test libraries to drive their tests (test runners). 

Some of them like TestNG or Pytest allow you to create higher-level functional tests apart from its primary unit testing use (functional, component, integration, end-to-end etc.). 

Read also: User Acceptance Testing (UAT) – Why is it important?

For Python 

The simplest case is to use Python’s standard unit test library, or alternatively you can use the highly popular Pytest.  

For Java 

You may use xUnit libraries (e.g., JUnit 4/5) or TestNG.  

Once you are familiar with running tests locally using your chosen browser, you may take a step forward and set up your grid of browsers to run tests remotely. 

This way, your tests can be run on different browsers and multiple operating systems across a range of machines in parallel mode. If your configuration is large, you could run your regression testing in a fraction of the time it would take without Selenium Grid. 

Later, you can go even further and integrate your tests into the CI/CD pipeline (e.g., running Selenium Tests in GitLab CI/CD or Jenkins). 

Please note that you could take advantage of containerization techniques like Docker to create various images for automated UI tests. 

By doing this, you could prepare a separate VM for any combination of your OS / browser environment for your SUT (System Under Test) / AUT (Application Under Test). 

CI/CD has been pivotal in setting up software development lifecycles, where new features are constantly updated at maximum levels of speed and efficiency. This allows end-users to access new features without the need to download software updates, offering them a seamless experience.  

Given the short span of the release cycle, testing has to be scaled to deliver bug-free software in the allocated timeframe. This is where Selenium plays a pivotal role by providing test automation in the CI/CD pipeline. 

Thanks to Selenium automation testing, parallel tests can be performed at the required scale, while Docker helps maintain the sanity of the test environment with its ephemeral containers. 

What is Selenium WebDriver? 

The most comprehensive source of knowledge to help answer this question can be found on the Selenium WebDriver page:  

„Selenium WebDriver refers to both the language bindings and the implementations of the individual browser controlling code. This is commonly referred to as just WebDriver.” 

or directly from the A4Q syllabus:  

„Selenium WebDriver, as the name suggests, interacts with the browser in the same way that a real user would. WebDriver is an end-to-end test compilation tool for web applications that is also frequently referred to as „Selenium WebDriver”. 

From a Selenium architectural point of view, all the components are visualized in the official documentation page. 

We can say that WebDriver helps us to mimic user / browser interactions; hence, it is extremely helpful in terms of test automation. WebDriver controls a browser using browser specific drivers which are usually created by their vendors (e.g., Google for Chrome or Mozilla for Firefox). 

All the communication is 2-way and is compliant with the following protocols: 

Thanks to W3C Protocol introduced in Selenium 4, we have a direct transfer of information between client and server. So, if you are still using Selenium 3 (WebDriver) and are hesitant to upgrade, consider checking the following page: Upgrade to Selenium 4. 

The minimum versions required are Java version 8 and Python version 3.7. 

Selenium and Python 

If you decide to go this way but don’t yet have the requisite knowledge, then try to play with Selenium IDE and generate your Python code using its export function.  

Once you are more familiar with Selenium IDE, you can then prepare your full Selenium / Python test automation development environment. 

What you need: 

*Selenium Manager is available starting from version 4.6 (Beta) 

Selenium and Java 

If you decided to go this way but don’t yet have the requisite knowledge, then try to play with the Selenium IDE plugin for Chrome or Firefox and generate your Java code using its export function. 

Once you are more familiar with it, you can then prepare your full Selenium / Java test automation development environment. 

What you need: 

*Selenium Manager is available starting from version 4.6 (Beta) 

What is a better option for automated tests – Selenium with Python or Selenium with Java?  

If you are a complete beginner when it comes to test automation with Selenium and maybe to programming too (whether it is Java or Python), I suggest that you start by using Selenium IDE, which is provided in the form of an add-on for Chrome, Firefox and Edge (version 3.x). It allows you to generate your Java / Python code using its export function. It is very straightforward, as you simply record your actions in a browser. Code is generated for you afterwards by exporting to your favorite language function. At the time of writing (June 2023), it was even possible to download a standalone version (4 alpha) of Selenium IDE for several platforms (e.g., Windows, MacOS). Find out more about Selenium’s latest releases. 

From the point of view of automation, and especially CI/CD integration, it looks like a combination of Selenium and Java is better suited here. It blends in well with this process thanks to very good integration with tools like Jenkins/Maven/Gradle. 

This doesn’t mean that you can’t achieve this with Python, albeit it would be more tiresome and some plugins would be necessary. But once again, Python provides simple coding and readability, so if you don’t have a background in Java/Python programming, you may be tempted to use Python. 

One of the most important points in the Selenium test automation development process is related to test debugging. Many browsers provide “DevTools” – a set of tools that are integrated with the browser that developers can use to debug web apps and explore the performance of their pages. 

The first thing that comes to mind in any case is Chrome DevTools based on Chrome DevTools Protocol (CDP): 

which is probably most commonly used and integrated with Selenium 4 itself. It helps you inspect, test and verify your selectors. As selectors are generic and language independent, it has universal usage. Another thing that is useful for debugging your Selenium test code is breakpoints in your favorite IDE. Set it anywhere you seem to have a problem and your test stops in the browser at that moment. Now you can continue debugging using your browser’s DevTools such as Chrome DevTools. 

This works both for Java (e.g., IDEA) and Python (e.g., PyCharm). But there is one thing for Python that is very interesting for debugging too. It is called PDB (The Python Debugger) and it is one of the best debugging techniques for Selenium. 

This Python module gives you an interactive source code debugging option. To see how useful it could be, look at the example below: 

C:\Users\user> py 
Python 3.11.4 (tags/v3.11.4:d2340ef, Jun 7 2023, 05:45:37) [MSC v.1934 64 bit (AMD64)] on win32 
Type "help", "copyright", "credits" or "license" for more information. 
>>> from selenium import webdriver 
>>> from selenium.webdriver.common.by import By 
>>> import pdb 
>>> if __name__ == '__main__': 
...   print('Hello World!') 
...   browser = webdriver.Chrome() 
...   browser.get('http://selenium.dev/') 
...   web_driver_selector = "div.selenium-button-container a.selenium-webdriver" 
...   web_driver_link = browser.find_element(By.CSS_SELECTOR, web_driver_selector) 
...   pdb.set_trace() 
...   browser.quit() 
... 
Hello World! 

and now when your browser is stopped at the breakpoint set on the http://selenium.dev/ page, you can check the web_driver_link: 

(Pdb) dir 
<built-in function dir> 
(Pdb) dir(web_driver_link) 
['__abstractmethods__', '__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getstate__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_abc_impl', '_execute', '_id', '_parent', '_upload', 'accessible_name', 'aria_role', 'clear', 'click', 'find_element', 'find_elements', 'get_attribute', 'get_dom_attribute', 'get_property', 'id', 'is_displayed', 'is_enabled', 'is_selected', 'location', 'location_once_scrolled_into_view', 'parent', 'rect', 'screenshot', 'screenshot_as_base64', 'screenshot_as_png', 'send_keys', 'shadow_root', 'size', 'submit', 'tag_name', 'text', 'value_of_css_property'] 

As you can see above, pdb gives you the opportunity to inspect your object and what you can do with it using dir command, for example: 

(Pdb) web_driver_link.is_displayed() 
True 
(Pdb) web_driver_link.is_enabled() 
True 
(Pdb) web_driver_link.is_selected() 
False 
(Pdb) web_driver_link.text 
'READ MORE' 
(Pdb) web_driver_link.get_property('href') 
'https://www.selenium.dev/documentation/webdriver/' 
(Pdb) web_driver_link.get_dom_attribute('class') 
'selenium-button selenium-webdriver text-uppercase font-weight-bold' 
(Pdb) web_driver_link.get_attribute('class') 
'selenium-button selenium-webdriver text-uppercase font-weight-bold' 
(Pdb) web_driver_link.get_dom_attribute 
<bound method WebElement.get_dom_attribute of <selenium.webdriver.remote.webelement.WebElement (session="b51ad53a899388ec9293d83fd0750a98", element="E97FE72B561D59DFF64B6C8846C4CC17_element_31")>> 
(Pdb) web_driver_link.id 
'E97FE72B561D59DFF64B6C8846C4CC17_element_31' 
(Pdb) web_driver_link.__class__ 
<class 'selenium.webdriver.remote.webelement.WebElement'> 
(Pdb) web_driver_link.value_of_css_property 
<bound method WebElement.value_of_css_property of <selenium.webdriver.remote.webelement.WebElement (session="b51ad53a899388ec9293d83fd0750a98", element="E97FE72B561D59DFF64B6C8846C4CC17_element_31")>> 
(Pdb) web_driver_link.value_of_css_property('color') 
'rgba(200, 16, 46, 1)' 
(Pdb) 

This could also be one of the arguments in Python’s favor. You may even extend it to include an ipdb add-on that improves the experience of the pdb debugger:  

ipdb Debug Mode adds color-coded syntax highlighting, tab-completion, and an expanded view of the code with line numbers. ipdb must be installed separately from pytest before use: 

pip install ipdb  

What is Selenium with Python for? 

This blend of technologies is meant for testing front end web applications. It helps to leverage your tedious and repeatable GUI actions or tests and replace them with automated scripts. By doing so, you can integrate them further with CI/CD tools for nightly regression testing, for example. If I were to answer this in only one sentence I would say: 

Selenium + Python is basically for web application test automation. 

Selenium (WebDriver) is responsible for 2-way client-server communication between you and the browser. Python and its Python Selenium bindings wrap everything in executable code driven by testing frameworks like xUnit / TestNG. 

Is Selenium with Python a good choice? 

I would say that the answer to this question depends on many factors. Each of us is different and has our own experience, skills and ability to learn. The final answer to this question will be specific to you. The aim of this article is to help you find it. Read the article and analyze it along with your professional objectives, your past, present and future, as it could indeed be your best choice. 

How to execute Selenium script in Python? 

In Python, we can distinguish 2 main types of Python files: 

  • .py files are human readable text files with Python code inside, called Python scripts (on Windows systems the extension can also be .pyw). 
  • .pyc files are compiled bytecode files that are generated by the Python interpreter when a Python script is imported or executed. 

Python files are saved on the user machine with the file extension “.py” as Java files are saved with .java extensions. Python codes are then converted to bytecodes after being interpreted. These bytecodes are saved in files with the extension “.pyc”.  

The “__pycache__” directory is the folder created to store the “.pyc” files. 

Think of a .pyc file as a compiled bytecode, similar to a .class file in the JAVA world. 

As soon as you generate it, it can be directly executed by the interpreter without recompiling a .py script file each time you use it. By doing so, you speed up the execution, which is important when you have large python scripts and/or modules. 

To sum up: 

  • .pyc files are generated automatically by the Python interpreter when a Python script is imported or executed. 
  • .pyc files are stored in the same directory as the corresponding .py files, and have the same name as the .py files, except with a .pyc extension instead of .py. 
  • .pyc files are specific to the version of Python that was used to generate them. If you try to run a .pyc file with a different version of Python, you may encounter errors or unexpected behavior. 

If you want to run a Python script, you have 2 options: 

  1.  run Python Script with the Python Interpreter using Interactive mode (in the form of a piece of code written in an interactive session – useful for debugging). 

python 

e.g., typing your code line by line: 
C:\Users\user> py 
Python 3.11.4 (tags/v3.11.4:d2340ef, Jun 7 2023, 05:45:37) [MSC v.1934 64 bit (AMD64)] on win32 
Type "help", "copyright", "credits" or "license" for more information. 
>>> from selenium import webdriver 
>>> if __name__ == '__main__': 
...   print('Hello World!') 
...   browser = webdriver.Chrome() 
...   browser.get('http://selenium.dev/') 
...   browser.quit() 
... 
Hello World! 
  
DevTools listening on ws://127.0.0.1:56302/devtools/browser/fdca3cc9-4266-49af-a146-41d60ed464eb 
>>> exit() 
  
C:\Users\user> 

or using exec() which provides an alternative way of running your scripts: 

C:\Users\user> py 
Python 3.11.4 (tags/v3.11.4:d2340ef, Jun 7 2023, 05:45:37) [MSC v.1934 64 bit (AMD64)] on win32 
Type "help", "copyright", "credits" or "license" for more information. 
>>> exec(open('your_script.py').read()) 
Hello World! 
>>> 
>>> quit() 
  
C:\Users\user> 

A Python interactive mode session allows you to write many lines of code, but once you close the session, you lose everything you’ve written.  

That’s why the usual way of writing Python programs is by using plain text files. The file with the Python code must be located in your current working directory. The file must be in the Python Module Search Path (PMSP), where Python looks for the modules and packages you import. 

2) run Python Script using Command-Line (in the form of a script or module – useful for automation) 

python your_script.py 
  
e.g.: 
C:\Users\user> py your_script.py 
Hello World! 

or even more simply, by using Windows file associations and providing just a script name: 

C:\Users\user> your_script.py 
Hello World! 

In GNU/Linux systems you can achieve a similar outcome by adding a so-called hashbang or shebang to your script, which is the character combination #! followed by the interpreter path. 

There are two ways to specify the path to the interpreter: 

  • #!/usr/bin/python: writing the absolute path. 
  • #!/usr/bin/env python: using the operating system env command, which locates and executes Python by searching the PATH environment variable. 

As not all Unix-like systems locate the Python interpreter at the same location, the second flavor of path given above looks more universal. 

You need to add execution permission as well: 

#assign the execution permissions 
chmod +x your_script.py 
#run script using its filename 
./your_script.py 
Hello World! 

You can run your bytecode-generated script directly as well: 

C:\Users\user> dir your_script.py 
Volume in drive C is Windows 
Volume Serial Number is 94D2-9546 
  
Directory of C:\Users\user 
  
15-Jun-23 14:02        544 your_script.py 
        1 File(s)      544 bytes 
        0 Dir(s) 194,664,701,952 bytes free 
  
C:\Users\user> cd __pycache__ 
  
C:\Users\user\__pycache__> dir your_script.cpython-311.pyc 
Volume in drive C is Windows 
Volume Serial Number is 94D2-9546 
  
Directory of C:\Users\user\__pycache__ 
  
15-Jun-23 14:06        401 your_script.cpython-311.pyc 
        1 File(s)      401 bytes 
        0 Dir(s) 194,664,546,304 bytes free 
  
C:\Users\user\__pycache__> your_script.cpython-311.pyc 
Hello World! 
  
C:\Users\user\__pycache__> 

How to install Selenium with PIP? 

  • install Python (manually or using IDE) 

Go to Python.org and get the suitable version

py –version

Python 3.N.N

e.g. for WIN (CMD):

C:\Users\user> py --version 
Python 3.11.4 
  
C:\Users\user> 

What is PIP? 

PIP is the package installer for Python. You can use it to install packages from the Python Package Index and other indexes. The most popular tool for installing Python packages, and the one included with modern versions of Python.  

It provides the essential core features for finding, downloading, and installing packages from other Python package indexes, and can be incorporated into a wide range of development workflows via its command-line interface (CLI). 

py -m pip –version

pip X.Y.Z from … (python 3.N.N)


e.g., for WIN (CMD): 

C:\Users\user> py -m pip --version 
pip 23.1.2 from C:\Program Files\Python311\Lib\site-packages\pip (python 3.11) 
  
C:\Users\user> 

e.g., for WIN (IDE): 

(venv) PS C:\Users\user\PycharmProjects\pythonSelenium> py -m pip list 
 
 
setuptools 65.5.1 
wheel   0.38.4 
  
[notice] A new release of pip available: 22.3.1 -> 23.1.2 
[notice] To update, run: python.exe -m pip install --upgrade pip 
(venv) PS C:\Users\user\PycharmProjects\pythonSelenium> py -m pip --version 
pip 22.3.1 from C:\Users\user\PycharmProjects\pythonSelenium\venv\Lib\site-packages\pip (python 3.11) 
(venv) PS C:\Users\user\PycharmProjects\pythonSelenium> python.exe -m pip install --upgrade pip 
Requirement already satisfied: pip in c:\users\user\pycharmprojects\pythonselenium\venv\lib\site-packages (22.3.1) 
Collecting pip 
 Downloading pip-23.1.2-py3-none-any.whl (2.1 MB) 
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.1/2.1 MB 2.7 MB/s eta 0:00:00 
Installing collected packages: pip 
 Attempting uninstall: pip 
  Found existing installation: pip 22.3.1 
  Uninstalling pip-22.3.1: 
   Successfully uninstalled pip-22.3.1 
Successfully installed pip-23.1.2 
(venv) PS C:\Users\user\PycharmProjects\pythonSelenium>  
(venv) PS C:\Users\user\PycharmProjects\pythonSelenium> py -m pip --version 
pip 23.1.2 from C:\Users\user\PycharmProjects\pythonSelenium\venv\Lib\site-packages\pip (python 3.11) 
(venv) PS C:\Users\user\PycharmProjects\pythonSelenium>  
(venv) PS C:\Users\user\PycharmProjects\pythonSelenium> py -m pip list 
Package  Version 
---------- ------- 
pip    23.1.2 
setuptools 65.5.1 
wheel   0.38.4 
(venv) PS C:\Users\user\PycharmProjects\pythonSelenium>  

If that worked, congratulations! You have a working PIP in your environment. 

Verify the supported Python version (as of Selenium 4.10.0): 

pip install selenium 
pip install -U selenium 

If you have PIP on your system, you can simply install or upgrade the Python bindings: 

pip install selenium==<version_number> 

If you want the specific Selenium python bindings version: 

pip install selenium==<version_number> 

Alternately, you can download the source distribution from PyPI (e.g. selenium-4.10.0.tar.gz), unarchive it, and run: 

py setup.py install

e.g. for WIN (CMD):

C:\Users\user> py -m pip list 
Package  Version 
---------- ------- 
pip    23.1.2 
setuptools 65.5.0 
  
C:\Users\user> 
C:\Users\user> py -m pip install selenium 
Defaulting to user installation because normal site-packages is not writeable 
Collecting selenium 
 Downloading selenium-4.10.0-py3-none-any.whl (6.7 MB) 
   ---------------------------------------- 6.7/6.7 MB 23.7 MB/s eta 0:00:00 
Collecting urllib3[socks]<3,>=1.26 (from selenium) 
 Downloading urllib3-2.0.3-py3-none-any.whl (123 kB) 
   ---------------------------------------- 123.6/123.6 kB ? eta 0:00:00 
Collecting trio~=0.17 (from selenium) 
 Downloading trio-0.22.0-py3-none-any.whl (384 kB) 
   ---------------------------------------- 384.9/384.9 kB 25.0 MB/s eta 0:00:00 
Collecting trio-websocket~=0.9 (from selenium) 
 Downloading trio_websocket-0.10.3-py3-none-any.whl (17 kB) 
Collecting certifi>=2021.10.8 (from selenium) 
 Downloading certifi-2023.5.7-py3-none-any.whl (156 kB) 
   ---------------------------------------- 157.0/157.0 kB 9.2 MB/s eta 0:00:00 
Collecting attrs>=19.2.0 (from trio~=0.17->selenium) 
 Downloading attrs-23.1.0-py3-none-any.whl (61 kB) 
   ---------------------------------------- 61.2/61.2 kB 3.2 MB/s eta 0:00:00 
Collecting sortedcontainers (from trio~=0.17->selenium) 
 Downloading sortedcontainers-2.4.0-py2.py3-none-any.whl (29 kB) 
Collecting async-generator>=1.9 (from trio~=0.17->selenium) 
 Downloading async_generator-1.10-py3-none-any.whl (18 kB) 
Collecting idna (from trio~=0.17->selenium) 
 Downloading idna-3.4-py3-none-any.whl (61 kB) 
   ---------------------------------------- 61.5/61.5 kB 3.2 MB/s eta 0:00:00 
Collecting outcome (from trio~=0.17->selenium) 
 Downloading outcome-1.2.0-py2.py3-none-any.whl (9.7 kB) 
Collecting sniffio (from trio~=0.17->selenium) 
 Downloading sniffio-1.3.0-py3-none-any.whl (10 kB) 
Collecting cffi>=1.14 (from trio~=0.17->selenium) 
 Downloading cffi-1.15.1-cp311-cp311-win_amd64.whl (179 kB) 
   ---------------------------------------- 179.0/179.0 kB ? eta 0:00:00 
Collecting exceptiongroup (from trio-websocket~=0.9->selenium) 
 Downloading exceptiongroup-1.1.1-py3-none-any.whl (14 kB) 
Collecting wsproto>=0.14 (from trio-websocket~=0.9->selenium) 
 Downloading wsproto-1.2.0-py3-none-any.whl (24 kB) 
Collecting pysocks!=1.5.7,<2.0,>=1.5.6 (from urllib3[socks]<3,>=1.26->selenium) 
 Downloading PySocks-1.7.1-py3-none-any.whl (16 kB) 
Collecting pycparser (from cffi>=1.14->trio~=0.17->selenium) 
 Downloading pycparser-2.21-py2.py3-none-any.whl (118 kB) 
   ---------------------------------------- 118.7/118.7 kB ? eta 0:00:00 
Collecting h11<1,>=0.9.0 (from wsproto>=0.14->trio-websocket~=0.9->selenium) 
 Downloading h11-0.14.0-py3-none-any.whl (58 kB) 
   ---------------------------------------- 58.3/58.3 kB ? eta 0:00:00 
Installing collected packages: sortedcontainers, urllib3, sniffio, pysocks, pycparser, idna, h11, exceptiongroup, certifi, attrs, async-generator, wsproto, outcome, cffi, trio, trio-websocket, selenium 
Successfully installed async-generator-1.10 attrs-23.1.0 certifi-2023.5.7 cffi-1.15.1 exceptiongroup-1.1.1 h11-0.14.0 idna-3.4 outcome-1.2.0 pycparser-2.21 pysocks-1.7.1 selenium-4.10.0 sniffio-1.3.0 sortedcontainers-2.4.0 trio-0.22.0 trio-websocket-0.10.3 urllib3-2.0.3 wsproto-1.2.0 
  
C:\Users\user> 
C:\Users\user> py -m pip freeze 
async-generator==1.10 
attrs==23.1.0 
certifi==2023.5.7 
cffi==1.15.1 
exceptiongroup==1.1.1 
h11==0.14.0 
idna==3.4 
outcome==1.2.0 
pycparser==2.21 
PySocks==1.7.1 
selenium==4.10.0 
sniffio==1.3.0 
sortedcontainers==2.4.0 
trio==0.22.0 
trio-websocket==0.10.3 
urllib3==2.0.3 
wsproto==1.2.0 
  
C:\Users\user> 
C:\Users\user> py -m pip show selenium 
Name: selenium 
Version: 4.10.0 
Summary: 
Home-page: https://www.selenium.dev 
Author: 
Author-email: 
License: Apache 2.0 
Location: C:\Users\user\AppData\Roaming\Python\Python311\site-packages 
Requires: certifi, trio, trio-websocket, urllib3 
Required-by: 
  
C:\Users\user> 
  
  
or for WIN (IDE): 
  
(venv) PS C:\Users\user\PycharmProjects\pythonSelenium> py -m pip install selenium 
Collecting selenium 
 Using cached selenium-4.10.0-py3-none-any.whl (6.7 MB) 
Collecting urllib3[socks]<3,>=1.26 (from selenium) 
 Using cached urllib3-2.0.3-py3-none-any.whl (123 kB) 
Collecting trio~=0.17 (from selenium) 
 Using cached trio-0.22.0-py3-none-any.whl (384 kB) 
Collecting trio-websocket~=0.9 (from selenium) 
 Using cached trio_websocket-0.10.3-py3-none-any.whl (17 kB) 
Collecting certifi>=2021.10.8 (from selenium) 
 Using cached certifi-2023.5.7-py3-none-any.whl (156 kB) 
Collecting attrs>=19.2.0 (from trio~=0.17->selenium) 
 Using cached attrs-23.1.0-py3-none-any.whl (61 kB) 
Collecting sortedcontainers (from trio~=0.17->selenium) 
 Using cached sortedcontainers-2.4.0-py2.py3-none-any.whl (29 kB) 
Collecting async-generator>=1.9 (from trio~=0.17->selenium) 
 Using cached async_generator-1.10-py3-none-any.whl (18 kB) 
Collecting idna (from trio~=0.17->selenium) 
 Using cached idna-3.4-py3-none-any.whl (61 kB) 
Collecting outcome (from trio~=0.17->selenium) 
 Using cached outcome-1.2.0-py2.py3-none-any.whl (9.7 kB) 
Collecting sniffio (from trio~=0.17->selenium) 
 Using cached sniffio-1.3.0-py3-none-any.whl (10 kB) 
Collecting cffi>=1.14 (from trio~=0.17->selenium) 
 Using cached cffi-1.15.1-cp311-cp311-win_amd64.whl (179 kB) 
Collecting exceptiongroup (from trio-websocket~=0.9->selenium) 
 Using cached exceptiongroup-1.1.1-py3-none-any.whl (14 kB) 
Collecting wsproto>=0.14 (from trio-websocket~=0.9->selenium) 
 Using cached wsproto-1.2.0-py3-none-any.whl (24 kB) 
Collecting pysocks!=1.5.7,<2.0,>=1.5.6 (from urllib3[socks]<3,>=1.26->selenium) 
 Using cached PySocks-1.7.1-py3-none-any.whl (16 kB) 
Collecting pycparser (from cffi>=1.14->trio~=0.17->selenium) 
 Using cached pycparser-2.21-py2.py3-none-any.whl (118 kB) 
Collecting h11<1,>=0.9.0 (from wsproto>=0.14->trio-websocket~=0.9->selenium) 
 Using cached h11-0.14.0-py3-none-any.whl (58 kB) 
Installing collected packages: sortedcontainers, urllib3, sniffio, pysocks, pycparser, idna, h11, exceptiongroup, certifi, attrs, async-generator, wsproto, outco 
me, cffi, trio, trio-websocket, selenium 
Successfully installed async-generator-1.10 attrs-23.1.0 certifi-2023.5.7 cffi-1.15.1 exceptiongroup-1.1.1 h11-0.14.0 idna-3.4 outcome-1.2.0 pycparser-2.21 pysoc 
ks-1.7.1 selenium-4.10.0 sniffio-1.3.0 sortedcontainers-2.4.0 trio-0.22.0 trio-websocket-0.10.3 urllib3-2.0.3 wsproto-1.2.0 
(venv) PS C:\Users\user\PycharmProjects\pythonSelenium>  
(venv) PS C:\Users\user\PycharmProjects\pythonSelenium> py -m pip list       
Package     Version 
---------------- -------- 
async-generator 1.10 
attrs      23.1.0 
certifi     2023.5.7 
cffi       1.15.1 
exceptiongroup  1.1.1 
h11       0.14.0 
idna       3.4 
outcome     1.2.0 
pip       23.1.2 
pycparser    2.21 
PySocks     1.7.1 
selenium     4.10.0 
sniffio     1.3.0 
sortedcontainers 2.4.0 
trio       0.22.0 
trio-websocket  0.10.3 
urllib3     2.0.3 
wheel      0.38.4 
wsproto     1.2.0 
(venv) PS C:\Users\user\PycharmProjects\pythonSelenium> py -m pip show selenium 
Name: selenium 
Version: 4.10.0 
Summary: 
Home-page: https://www.selenium.dev 
Author: 
Author-email: 
License: Apache 2.0 
Location: C:\Users\user\PycharmProjects\pythonSelenium\venv\Lib\site-packages 
Requires: certifi, trio, trio-websocket, urllib3 
Required-by: 
(venv) PS C:\Users\user\PycharmProjects\pythonSelenium>  

Test automation – summary  

Selenium supports a number of programming languages for test automation. Among developers, both Java and Python have achieved record-breaking popularity. Python is easy to learn, and its syntax is simple to read, so if you are new to programming, using Selenium with Python might sound interesting in terms of automation. On the other hand, Java and Selenium are an excellent fit for the entire software development process, especially in the context of CI/CD integration, thanks to the use of the appropriate build tools. The answer to the question of which to use, Java or Python, is up to you, depending on your professional background and objectives for the future.  

FAQ – starting points for Selenium with Java or Python 

Here is your starter pack for test automation with Selenium + Java or Selenium + Python, no matter which of them you decide to use. 

Exclusive Content Awaits!

Dive deep into our special resources and insights. Subscribe to our newsletter now and stay ahead of the curve.

Information on the processing of personal data

Exclusive Content Awaits!

Dive deep into our special resources and insights. Subscribe to our newsletter now and stay ahead of the curve.

Information on the processing of personal data

Subscribe to our newsletter to unlock this file

Dive deep into our special resources and insights. Subscribe now and stay ahead of the curve – Exclusive Content Awaits

Information on the processing of personal data

Almost There!

We’ve sent a verification email to your address. Please click on the confirmation link inside to enjoy our latest updates.

If there is no message in your inbox within 5 minutes then also check your *spam* folder.

Already Part of the Crew!

Looks like you’re already subscribed to our newsletter. Stay tuned for the latest updates!

Oops, Something Went Wrong!

We encountered an unexpected error while processing your request. Please try again later or contact our support team for assistance.

    Get notified about new articles

    Be a part of something more than just newsletter

    I hereby agree that Inetum Polska Sp. z o.o. shall process my personal data (hereinafter ‘personal data’), such as: my full name, e-mail address, telephone number and Skype ID/name for commercial purposes.

    I hereby agree that Inetum Polska Sp. z o.o. shall process my personal data (hereinafter ‘personal data’), such as: my full name, e-mail address and telephone number for marketing purposes.

    Read more

    Just one click away!

    We've sent you an email containing a confirmation link. Please open your inbox and finalize your subscription there to receive your e-book copy.

    Note: If you don't see that email in your inbox shortly, check your spam folder.