Python Selenium Tips

Hello everyone, I’m Ceyhun. Today i will share some tips regarding preparing and using Selenium scripts with Python.

-Use page object model, its very important to start your project with it.. Make some demo project or start with basic writing and show difference to your team.
-Use unittest module or something similar to organize your cases. It makes easier to run and manage.
-Use driver.quit() not close if you gonna run many cases on a server.
-Use expected conditions very often or always.
-Use try except functions at your setup. Lets say you have 30 cases requires a setup before run and you put your driver.quit function inside the teardown function. What will happen if setup fails? You will have 30 chrome window open. Sometimes you can take some actions to make your scripts look like a poem but design them well.
-Follow PEP8 guides for better code quality. You are probably in a QA department. Well improve quality of your own work.
-Use power of the unittest! Expected Failure, Skip ext. You can make your tests easier if you can check its build in functions.
-Take screenshots with teardown, it makes your life easier if you gather screenshots once your script fails, do it.
-Prepare your base for different platforms. Python can provide what os and platform you are working on. Arrange your settings file to work with different platform without additional settings by end users(your team members).
-Maintain and run your cases. If you only write but don’t run your cases your team members won’t understand its effect. Focus on reporting and maintaining your cases, show your business partners the value of automation, if you don’t do that they can request to stop automation work since it takes more time to write scripts. Schedule may be important but dont give up from quality that easily.