Last active
October 1, 2021 06:33
-
-
Save dtopuzov/373a8f4c8962b5d23a820c3cf23226ac to your computer and use it in GitHub Desktop.
This file contains 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
public class SmokeTest { | |
private WebDriver driver; | |
@BeforeClass | |
public void beforeClass() { | |
WebDriverManager.chromedriver().setup(); | |
ChromeOptions options = new ChromeOptions(); | |
driver = new ChromeDriver(options); | |
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(10)); | |
driver.manage().window().maximize(); | |
driver.navigate().to("https://github.com/"); | |
} | |
@AfterClass(alwaysRun = true) | |
public void afterClass() { | |
driver.quit(); | |
} | |
@Test | |
public void testSearchFeature(){ | |
// This test should verify that search works. | |
WebElement searchBox = driver.findElement(By.name("q")); | |
searchBox.sendKeys("selenium"); | |
searchBox.submit(); | |
WebElement seleniumHQLink = driver.findElement(By.linkText("SeleniumHQ/selenium")); | |
Assert.assertTrue(seleniumHQLink.isDisplayed()); | |
Assert.assertTrue(driver.getCurrentUrl().startsWith("https://github.com/search?q=selenium")); | |
} | |
@Test | |
public void testResponsiveLayout() { | |
// This test should verify that in lower resolution search is not displayed. | |
// Instead of it hamburger menu should be available. | |
Dimension dimension = new Dimension(800, 600); | |
driver.manage().window().setSize(dimension); | |
WebElement searchBox =driver.findElement(By.name("q")); | |
Assert.assertFalse(searchBox.isDisplayed()); | |
By hamburgerMenuLocator = By.cssSelector("button[aria-label='Toggle navigation']"); | |
WebElement hambugerMenu = driver.findElement(hamburgerMenuLocator); | |
Assert.assertTrue(hambugerMenu.isDisplayed()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment