Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Selenium with SESALESFORCE-3
  • Loading branch information
JoaquinGonzales committed Mar 24, 2017
commit cb3f1b4d5eccf9ceb98f7f569c18891a9a492153
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.jalasoft.selenium.joaquin.Selenium.SalesForce;

import org.openqa.selenium.support.ui.ExpectedConditions;

/**
* Created by Joaquin Gonzales on 3/23/2017.
*/
public class AccountPage extends BaseHome {
@Override
protected CreateAccountPage clickNew() {
wait.until(ExpectedConditions.visibilityOfElementLocated(newButton));
driver.findElement(newButton);
return new CreateAccountPage();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.jalasoft.selenium.joaquin.Selenium.SalesForce;

import org.openqa.selenium.By;

/**
* Created by Joaquin Gonzales on 3/20/2017.
*/
public abstract class BaseHome extends BasePage{
protected By newButton = By.cssSelector("div[title='New']");
protected abstract BasePage clickNew();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.jalasoft.selenium.joaquin.Selenium.SalesForce;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.WebDriverWait;

import java.util.concurrent.TimeUnit;

/**
* Created by Joaquin Gonzales on 3/20/2017.
*/
public abstract class BasePage {
protected WebDriver driver;
protected WebDriverWait wait;
public BasePage()
{
driver = DriverManager.getInstance().getDriver();
wait = DriverManager.getInstance().getWait();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.jalasoft.selenium.joaquin.Selenium.SalesForce;

import org.openqa.selenium.By;
import org.openqa.selenium.support.ui.ExpectedConditions;

/**
* Created by Joaquin Gonzales on 3/23/2017.
*/
public class CreateAccountPage extends BasePage {
public By accountNameTextField = By.cssSelector("div[data-aura-class='uiInput witsSuggestedNameField uiInput--default'] input");
public By setTypeAccount = By.cssSelector("div[aria-label='Type - Type'] a[class='select']");


public void setAccountName(String accountName)
{
wait.until(ExpectedConditions.visibilityOfElementLocated(accountNameTextField));
driver.findElement(accountNameTextField).sendKeys(accountName);
}
public void setTypeAccount(String typeAccount)
{
wait.until(ExpectedConditions.visibilityOfElementLocated(setTypeAccount));
driver.findElement(setTypeAccount).click();
driver.findElement(By.cssSelector(String.format("a[title='%s']",typeAccount))).click();
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.jalasoft.selenium.joaquin.Selenium.SalesForce;

import org.apache.bcel.generic.NEW;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
Expand All @@ -9,21 +10,23 @@
/**
* Created by Joaquin Gonzales on 3/15/2017.
*/
public class CreateOportunityPage {
public class CreateOportunityPage extends BasePage{

private WebDriver driver;
private WebDriverWait wait;
private By opportunityTextField = By.xpath("//span[text()='Opportunity Name']/ancestor::label/following-sibling::input");
private By opportunityTextField = By.xpath("//span[text()='Opportunity Name']/ancestor::label/following-sibling::input");
private By opportunityAccountTextField = By.cssSelector("input[placeholder = 'Search Accounts']");
private By closeDateField = By.cssSelector("div[class='form-element'] input");
private By stageSelect = By.cssSelector("div[aria-label='Stage - Stage*Qualification'] a[class='select']");
private By saveButton = By.cssSelector("button[title='Save']");
private By typeDropBox = By.cssSelector("div[aria-label='Type - Type'] a[class='select']");
private By budgetConfirm = By.cssSelector("div[class='uiInput uiInputCheckbox uiInput--default uiInput--checkbox'] input[data-interactive-lib-uid='15']");
private By lossReason = By.cssSelector("a[aria-label='Loss Reason']");
//private By lossReasonSelection = By.cssSelector("a[title='Lost to Competitor']");
private By nextStepTextField = By.cssSelector("div[aria-label='Next Step - Next Step'] input");
private By descriptionTextArea = By.cssSelector("div[data-aura-class='uiInput uiInputTextArea uiInput--default uiInput--textarea'] textarea");
private By probabilityTextField = By.cssSelector("div[aria-label='Probability (%) - Probability (%)'] input");
private By amountTextField = By.cssSelector("div[aria-label='Amount - Amount'] input");

public CreateOportunityPage(WebDriver driver, WebDriverWait wait)
{
this.driver = driver;
this.wait = wait;
}
public void setOpportunityNameTextField(String opportunityName)
public void setOpportunityNameTextField(String opportunityName)
{
wait.until(ExpectedConditions.visibilityOfElementLocated(opportunityTextField));
driver.findElement(opportunityTextField).sendKeys(opportunityName);
Expand All @@ -34,6 +37,33 @@ public void setOpportunityAccountTextField(String opportunityAccount)
driver.findElement(opportunityAccountTextField).click();
driver.findElement(By.cssSelector(String.format("div[title='%s']", opportunityAccount))).click();
}
public void selectType(String typeAccount)
{
wait.until(ExpectedConditions.visibilityOfElementLocated(typeDropBox));
driver.findElement(typeDropBox).click();
driver.findElement(By.cssSelector(String.format("a[title='%s']", typeAccount))).click();
}
public void setBudgetConfirm()
{
wait.until(ExpectedConditions.visibilityOfElementLocated(budgetConfirm));
driver.findElement(budgetConfirm).click();
}
public void selectLossReason(String lossSelection)
{
wait.until(ExpectedConditions.visibilityOfElementLocated(lossReason));
driver.findElement(lossReason).click();
driver.findElement(By.cssSelector(String.format("a[title='%s']", lossSelection))).click();
}
public void setNextStep(String nextStepText)
{
wait.until(ExpectedConditions.visibilityOfElementLocated(nextStepTextField));
driver.findElement(nextStepTextField).sendKeys(nextStepText);
}
public void setDescriptionTextArea(String description)
{
wait.until(ExpectedConditions.visibilityOfElementLocated(descriptionTextArea));
driver.findElement(descriptionTextArea).sendKeys(description);
}
public void setCloseDate(String date)
{
wait.until(ExpectedConditions.visibilityOfElementLocated(closeDateField));
Expand All @@ -45,4 +75,20 @@ public void selectStage(String selection)
driver.findElement(stageSelect).click();
driver.findElement(By.cssSelector(String.format("a[title='%s']", selection))).click();
}
public void setProbabilityTextField(String probality)
{
wait.until(ExpectedConditions.visibilityOfElementLocated(probabilityTextField));
driver.findElement(probabilityTextField).sendKeys();
}
public void setAmountTextField(String amount)
{
wait.until(ExpectedConditions.visibilityOfElementLocated(amountTextField));
driver.findElement(amountTextField).sendKeys(amount);
}
public void saveOpportunity()
{
wait.until(ExpectedConditions.visibilityOfElementLocated(saveButton));
driver.findElement(saveButton).click();
//return new OportunityPage(driver,wait);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.jalasoft.selenium.joaquin.Selenium.SalesForce;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.WebDriverWait;

import java.util.concurrent.TimeUnit;

/**
* Created by Joaquin Gonzales on 3/20/2017.
*/
public class DriverManager {
private static DriverManager instance;
private WebDriver driver;
private WebDriverWait wait;
private DriverManager()
{
System.setProperty("webdriver.chore.driver","chromedriver.exe");
driver = new ChromeDriver();
driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
driver.get("https://login.salesforce.com/");
driver.manage().window().maximize();
wait = new WebDriverWait(driver,30);
}

public static DriverManager getInstance()
{
if (instance == null)
{
instance = new DriverManager();
}
return instance;
}
public WebDriver getDriver()
{
return driver;
}
public WebDriverWait getWait()
{
return wait;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,11 @@
/**
* Created by Joaquin Gonzales on 3/15/2017.
*/
public class HomePage {
public WebDriver driver;
public WebDriverWait wait;
public class HomePage extends BasePage {

private By profileItem = By.cssSelector(".profileTrigger");
private By profileNameText = By.cssSelector(".profile-card-name .profile-link-label");
private By oportunitiesTab = By.cssSelector("a[title='Opportunities']");

public HomePage(WebDriver driver, WebDriverWait wait)
{
this.wait = wait;
this.driver = driver;
}
//private By oportunitiesTab = By.cssSelector("a[title='Opportunities']");

public void clickProfileIcon()
{
Expand All @@ -33,8 +26,9 @@ public String getProfileName()
}
public OportunityPage clikOportunitiesTab()
{
wait.until(ExpectedConditions.visibilityOfElementLocated(oportunitiesTab));
return NavigationBar.clickOpportunity();
/* wait.until(ExpectedConditions.visibilityOfElementLocated(oportunitiesTab));
driver.findElement(oportunitiesTab).click();
return new OportunityPage(driver,wait);
return new OportunityPage();*/
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,12 @@
/**
* Created by Joaquin Gonzales on 3/15/2017.
*/
public class LoginPage {
public WebDriver driver;
public WebDriverWait wait;
public class LoginPage extends BasePage {

private By username = By.id("username");
private By password = By.id("password");
private By login = By.id("Login");

public LoginPage()
{
System.setProperty("webdriver.chore.driver","chromedriver.exe");
driver = new ChromeDriver();
driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
driver.get("https://login.salesforce.com/");
wait = new WebDriverWait(driver,30);
}
public void setUserNameTextField(String userName)
{
wait.until(ExpectedConditions.visibilityOfElementLocated(username));
Expand All @@ -41,7 +32,7 @@ public HomePage clickLoginButton()
{
wait.until(ExpectedConditions.elementToBeClickable(login));
driver.findElement(login).click();
return new HomePage(driver,wait);
return new HomePage();
}

}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.jalasoft.selenium.joaquin.Selenium.SalesForce;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

/**
* Created by Joaquin Gonzales on 3/20/2017.
*/
public class NavigationBar {

private NavigationBar()
{

}
public static OportunityPage clickOpportunity()
{
WebDriver driver = DriverManager.getInstance().getDriver();
WebDriverWait wait = DriverManager.getInstance().getWait();
wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("a[title='Opportunities']")));
driver.findElement(By.cssSelector("a[title='Opportunities']")).click();
return new OportunityPage();
}
public static AccountPage clickAccountTab()
{
WebDriver driver = DriverManager.getInstance().getDriver();;
WebDriverWait wait = DriverManager.getInstance().getWait();
wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("a[title='Accounts']")));
driver.findElement(By.cssSelector("a[title='Accounts']")).click();
return new AccountPage();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,12 @@
/**
* Created by Joaquin Gonzales on 3/15/2017.
*/
public class OportunityPage {
private WebDriver driver;
private WebDriverWait wait;
private By newButton = By.cssSelector("div[title='New']");
public class OportunityPage extends BaseHome{

public OportunityPage(WebDriver driver,WebDriverWait wait)
{
this.driver = driver;
this.wait = wait;
}
public CreateOportunityPage clickNewOpportunity()
{
@Override
public CreateOportunityPage clickNew() {
wait.until(ExpectedConditions.visibilityOfElementLocated(newButton));
driver.findElement(newButton).click();
return new CreateOportunityPage(driver,wait);
return new CreateOportunityPage();
}
}
16 changes: 11 additions & 5 deletions src/test/java/com/jalasoft/selenium/Joaquin/LoginTest.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package com.jalasoft.selenium.Joaquin;

import com.jalasoft.selenium.joaquin.Selenium.SalesForce.CreateOportunityPage;
import com.jalasoft.selenium.joaquin.Selenium.SalesForce.HomePage;
import com.jalasoft.selenium.joaquin.Selenium.SalesForce.LoginPage;
import com.jalasoft.selenium.joaquin.Selenium.SalesForce.OportunityPage;
import com.jalasoft.selenium.joaquin.Selenium.SalesForce.*;
import org.junit.Assert;
import org.junit.Test;

Expand Down Expand Up @@ -33,10 +30,19 @@ public void testOpportunities()
login.setPasswordField("P4ssw0rd_1");
HomePage home= login.clickLoginButton();
OportunityPage opportunityPage = home.clikOportunitiesTab();
CreateOportunityPage createOpportunityPage = opportunityPage.clickNewOpportunity();
CreateOportunityPage createOpportunityPage = opportunityPage.clickNew();
createOpportunityPage.setOpportunityNameTextField("joaquin");
createOpportunityPage.setOpportunityAccountTextField("Testamerica Inc");
createOpportunityPage.selectType("Existing Business");
createOpportunityPage.setBudgetConfirm();
createOpportunityPage.selectLossReason("Lost to Competitor");
createOpportunityPage.setNextStep("Next Step");
createOpportunityPage.setDescriptionTextArea("this is a description");
createOpportunityPage.setCloseDate("10/07/2018");
createOpportunityPage.selectStage("Qualification");
createOpportunityPage.setProbabilityTextField("10");
createOpportunityPage.setAmountTextField("1200");
createOpportunityPage.saveOpportunity();

}
}