Created
February 22, 2024 06:23
-
-
Save SarahElson/fd72af8baeb7fd2bd3c75f63c2c03981 to your computer and use it in GitHub Desktop.
Automate UI Tests With Selenium
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package demo; | |
import org.openqa.selenium.By; | |
import org.openqa.selenium.WebDriver; | |
import org.openqa.selenium.chrome.ChromeDriver; | |
import org.testng.Assert; | |
import org.testng.annotations.Test; | |
public class DemoClass { | |
@Test | |
public void title_test() { | |
/* Initializing ChromeDriver, for any other browser, use its respective driver class */ | |
WebDriver driver = new ChromeDriver(); | |
// Opening the Lambdatest E-Commerce Playground | |
driver.get("https://ecommerce-playground.lambdatest.io/"); | |
/* Retrieving the text of a “TOP TRENDING CATEGORIES” element by locating using cssSelection attribute */ | |
String val = driver.findElement(By.cssSelector(".module-title")).getText(); | |
// Verifying the Outcomes | |
Assert.assertEquals( val, "TOP TRENDING CATEGORIES"); | |
// Closing the WebDriver and terminating the browser session. | |
driver.quit(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment