No Need To Know Everything

Learning anything deeply requires a lot of time and it is an on-going process. Programming is no different. Challenging part is that, it seems like, there is always more and more to learn. For example, learning Python - you can go through basics in 1 hour, but when you start exploring it more and actually start using the language, you always find something new. A new feature, library, module, tool, n different ways of doing a task. ...

November 5, 2023 Â· 2 min Â· 219 words

PyTest - Parametrizing Test Functions

One of key features of PyTest is the ability to create parametrized tests, meaning running test cases with various input values without having to write separate test cases. Main goal of my most recent Django project is to develop better understanding of testing principles and tools. I have already built few Django applications, however never really focused on testing my own code - I was just happy the app “worked”. Knowing what and how to test is a skill in itself. It is quite a challenge. One can write hundreds of test cases which are not really covering the essential functionalities, or they repeat. Just as most of the things, it comes with a practice. However, I understand the long-term value of writing and having effective tests. ...

October 6, 2023 Â· 2 min Â· 417 words

Dump & Restore PostgreSQL database in a Docker

I was updating my blog and needed to use the same database which I currently have in production. Since my blog is fully dockerized, managing the state of the application between production & development environment is a lot easier. For this purpose, I have researched and learned two handy commands, one to export the database and the other one to import the database. Export (dump) with pg_dump{.single}: 1 docker exec -i container_name /bin/bash -c “PGPASSWORD=actual_password pg_dump —username actual_username database_name” > /path/of/export/export.sql Import (restore) with psql{.single}: 1 docker exec -i container_name /bin/bash -c “PGPASSWORD=actual_password psql —username actual_username database_name” > /path/of/export/export.sql I have noticed successful import even with errors (default PostgreSQL behaviour), because I already had some migrations (in my Django app). Therefore I would recommend first resetting the whole DB and then importing the database. If you want to overwrite this default behaviour and stop upon error, add -set ON_ERROR_STOP=on{.single} to your command. ...

September 13, 2023 Â· 1 min Â· 152 words

Django Password Validators

By default Django comes with an advanced password validator, meaning user must enter password with a minimum length of 8 characters, some special sign, number. For production environment this is very important, however for development environment a simpler password would do and it wouldn’t take so much time. Today I have learned how to turn the advaced password protection off (remember to remove this line for production). Add the following line to your settings.py file: ...

August 31, 2023 Â· 1 min Â· 79 words

yield vs return

As I’m currently using and learning PyTest framework in my QA Automation project, I have noticed that a lot of functions decorated with @pytest.fixture() decorator use the yield keyword instead of the return keyword. I was not sure about the exact difference between these two statements, therefore I have decided to research it a bit more. return vs yield statement Both yield and return are keywords in Python and both are used in a function to pass values from one function to another in a program. ...

August 8, 2023 Â· 2 min Â· 346 words

Page Object Model

To improve my automation skills, I am working on a QA Automation project where I have to solve various Test Cases that test many aspects of the web-application. I have started this project with the main goal of developing better understanding of Page Object Model, Selenium and PyTest. For the bigger projects it is very important to correctly design and structure the project itself. Very popular design pattern for this purpose is called Page Object Model. This way, I would like to sum-up some of the things I have learned about POM so far. ...

August 7, 2023 Â· 4 min Â· 786 words

Sorting dictionary first by key, then by value

I have just completed a fun exercise on HackerRank named Company Logo. The task was to “print the three most common characters along with their occurrence count”. Task Two key conditions were: Sort in descending order of occurrence count, If the occurrence count is the same, sort the characters in alphabetical order. As with most of the problems, there is more than one solution, but because I recently explored the collections module and DefaultDict in particular, it was the first thing that came to my mind - I would insert each character into the dictionary and on each occurence increment the value by 1. ...

July 17, 2023 Â· 2 min Â· 408 words

Python's collections module

I’m currently going over Python’s collection module exercises on HackerRank. This module offers a range of data-structures and algorithms that can enhance the performance and functionality of your Python programs. What I’ve learned so far is that when I am in need of some specialized data-structure, I should take a look into collections module. Python’s collection module offers: Counter The Counter class within the collections module provides an efficient way to count the occurrence of elements in a collection. It takes an iterable as input and returns a dictionary-like object where elements are keys and their counts are the corresponding values. ...

June 6, 2023 Â· 4 min Â· 801 words

Locating Elements

[TOC] Web element interactions are at the core of web automation using Selenium and Python. By leveraging the various locator strategies available, you can precisely locate and interact with web elements. Modern websites can be very complex and unique, therefore learning different locators can be a great investment. Benefits of knowing various locator strategies: Precise Element Identification: Locators allow you to target specific elements on a web page accurately. Flexibility and Adaptability: Locators provide flexibility in locating elements by offering different strategies such as ID, class name, tag name, etc. Maintainability and Robustness: Locators help in creating maintainable and robust automation scripts. Reusability: Once you define a locator for an element, you can reuse it across multiple test cases or scenarios. Improved Readability: Locators make your automation scripts more readable and understandable. Enhanced Debugging and Troubleshooting: When an automation script encounters an issue, having well-defined locators makes debugging and troubleshooting more manageable. Cross-Browser and Platform Compatibility: Locators help ensure cross-browser and platform compatibility. Reduced Maintenance Effort: With reliable locators, your automation scripts require fewer updates and maintenance efforts. Locator strategies As mentioned before, Selenium comes with many locators, such as: ...

May 26, 2023 Â· 4 min Â· 763 words

Expected Conditions

One essential aspect of Selenium is handling synchronization issues (for example, AJAX loading screen), where the automation script needs to wait for specific conditions to be met before proceeding. This is where “Expected Conditions” come into play, providing a flexible and efficient way to wait for elements or certain states to appear or change on a web page. What are Expected Conditions? Expected Conditions are predefined conditions that Selenium can wait for, ensuring that the desired state or element is available before performing an action or assertion. These conditions are part of the selenium.webdriver.support.expected_conditions module and can be used in conjunction with the WebDriverWait class to implement effective synchronization in your automation scripts. ...

May 17, 2023 Â· 2 min Â· 350 words