Author: robertsgreibers

Python XML Parse – ElementTree Reader & Parser

In this Python XML tutorial, you will learn how to use xml.etree.ElementTree package (which is one of the many Python XML parsers) to process XML response.

For this tutorial, you can use your own XML response or follow the steps below and use the one I have provided.

The Python XML parsing steps I’m about to explain and guide you through were developed alongside a refund payment integration I was working on in Django. 

We’re going to explore the parsing end result for the SOAP XML response I wrote about in the previous post. The SOAP XML parsing post was written with a focus on an actual regex parsing in Python and all the steps before you get to the actual XML scheme style response. 

In this post, I’m about to give you a Python XML tutorial for parsing XML schemes when you already have a decoded version of an XML response and you see the information.

The post here is about extracting specific values from the whole XML tree without using regex or any other typical Python parsing tools, but the actual xml.etree.ElementTree package (the right way)

By the way, Roberts Greibers here – in my day job, I’m working as a Python Django backend developer for a local company in Riga, Latvia, and building a white label payment gateway platform. 

Over the past couple of years, I’ve gathered a lot of experience in the FinTech industry, practical knowledge of how payment systems work, how to develop, test and deploy them with minimal headache. 

Of course, I can’t go into too much detail here in a single blog post, but if you want to build your own portfolio project and become a Python and Django developer, I’d suggest checking out client testimonials here and reaching out to me.

I go very deep and always explain all the steps in detail with specific videos and documents for my clients. So the post here is just a small example of how I could help you out.

Also, I always answer all client questions along the way.. but enough of talking, let’s get into the code. 

Continue reading

Parsing SOAP XML Response In Python

In this tutorial, you will learn how to decode and parse a large SOAP XML response with Python and regular expression, essentially the goal here was to build a Python function to get rid of manually decoding SOAP XML response over and over again.

The Python code I’m about to explain and show you was developed as a part of refund payment integration done in Python and Django. 

We’re going to take a look at an encoded SOAP XML response stdout saved in a text file.

I saved this SOAP response output when I was in a process of developing a payment integration feature for a local bank here in Riga, Latvia, along the way I realized it’s going to be a great learning experience for anyone else who’s going to search for a similar solution on Google. 

I’ve discussed similar text file parsing in Python situations before here on the blog, but the difference here is that this one is way more complicated and involves a bit more decoding and text manipulation as well as extensive knowledge on regex pattern matching. 

Definitely a good Python regular expression practice, even for advanced Python developers. 

Currently, I’m working as a Python Django backend developer (Roberts Greibers) for a local company here in Riga, Latvia – building a white-label payment gateway platform, you can find more about my experience on my Linkedin profile

Give me a follow on Linkedin or send me a DM if you have any questions. 

One of the recent payment integration flows I needed to develop was for a refund payment. Refund payments were supposed to work for multiple banks through one gateway system for this particular client and brand. 

The whole refund payment flow is way more complicated and would take me weeks to write up and explain here on the blog so I’m gonna share a small portion of what actually was very interesting to work on – parsing decoded SOAP XML response with regular expression in Python. 

I go deeper explaining features you can develop for your Python and Django portfolio if you’re working personally with me in one on one Zoom calls (click here to see an example of a LIVE Zoom call). I personally will guide you through the development of each feature and answer all your questions along the way. 

This is what we’re working on with my most successful mentoring clients.

So if the above sounds interesting, let’s get started! 

Continue reading

Django: How Painful And Difficult It Is

Hello there!

Welcome back – or nice to have you for the first time!

Roberts Greibers here and in this post, I want to share with you how painful and difficult the Django framework is and how much Python is required for a Django developer position – this is especially important for Python beginners who are interested in becoming a Django developer. 

If you’re reading this post… 

And you’re seriously considering becoming a Python/Django developer

Starting from scratch and getting your very first Python/Django DEV job can make you feel a little lost -“Where to actually start?”

All these doubtful questions can come to your mind and you can start to feel unsure about yourself

