Skip to content

Instantly share code, notes, and snippets.

@KrishnB
Created February 2, 2022 09:57
Show Gist options
  • Save KrishnB/3507c1b733abc4783f4f9e6a8f649afc to your computer and use it in GitHub Desktop.
Save KrishnB/3507c1b733abc4783f4f9e6a8f649afc to your computer and use it in GitHub Desktop.
import org.testng.Assert;
import org.testng.annotations.Test;
public class SearchTests {
@Test
public void verifyIfSearchTermShowsRelevantResults() {
//Arrange
String searchItem = "Jeans";
String searchKey = "Jean";
LauncherPage launcherPage = new LauncherPage(webdriver); // Assume webdriver is created and // handy
launcherPage.navigateTo("https://web-playground.ultralesson.com/");
//Act
HomePage homepage = new HomePage(webdriver);
homepage.search(searchItem);
List<Item> searchItems = homepage.getSearchItems();
//Assert
Assert.assertEquals(4, searchItems.size());
Assert.assertTrue(searchItems.stream().allMatch(item -> item.getName().contains("Jean")));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment