I recently wrote an automated test that
- opens a site
- searches for a keyword
- selects a result on results page
- enables an alert on details page
- gets api calls executed by details page when enabling the alert
- gets data from the response of the api calls
How difficult can it be to convert Java code to C#?
It turned out that it was very easy.
These were the major differences for my test so it runs in Visual Studio, C# instead of Eclipse and Java:
1. Selenium interfaces are named differently (WebDriver is IWebDriver in C#, WebElement is IWebElement)
2. There is no CamelCase notation
3. String formatting is slightly different and uses {} instead of %
4. Writing text to files is a bit different
5. const is used instead of final static for constants
6. the collection returned by driver.FindElements() is not a list but a readonly collection
7. the equivalent of IllegalArgumentException is ArgumentException
8. all Selenium methods are minimally different
9. there are no expected conditions but the alternative is better and more flexible
10. Collection methods have different names
11. String in Java is string in C#
12. packages in Java are namespaces in C#
13. nUnit is similar to jUnit with minor differences
C# and Java are so similar
![]() |
ReplyForward
|
You must be logged in to post a comment.