If that sounds familiar, keep reading – this post is exactly for YOU!

Continue reading

My 3 Unit Tests Tips In Python Django (REALLY Important!)

Good morning! Welcome back, Roberts Greibers here, and in this post, I want to talk about my three unit tests tips that have allowed me to get into writing unit tests in Python Django way faster, in a way more scalable way. 

These are unit tests tips that you will definitely need! 

Because when it comes to building a Python Django project you can’t build anything without having proper test coverage. 

If you like the idea of becoming a Python Django developer, building your own Django projects, writing professional code which is also covered with unit tests – this post is exactly for YOU!

These are tips that I literally use every day when I’m working on new features in Python Django and I wish I knew about them when I was just a beginner Python developer. 

I’ve been working professionally as a Python developer for more than 5 years now – and for the past couple of years, I’ve been working in the fintech industry, building a white label payment gateway product for a local company (ourspell.com) in Riga, Latvia. 

You can read more about my experience on my Linkedin here.

I’m also helping junior developers who are at beginning of their careers (see the LIVE mentoring call here) to take a shortcut and basically use my code examples, techniques I have collected over the years and apply them to their own projects to get their first Python Django job opportunities. 

In the end, what I’m about to give you here in this post is just a small portion of what I share with my clients.

But this will definitely help you write better Python scripts if you’re serious about becoming a Python/Django developer. 

Continue reading

Wait For Elements In Python Selenium (5 Powerful Examples)

Alright, welcome back to the blog, Roberts Greibers here, and in this post, I want to talk about five powerful examples you can use in Python Selenium to wait for elements when working on automation projects.

Whether you’re just getting started as a Python developer, or you are already in the industry as a test automation engineer and looking for more effective ways in Python selenium to wait for element – this post is for you!

These are not just things that I’ve just randomly come up with!

These are not just theoretical concepts!

These are code examples in Python selenium to wait for element that I have saved in my notes since a long time ago and I literally used them back when I used to work on test automation projects. 

The code examples I’m about to show you are few of the best ways in Python selenium to wait for element that allowed me to improve the speed of my test automation scripts!

I’m going to show you a code to:

  • wait for element to be found (any situation)
  • wait for element to be visible
  • wait for element to be clickable
  • wait for element to load
  • wait for element to be displayed

… which one to use depends on a specific situation you’re working on. But I can assure you, in the end, these code examples led me to write more advanced Selenium automation test cases. 

And NO! It’s not going to be about using just the typical time.sleep(1) solution. I’ll show you where it’s appropriate to use time.sleep(1) and I’ll show you the best ways I know in Python Selenium to wait for element.

import time

time.sleep(1)

I’ve been working professionally as a Python developer for more than 5 years – a part of it was as a quality assurance engineer where I worked with Python and selenium framework a lot. 

Eventually, I became a Python/Django developer (see my Linkedin here) and now I’m also helping relatively new engineers (quality assurance engineers, analysts, etc.) to become Python developers. (see a cut from a LIVE mentoring call)

If you like the idea of becoming a Python developer, learning about Selenium framework tricks, and eventually maybe even becoming a Django developer, then this post is for you!

Continue reading

Python Training: Why You Shouldn’t Attend It (3 Important Reasons)

Good afternoon, Roberts Greibers here, and in this post I’m going to expose the awful truth about python training in NYC (New York City) and also all over the world. 

I’ve been working professionally as a Python developer for more than 5 years and now (see my Linkedin here) I’m also helping people who are in a similar position I was when I first started – to become Python developers. (see a cut from a LIVE mentoring call)

Ever since I started to lean more into the field of helping people, I realized how many horror stories are out there about a common Python training course. 

Every now and then I hear a new story, a new shocking price of a training course, and now it’s no surprise to me that there is a lack of good Python developers out there. 

I used to be a quality assurance engineer (manual tester) – testing website projects and apps so I totally get that a lot of people want to move away from their current job and get into more profitable positions like becoming a Python/Django developer.  

