Commit b69f0d8e authored by Khai Yuan ​Liew's avatar Khai Yuan ​Liew

Finish POM Assignment

parents
# Default ignored files
/shelf/
/workspace.xml
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<annotationProcessing>
<profile name="Maven default annotation processors profile" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<module name="POM_Assignment" />
</profile>
</annotationProcessing>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RemoteRepositoriesConfiguration">
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Central Repository" />
<option name="url" value="https://repo.maven.apache.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Maven Central repository" />
<option name="url" value="https://repo1.maven.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="jboss.community" />
<option name="name" value="JBoss Community repository" />
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
</remote-repository>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="MavenProjectsManager">
<option name="originalFiles">
<list>
<option value="$PROJECT_DIR$/pom.xml" />
</list>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_15" default="true" project-jdk-name="11" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Palette2">
<group name="Swing">
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
</item>
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
</item>
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
</item>
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
<initial-values>
<property name="text" value="Button" />
</initial-values>
</item>
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="RadioButton" />
</initial-values>
</item>
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="CheckBox" />
</initial-values>
</item>
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
<initial-values>
<property name="text" value="Label" />
</initial-values>
</item>
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
</item>
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
</item>
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
<preferred-size width="-1" height="20" />
</default-constraints>
</item>
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
</item>
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
</item>
</group>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4" />
\ No newline at end of file
URL=https://www.safeway.com/
username=vkrijegccvsknuvnpv@miucce.com
password=12345678
firstName=Nisum
lastName=TestAcct
phone=3141592635
ccn=49132518493
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>POM_Assignment</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.59</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-chrome-driver</artifactId>
<version>3.141.59</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-api -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-api</artifactId>
<version>3.141.59</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.6.0</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/junit/junit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-engine -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.6.0</version>
<scope>test</scope>
</dependency>
</dependencies>
<properties>
<maven.compiler.source>15</maven.compiler.source>
<maven.compiler.target>15</maven.compiler.target>
</properties>
</project>
\ No newline at end of file
package com.nisum.pages;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import java.util.concurrent.TimeUnit;
public class AccountSettingsPage {
WebDriver driver;
public AccountSettingsPage(WebDriver driver){
this.driver = driver;
driver.manage().timeouts().pageLoadTimeout(5, TimeUnit.SECONDS);
}
public WebElement getLnkAccount() {
return driver.findElement(By.xpath("//span[@class='button__item menu-nav__profile-button-sign-in-up d-none d-lg-inline-block']"));
}
public WebElement getAccountSettings(){
return driver.findElement(By.xpath("/html/body/div[1]/div/div/div[1]/div/div/div/div[3]/div[2]/div[1]/div/div/div[3]/ul/div/div[2]/div[1]/ul/li[4]/a"));
}
public WebElement getFirstName(){
return driver.findElement(By.xpath("//*[@id=\"input-firstName\"]"));
}
public WebElement getLastName(){
return driver.findElement(By.xpath("//*[@id=\"input-lastName\"]"));
}
public WebElement getEmail(){
return driver.findElement(By.xpath("//*[@id=\"emailIdaccount\"]"));
}
public WebElement getPhone(){
return driver.findElement(By.xpath("//*[@id=\"phoneNumber\"]"));
}
public WebElement getCCN(){
return driver.findElement(By.xpath("//*[@id=\"uca-root\"]/main/div/div/div[2]/div/div[6]/div/p[2]"));
}
public void goToAccountSettings(){
WebDriverWait wdw = new WebDriverWait(driver, 10);
try{
wdw.until(ExpectedConditions.elementToBeClickable(getLnkAccount()));
getLnkAccount().click();
getAccountSettings().click();
}catch(org.openqa.selenium.StaleElementReferenceException ex){
wdw.until(ExpectedConditions.elementToBeClickable(getLnkAccount()));
getLnkAccount().click();
getAccountSettings().click();
}
}
}
package com.nisum.pages;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.support.PageFactory;
//Header and Footer - Group them into one class.
//PageFactory
public class HomePage {
WebDriver driver;
public HomePage(WebDriver driver){
this.driver = driver;
PageFactory.initElements(this.driver, this);
}
public void navigateHome(String url){
driver.get(url);
}
}
package com.nisum.pages;
import org.openqa.selenium.*;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import java.util.concurrent.TimeUnit;
public class LoginPage {
WebDriver driver;
public LoginPage(WebDriver driver, String url){
this.driver = driver;
driver.manage().timeouts().pageLoadTimeout(5, TimeUnit.SECONDS);
driver.navigate().to(url);
}
public WebElement getLnkSignIn() {
return driver.findElement(By.xpath("//span[@class='button__item menu-nav__profile-button-sign-in-up d-none d-lg-inline-block']"));
}
public WebElement getMenuItemSignIn(){
return driver.findElement(By.id("sign-in-modal-link"));
}
public WebElement getInpUserName(){
return driver.findElement(By.id("label-email"));
}
public WebElement getInpPassword(){
return driver.findElement(By.id("label-password"));
}
public WebElement getBtnSubmit(){
return driver.findElement(By.id("btnSignIn"));
}
public void login(String username, String password){
getLnkSignIn().click();
getMenuItemSignIn().click();
WebDriverWait wdw = new WebDriverWait(driver, 10);
wdw.until(ExpectedConditions.elementToBeClickable(getInpUserName()));
getInpUserName().sendKeys(username);
getInpPassword().sendKeys(password);
getBtnSubmit().click();
}
}
package com.nisum.testCases;
import com.nisum.pages.AccountSettingsPage;
import com.nisum.pages.LoginPage;
import org.junit.jupiter.api.Test;
import org.junit.Assert;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import java.io.FileReader;
import java.util.Properties;
import java.util.concurrent.TimeUnit;
public class AccSetTestCase {
public static void main(String[] args){
String os = System.getProperty("os.name");
System.out.println("Using System Property: " + os);
}
@Test
public void checkAccountDetails() throws Exception{
System.setProperty("webdriver.chrome.driver", "/opt/WebDriver/bin/chromedriver");
WebDriver driver = new ChromeDriver();
FileReader reader = new FileReader("datafile.properties");
Properties p = new Properties();
p.load(reader);
LoginPage login = new LoginPage(driver, p.getProperty("URL"));
login.login(p.getProperty("username"), p.getProperty("password"));
AccountSettingsPage acc = new AccountSettingsPage(driver);
acc.goToAccountSettings();
WebDriverWait wdw = new WebDriverWait(driver, 10);
wdw.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[@id=\"input-firstName\"]")));
String firstName = acc.getFirstName().getAttribute("value");
String lastName = acc.getLastName().getAttribute("value");
String email = acc.getEmail().getAttribute("value");
String phone = acc.getPhone().getAttribute("value");
String ccn = acc.getCCN().getAttribute("innerHTML"); //getText()
Assert.assertEquals(p.getProperty("firstName"), firstName);
System.out.println("First Name: " + firstName);
Assert.assertEquals(p.getProperty("lastName"), lastName);
System.out.println("Last Name: " + lastName);
Assert.assertEquals(p.getProperty("username"), email);
System.out.println("Email: " + email);
Assert.assertEquals(p.getProperty("phone"), phone);
System.out.println("Phone: " + phone);
Assert.assertEquals(p.getProperty("ccn"), ccn);
System.out.println("CCN: " + ccn);
driver.close();
}
}
package com.nisum.testCases;
import com.nisum.pages.HomePage;
import org.junit.jupiter.api.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class HomeTestCase {
@Test
public void goToHome() throws Exception{
System.setProperty("webdriver.chrome.driver", "/opt/WebDriver/bin/chromedriver");
WebDriver driver = new ChromeDriver();
HomePage home = new HomePage(driver);
home.navigateHome("https://www.safeway.com/");
Thread.sleep(10000);
driver.close();
}
}
package com.nisum.testCases;
import com.nisum.pages.LoginPage;
import org.junit.Assert;
import org.junit.jupiter.api.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import java.io.FileReader;
import java.util.Properties;
import java.util.concurrent.TimeUnit;
public class LoginTestCase {
@Test
public void testLogin() throws Exception{
System.setProperty("webdriver.chrome.driver", "/opt/WebDriver/bin/chromedriver");
WebDriver driver = new ChromeDriver();
FileReader reader = new FileReader("datafile.properties");
Properties p = new Properties();
p.load(reader);
LoginPage login = new LoginPage(driver, p.getProperty("URL"));
login.login(p.getProperty("username"), p.getProperty("password"));
System.out.println("Logged In!");
driver.close();
}
}
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