Selenium Tests Should Not Include Java/C# Statements

Photo by Jess @ Harper Sunday on Unsplash

I hear sometimes people saying that, in certain conditions, it is ok to use Java/C# statements in Selenium UI tests.

For example, the following UI test checks that all product titles include the search keyword:

@Test
public void All_Product_Titles_Include_Search_Keyword()
{
HomePage homePage = new HomePage(driver);

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store