Commit 7d103107 authored by Shaphen Pangburn's avatar Shaphen Pangburn

Modify configurations and add code to test working functionality

parent 23d21892
plugins { plugins {
id 'org.springframework.boot' version '2.4.4'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'java' id 'java'
} }
group = 'com.nisum.pom-page-factory' group 'com.nisum.pom-page-factory'
version = '0.0.1-SNAPSHOT' version '0.0.1-SNAPSHOT'
sourceCompatibility = '11'
repositories { repositories {
mavenCentral() mavenCentral()
} }
dependencies { dependencies {
implementation 'org.springframework.boot:spring-boot-starter' implementation group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '3.141.59'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.6.0'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'
} }
test { test {
......
package com.nisum.pompagefactory.practice;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class PracticeApplication {
public static void main(String[] args) {
SpringApplication.run(PracticeApplication.class, args);
}
}
package com.nisum.pompagefactory.practice;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class PracticeApplicationTests {
@Test
void contextLoads() {
}
}
package com.nisum.pompagefactory.practice;
import org.junit.jupiter.api.*;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import static org.junit.jupiter.api.Assertions.assertEquals;
class SafewayLogin {
@Test
public void testSafewayLogin() throws InterruptedException {
System.setProperty("webdriver.chrome.driver", "/Users/spangburn/Desktop/nisum_learning/drivers/chromedriver");
WebDriver driver = new ChromeDriver();
driver.get("https://www.safeway.com/");
Thread.sleep(1000);
WebElement signInDropdown = driver.findElement(By.linkText("Sign In / Up"));
signInDropdown.click();
Thread.sleep(1000);
WebElement signInButton = driver.findElement(By.id("sign-in-modal-link"));
signInButton.click();
Thread.sleep(2000);
WebElement trySignIn = driver.findElement(By.id("btnSignIn"));
trySignIn.click();
Thread.sleep(5000);
WebElement failedText1 = driver.findElement(By.xpath("//*[@id=\"errorMsgEmail\"]/ul/li"));
WebElement failedText2 = driver.findElement(By.xpath("//*[@id=\"errorMsgPwd\"]/ul/li"));
assertEquals("Please enter your email address.", failedText1.getText());
assertEquals("Please enter a password.", failedText2.getText());
driver.quit();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment