Skip to content

Instantly share code, notes, and snippets.

@JPGITHUB1519
Forked from diyan/python_qa_automation.md
Created February 10, 2017 20:26
Show Gist options
  • Save JPGITHUB1519/adee6706fce67b0365f938978f75d7cb to your computer and use it in GitHub Desktop.
Save JPGITHUB1519/adee6706fce67b0365f938978f75d7cb to your computer and use it in GitHub Desktop.
Learning Python for QA automation tasks

Hello all,

In this gist you may find resources in Russian/English which could be useful for writing Python script for test automation tasks.

What Python runtime I should use?

While Python 3.x (>=3.3) is reccomended for new project development it much better and easier to go with a bit older but rock-solid Python 2.x (>=2.7) for test automation.

Some Python packages comes with binary modules and it much easier to use 32-bit Python under Windows due to this reason.

Where I can find different Python libraries?

Python installation includes very good set of standard libraries.

Majority of third-party libraries could be found at PyPI (Python Package Index) - https://pypi.python.org/pypi/simplegui

NOTE that all third party libraries in Python are called 'packages'.

How to install Python third party package?

pip or easy_install tools should be used in order to install Python package.

NOTE that both pip and easy_install can not install packages with binary modules without C/C++ compiler on Windows.

In such cases you can download such packages with already compiled modules from here:

Gallery of Python packages which contains binary modules. Complied for Windows - http://www.lfd.uci.edu/~gohlke/pythonlibs/

For example, this package can not be installed using pip - https://pypi.python.org/pypi/MySQL-python/1.2.4

So, you can download and install package using following url - http://www.lfd.uci.edu/~gohlke/pythonlibs/#mysql-python

Packages worth to take a look

Unit/integration tests. Use pytest instead of unittest module or nose package - https://pypi.python.org/pypi/pytest

HTTP protocol. Use requests instead of httplib, urllib, urllib2 or urllib3 - https://pypi.python.org/pypi/requests

Web Browser drivers. Selenium WebDriver for Python - https://pypi.python.org/pypi/selenium

HTML parsing, XML parsing, XML writing - https://pypi.python.org/pypi/lxml/3.2.1

JSON parsing/writing - http://docs.python.org/2/library/json.html

MySQL database access - https://pypi.python.org/pypi/MySQL-python/1.2.4

Check email (IMAP protocol) - http://docs.python.org/2/library/imaplib.html

Send email (SMTP protocol) - http://docs.python.org/2/library/smtplib.html

Coding guidelines

PEP8 коротко и по-русски - Блог - http://rukeba.com/by-the-way/pep8-korotko-i-po-russki/

NOTE: Fresh version of PyCharm will check your code against PEP8 guidelines automatically.

Code Like a Pythonista: Idiomatic Python (part0) / Хабрахабр - http://habrahabr.ru/post/88972/

Code Like a Pythonista: Idiomatic Python (part1) / Хабрахабр - http://habrahabr.ru/post/89735/

Code Like a Pythonista: Idiomatic Python (part2) / Хабрахабр - http://habrahabr.ru/post/90493/

Стиль кода в языке python - https://docs.google.com/file/d/0B7cDWj1-Z0r0MmYwZjJhZWEtMjk1Zi00NWE5LWEzNTQtOTFjNjcwYjdhMGRl/edit?pli=1&hl=ru

This resource could be useful

The Hitchhiker’s Guide to Python! - https://python-guide.readthedocs.org/en/latest/

What should I learn in addition to Selenim WebDriver for doing Web automation?

  • XPATH selectors. IMO better to learn this because it's more poverful (and also a bit more complicated that CSS selectors)

  • CSS selectors

TODO

  • Put some books/references for novices and beginners in programming
  • Fix some formatting issues
  • Put references on XPATH and CSS selectors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment