0

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.

1
  • 1
    A big disadvantage to C# is that it's a legacy, frequently Windows-only language, though Selenium might work fine on Mono. Being stuck on Windows might outweigh the training costs, but it might not. Jul 1, 2014 at 20:18

5 Answers 5

5

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.

2
  • 1
    I think productivity is a rather subjective matter. From my perspective: we use C# for Selenium and API testing - it's a perfect language to create extensive, solid frameworks, and I find it a lot more readable than dynamically typed languages. I (and even junior colleagues) can write tests using these frameworks on a whim and they are easily maintainable on top. So a rather unbalanced answer. ;)
    – FDM
    Aug 8, 2018 at 6:33
  • @FDM - I see that you have experience in using C#. But how much experience you have in Python? I have few years of Java/C#, and extensively used Perl before Python. And yes, it takes a mental switch to let go static typing, and again, readability improves as you gain experience with a language. I would personally never go back to statically typed language, because in Python, I am 300% more productive. Nov 6, 2019 at 15:00
3

First of all: Welcome to SQA.

Apart form the features of C# and Python, your team should also use C#. The web testing team can reuse scripts from the automation team. The teams can support and complement each other. They can talk about problems and challenges and find solutions together.

That Python already have a xUnit framework in the standard library is the only advantage comes into my mind when I compare C# with Python.

1

Adding something to @Twaldigas reply, why / who has recommended that you use python?

It makes perfect sense to me that you use the same language as the development and automation team, this way, if you have some problems, I'm sure they have already solved it in the past.

Plus, if the automation team already has a framework built on top of selenium, maybe you can use it instead of going through all the quirks and difficulties of starting with selenium.

Hope this helps...

1

Great question! For my company, QA is restricted to lots of access, such as SQL database. So for me, it doesn't matter what we use to create test scripts. I can see the point of developers being able to help trouble shoot automation scripts that fail, but for us, the developers are always on at least 3 projects so getting their help is hard. Our QA team is self sufficient and I used to be a developer in .NET for 10 years so i can support out own internal need. With that said, I am leaning towards python for it's easy learning curve. And in our environment, my manager prefers that we are outside of developers code because then it's fully blind testing. ;)

0

Disadvantages of using C# in one team and Python in the other include cost of training and cost of learning.

If one team finds issues and wants the assistance of the other there will be challenges with explaining the subtle features of the language used for the test.

New members on either team will need some training. Using two languages will mean two types of training need to be found.

People transferring from one team to the other will need to learn another language.

As your company already uses C# with Selenium it makes sense to reuse that expertise. Perhaps one of the developers can be seconded to the test team to give guidance and training etc. Such a secondment may be good for the developers as they get to learn about the challenges of testing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.