|
2 | 2 |
|
3 | 3 | import com.browserstack.test.suites.TestBase; |
4 | 4 | import org.openqa.selenium.By; |
| 5 | +import org.openqa.selenium.JavascriptExecutor; |
5 | 6 | import org.openqa.selenium.Keys; |
| 7 | +import org.openqa.selenium.support.ui.ExpectedConditions; |
6 | 8 | import org.testng.Assert; |
7 | 9 | import org.testng.annotations.Test; |
8 | 10 |
|
9 | 11 | public class LoginVisualTest extends TestBase { |
10 | 12 |
|
| 13 | + private boolean changeCSS = true; |
| 14 | + |
11 | 15 | @Test |
12 | 16 | public void loginLockedUser() { |
| 17 | + JavascriptExecutor ex = ((JavascriptExecutor) getDriver()); |
13 | 18 |
|
14 | 19 | percy.snapshot("Check Homepage"); |
15 | 20 | getDriver().findElement(By.id("signin")).click(); |
| 21 | + wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("#username input"))); |
| 22 | + |
| 23 | + if (changeCSS) { |
| 24 | + ex.executeScript("document.getElementById('login-btn').style.backgroundColor = '#FFA500';"); |
| 25 | + ex.executeScript("document.getElementById('login-btn').style.width = '60%';"); |
| 26 | + } |
16 | 27 | percy.snapshot("Check Signin page"); |
17 | 28 | getDriver().findElement(By.cssSelector("#username input")).sendKeys("locked_user" + Keys.ENTER); |
18 | 29 | getDriver().findElement(By.cssSelector("#password input")).sendKeys("testingisfun99" + Keys.ENTER); |
19 | 30 | getDriver().findElement(By.id("login-btn")).click(); |
20 | | - percy.snapshot("Check Login result"); |
21 | 31 |
|
| 32 | + wait.until(ExpectedConditions.visibilityOfElementLocated(By.className("api-error"))); |
| 33 | + if (changeCSS) { |
| 34 | + ex.executeScript("document.getElementsByClassName('api-error')[0].style.fontSize = '200%';"); |
| 35 | + } |
| 36 | + percy.snapshot("Check Login result"); |
22 | 37 | Assert.assertEquals(getDriver().findElement(By.className("api-error")).getText(), "Your account has been locked."); |
23 | 38 | } |
| 39 | + |
24 | 40 | } |
0 commit comments