Maybe you’re somebody who wants to become a Python developer, be more independent, more free from a typical 9-5 job, maybe even work remotely from anywhere in the world, and have a higher income than what you’re used to. 

So if that’s you, I want to give you a little bit of a counterbalance to all the wild claims that all these Python training courses out there are currently making. 

Continue reading

5 Secret Debugging Tools For Python And Django

Alright, Roberts Greibers here with another experience-based Python post.

I’ve been working professionally as a Python developer for more than 5 years and now I’m also helping people who are at the start of their careers (or in a similar position I was in) to become Python developers. 

I used to be a quality assurance engineer – manually tested website projects and mobile apps. (iOS, Android)

So I totally get how it is when you want to move away from your current role and get into a more profitable position, for example, become a Python/Django developer.  

What I’m about to show you in this post are five of the most important tools I used and my clients are using now (see a cut from a LIVE Zoom video call below) that made me look like a senior Python developer even though I was just starting to learn Python.

Continue reading

Amazon Scraping In Python Selenium

Scraping data from any kind of website with Python can be exciting and challenging at the same time. Also, you can learn a lot about development and writing simple scripts – practice Python’s fundamentals.

More than 5 years ago, when I first started to get to know what Python is capable of – the very first thing I wanted to learn was how to automate browser actions – open websites, click on buttons, enter text into input fields, etc.

Back then I was learning how to automate facebook.com

Within the following steps, you will learn how to automate scraping data from amazon.com from A-Z.

I’ve prepared steps with everything you need to do in order to be able to fully automate the process and gather data for up to 100 products in less than a minute.

With the provided code you’ll have a good base for starting the Amazon website automation and you’ll be able to expand and extend my code to whatever your goals are.

Follow the steps below.

Continue reading

Python Regex Match, Group and Search

This is a follow-up post to a blog post I made 5 years ago. I’ve received quite a few emails from people having problems with Python regex match, group, and search methods. It seems like a lot of people are dealing with a situation where they need to open up and parse a log file in Python – extract information about database dumps, database errors or it could also be any kind of other information, as long as it’s a log or error file with text in it. 

As I have mentioned in my first blog post (Log File Parsing In Python), Python and Regex are a perfect combination of tools to read log files line by line. It’s easy to use and very easy to learn. 

The last time a did a post about this topic I gave you an example of how to parse Skype for Business iOS application log files. This time I’m going to take a look at a log file sent in by a reader of this blog and give you an example of how I would deal with such a situation. 

Here’s a quick example of the type of log file you’re going to deal with:

Event: Cdr Privilege: cdr,all AccountCode: Source:491454490 Destination:1545454572877 110 DestinationContext: testing CallerID: Channel: Console/dsp DestinationChannel: LastApplication: Hangup
LastData: StartTime: 2010-08-23 08:27:21 AnswerTime: 2010-08-23 08:27:21 EndTime: 2010-08-23 08:28:21 Duration: 60 BillableSeconds: 0 Disposition: ANSWERED AMAFlags: DOCUMENTATION UniqueID: 1282570041.3 UserField: Rate: 0.02 Carrier: BS&S

Event: Cdr Privilege: cdr,all AccountCode: Source: Destination: 110 DestinationContext: testing CallerID: Channel: Console/dsp DestinationChannel: LastApplication: Hangup
LastData: StartTime: 2010-08-23 08:27:21 AnswerTime: 2010-08-23 08:27:21 EndTime: 2010-08-23 08:27:21 Duration: 0 BillableSeconds: 0 Disposition: ANSWERED AMAFlags: DOCUMENTATION UniqueID: 1282570041.3 UserField: Rate: 0.02 Carrier: BS&S
Continue reading

Log File Parsing In Python

In this tutorial, you will learn how to open a log file, read a log file, and create a log file parser in Python, essentially building a so-called “Python log reader”.

To open a log file in Python, read a log file, and actually parse a log file or any type of text file in order to extract specific information is not that hard if you know a bit of Python log file parsing and regex pattern match usage.

Python itself is a perfect tool to open a log file for parsing and it does not require any third-party modules. Believe me, the first thing I did was a Google search for a “Python log reader” and “Python file parsing” a couple of years ago when I first started to work on parsing text files in Python. Ever since those days, I’ve learned to work with Python and regex very efficiently, see more details in a recent post I did about how to parse XML SOAP response with Python and regex by clicking here.

In my day job, a while back I was working on testing Skype for Business iOS application as a test engineer and it came to the point where I had to open and manually collect the SfB iOS application log files in order to see all HTTP requests and received HTTP responses.

Ever since then I’ve switched to backend development with Python/Django and also helped people to go into a similar path. See a cut from a recent coaching call here. And more about client testimonials here.

Anyways, in this specific situation, I had to figure out a good way to open iOS log files and parse them to search a log file for properties like:

<code><property name="saveMessagingHistory">Enabled</property></code>

Usually, properties were buried under a bunch of other not-so-important log file dumps, for example:

INFO UTILITIES /Volumes/ServerHD2/buildagent/workspace/200615/client_ios_sfb/dependencies/client-shared_framework_sfbplatform/src/dev/lyncMobile/platform/tracing/privateIos/CMTrace.mm/173:Version Information 6.12.0.65
2016-12-20 13:16:52.303 SfB[417:1af74bc40] INFO UTILITIES CTimer.cpp:657 TimerMap is created 
2016-12-20 13:16:52.342 SfB[417:1af74bc40] INFO UI SFBAppDelegate.mm:69 Application will finish launching with options
2016-12-20 13:16:52.345 SfB[417:1af74bc40] INFO UTILITIES CStorageManager.mm:146 Creating StorageManager
2016-12-20 13:16:52.347 SfB[417:1af74bc40] INFO UTILITIES CStorageManager.mm:187 Initializing StorageManager
2016-12-20 13:16:52.357 SfB[417:1af74bc40] INFO APPLICATION CApplication.cpp:3400 Initialize Internal Begin
2016-12-20 13:16:52.361 SfB[417:1af74bc40] INFO UTILITIES COsInformation.mm:398 User UI language identifier en was mapped to en-US 1033
2016-12-20 13:16:52.362 SfB[417:1af74bc40] INFO UTILITIES COsInformation.mm:106 Device Version Info - Model=iPhone, HardwareModel=iPhone9,3, SystemName=iOS, SystemVersion=10.1
2016-12-20 13:16:52.362 SfB[417:1af74bc40] VERBOSE APPLICATION CApplication.cpp:3415 Initialize Internal -- App State Query Established
2016-12-20 13:16:52.363 SfB[417:1af74bc40] INFO UTILITIES CNetworkMonitor.cpp:70 Successfully started listening to network events
2016-12-20 13:16:52.364 SfB[417:1af74bc40] INFO UTILITIES CNetworkMonitor.cpp:229 Reachabilility Flags IsWWAN(0):Reachable(1):TransientConnection(0):ConnectionRequired(0):ConnectionOnTraffic(0):InterventionRequired(0):ConnectionOnDemand(0):IsLocalAddress(0):IsDirect(0)
2016-12-20 13:16:52.364 SfB[417:1af74bc40] INFO UTILITIES CNetworkMonitor.cpp:198 Updated networkAvailableToConnect(NoNetwork) -> WiFi, isInAirplaneMode(0) -> 0
2016-12-20 13:16:52.364 SfB[417:1af74bc40] INFO UTILITIES CTimer.cpp:227 Created timer instance (0x70286428) for runloop (0x7017e780)

While I was searching for specific properties in those log files, I realized it’s going to be really time-consuming to go through everything manually.

In order to save time, I had to come up with a good way to use Python file parsing, and long behold I managed to write code for a log file parsing Python script.

It’s a very simple way of searching a log file with Python.

If you want to test the following Python log parsing script with a similar text file, you have to download Skype for Business iOS log file here:

Continue reading