public class CrossMobileAgentTest extends TestBase { @AfterMethod public static void cleanUp() { driver.quit(); } @Test(dataProvider = "userAgentsData") public static void testDataProvider(String s) { ChromeOptions options = new ChromeOptions(); options.setExperimentalOption("mobileEmulation", Map.of("deviceName", s)); driver = new ChromeDriver(options); driver.get(Constants.DROPDOWN_PAGE_URL); DropDownPageFunctions dropDownPageFunctions = new DropDownPageFunctions(driver); TestData testData = JSONUtil.readTestData("002"); dropDownPageFunctions.selectValueFromDropDown(testData.getStringValue()); //Asserts to see if the dropdown selection has been set. Assert.assertTrue(dropDownPageFunctions.isTheGivenValueSelected(testData.getStringValue()), "The given value was not set as the dropdown selection."); } @DataProvider(name = "userAgentsData") public static Object[][] generateData() { return new String[][]{{"iPhone 5"}, {"iPhone 6"}, {"Nexus 6"}}; } }