Salesforce With Selenium

Salesforce With Selenium

This is my First post for Salesforce with Selenium. In this post, we will understand why we use selenium in salesforce and how we are using selenium with salesforce. We will also look into what results are achieved by using selenium.

This post based on WHW. 

WHW stands for Why How and What

TheGoldenCircle.jpg1. WHY:  As we all know Salesforce has its own unit testing classes to test the apex code but these classes have their own limitations. That is why we are coming up with integration between Selenium and Salesforce to overcome these limitations. Let us now discuss the Open Source Automation Tool  "Selenium". 

Selenium: We are using Selenium WebDriver because Selenium IDE has many limitations which are as follows:

  • Its works on Mozilla Browser
  • It is a GUI Plug-in

seltest.jpg

2. HOW: We need to install Selenium, along with another software.

Installation of Selenium:

Please Click here for Installation. We have taken a simple login scenario for Salesforce.

Login in Salesforce:

Here is a screenshot of Code

2017-09-10 17_04_18-Java - SalesForceWithSelenium_src_LoginInSalesforce.java - Eclipse.png

Sample Code:

import java.io.File;
import java.io.File;
import java.io.IOException;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.ExpectedCondition;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

public class LoginInSalesforce {
    private static WebDriver driver; 
    public static WebDriverWait wd;  
    public static void main(String[] args) throws IOException, InterruptedException { 
        System.setProperty("webdriver.chrome.driver", new File(".").getCanonicalFile()+ "\\Drivers\\Chrome\\chromedriver.exe"); 
        driver= new ChromeDriver(); 
        System.out.println("Opening URL"); 
        driver.get("https://login.salesforce.com"); 
        wd= new WebDriverWait(driver, 30); 
        wd.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//input[@id='username']"))); 

        // Enter username in textbox 
        System.out.println("Enter username in textbox"); 
        driver.findElement(By.xpath("//input[@id='username']")).sendKeys("Type your UserName" ); 

        //Enter Password in textbox 
        System.out.println("Enter Password in textbox"); 
        driver.findElement(By.xpath("//input[@id='password']")).sendKeys("type your password");

        //Click on Login button 
        System.out.println("Click on Login button"); 
        driver.findElement(By.xpath("//input[@id='Login']")).click(); 
        Thread.sleep(2000); 
        System.out.println("Login Sucessfully"); driver.close(); 
    }
}

3. What:  Here I have attached a video of the automation process.

Apex Test Classes + Selenium= Good Salesforce App Quality

Video:  

Popular Salesforce Blogs