Module 13- Salesforce Login | Selenium Forum
M
Posted on 07/12/2015
Hi Ashish,

I was practising the exercise of Module 13. The first exercise is to login to sales force and create a new Lead to verify the name. I completed 50% part of it and very badly stuck on next half.

I was able to login the website Salesforce.com click on the Lead and click on the "New" tp create a new Lead. After I click on the "new"
a light-box appears where we need to enter our name.

When i try to enter a Name in the lead Light-box pop up , it throws a
“NoSuchElementException: no such element: Unable to locate element: {"method":"xpath","selector":"html/body/div[5]/div[4]/div[2]/div[2]/div/div[2]/div/div[3]/div[1]/div/input"}”

I tried and google and spent half a day but unable to figure out why. Its it not a pop up or alert ,but still even with the full xpath Iam unable to handle this light-box pop up. On the same light-box pop if I click Save button it works.

PSB the code. I have tried my best with debugging as well. Need your input. The line highlighted in red below throws an error.

import java.util.Iterator;
import java.util.Set;
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;

public class Exercise_Module13_Salesforce {

public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver","E:\\Selenium_Java\\chromedriver_win32\\chromedriver.exe");
WebDriver driver=new ChromeDriver();
// WebDriver driver=new FirefoxDriver();
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);

System.out.println("******** Start ************");
driver.get("https://login.salesforce.com/");
WebElement un=driver.findElement(By.xpath("//*[@id='username']"));
un.sendKeys("abwasha@outlook.com");

System.out.println("******** Start 2************");

WebElement pwd=driver.findElement(By.xpath("//*[@id='password']"));
pwd.sendKeys("Salesforce1");

driver.findElement(By.name("Login")).click();


System.out.println("******** Start 3************");


driver.findElement(By.xpath("//*[@id='oneHeader']/div[3]/div[1]/div[1]/a")).click();

System.out.println("******** Start 4************");

driver.findElement(By.xpath("//*[@id='actionCard_Lead']/a/div/div[2]/div")).click();

System.out.println("******** Start 5************");

driver.findElement(By.xpath("//html/body/div[5]/div[1]/section/div[1]/div[2]/div[2]/div/div[1]/div[1]/div[1]/div/div[2]/div/div/div/div/div[1]/div/div/a")).click();

System.out.println("******** Start 6************");



System.out.println("******** Start 6.1************");


driver.findElement(By.xpath("html/body/div[5]/div[1]/section/div[1]/div[2]/div[2]/div/div[1]/div[1]/div[1]/div/div[2]/div/div/div/div/div[2]/div/ul/li[1]/a")).click();

System.out.println("******** Start 7************");


[color=#FF0000:22345eij][size=200:22345eij]driver.findElement(By.xpath("html/body/div[5]/div[4]/div[2]/div[2]/div/div[2]/div/div[3]/div[1]/div/input")).sendKeys("Shafath");[/size:22345eij]
[/color:22345eij]
driver.findElement(By.xpath("html/body/div[5]/div[4]/div/div[2]/div/div[2]/div/div[4]/div/button[2]")).click();

System.out.println("******** Start 9************");


}

}


Please help.

M
Replied on 07/12/2015

Put Thread.sleep before it for 5 seconds
Sometimes it helps Responsive image