Selenium - advantages and disadvantages of using Python vs C#



  • We currently have two teams. An automation team and also a web testing team. The automation team currently use Selenium and C# to automate tests on our web applications and legacy systems.

    As a member of the web testing team, we are now starting to look at writing simple scripts using selenium, however it has been recommended to us that we start to use Python rather than C# to write our scripts.

    I would appreciate any advice on the advantages and disadvantages of using C# with Selenium and also Python.



  • To play a devil advocate, if you try Python, you will find that you are substantially more productive because of dynamic typing. Python just works much harder to improve productivity of the programmer, as compared to C# which is focused to create effective code (making programmer to work harder to get it). In testing, it is of little difference if test script is 20 ms faster (in C#), because tests in both languages just call the same libraries anyway. But if you can create test script one day sooner, it does make difference.

    Python data structures are more flexible: it is trivial to create a dictionary with tuples as keys and lists as values. In C#, it is not as obvious. Many times Python debugger saved my bacon: fire it in the middle of test where interesting variables are instantiated, and you can interrogate them for properties and methods as they are, not as you think they should be by reading the code (as you do in C#).

    Also, yield operator allowed me cool tricks when implementing page object. Not sure how easy is to create a generator returning tuples in C#, but in Python it is trivial.

    Full disclosure: I used C# for a desktop application, did not enjoyed it, and changed job to one where Python is main language for both development and testing.

    I understand that standardization on a single language is important. But I strongly believe that especially for testing, that language being Python has substantial competitive advantage over C#.

    Maybe the person who suggested to try Python alongside C# wants to compare productivity and switch to the more productive platform? And I am pretty sure that Python will be a winner in that competition.



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2