i cannot run the code.
can you send the screen shot firebug of company text box.
package p111;
import java.util.List;
import java.util.ArrayList;
import java.util.concurrent.TimeUnit;
import org.junit.rules.Timeout;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;
import org.openqa.selenium.firefox.internal.ProfilesIni;
import org.openqa.selenium.support.ui.Select;
public class Excercise1_salesforce {
public static void main(String[] args) {
// TODO Auto-generated method stub
ProfilesIni prof = new ProfilesIni();
FirefoxProfile p = prof.getProfile("Chaitra");
WebDriver w=new FirefoxDriver(p);
//open main page salesforce
w.navigate().to("http://www.salesforce.com/");
w.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
//click login
w.findElement(By.xpath("//*[@id='button-login']")).click();
w.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
//w.findElement(By.xpath(xpathExpression))
//Enter data into fields
w.findElement(By.xpath("//*[@id='username']")).sendKeys("chaitra.jagirdar7@gmail.com");
w.findElement(By.xpath("//*[@id='password']")).sendKeys("Chaitra7");
w.findElement(By.xpath("//*[@id='Login']")).click();
w.manage().timeouts().implicitlyWait(50, TimeUnit.SECONDS);
//Click on "Lead" >"New"
//w.findElement(By.className("toggleNav desktop forceIcon oneHeaderButton")).click();
//w.manage().timeouts().implicitlyWait(50, TimeUnit.SECONDS);////*[@id='actionCard_Lead']/a/div/div[2]/div
w.findElement(By.xpath("//*[@id='actionCard_Lead']/a/div/div[2]/div")).click();
w.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
w.findElement(By.xpath("html/body/div[5]/div[1]/section/div[1]/div[2]/div[2]/div/div[1]/div[1]/div[2]/div/div/ul/li/a")).click();
w.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
w.manage().window().maximize();
//Enter "Lead Status","Name"
WebElement WE=w.findElement(By.xpath("//*[starts-with(@id,'40:')]"));
Select s=new Select(WE);
s.selectByIndex(4);
//----------------------------------------------------------------------
WebElement y=w.findElement(By.xpath("//*[starts-with(@id,'8')]"));
s=new Select(y);
s.selectByIndex(4);
//------------------------------------------------------------------
y=w.findElement(By.xpath("//*[starts-with(@id,'11')]"));
y.sendKeys("Jagirdar");
w.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
//=========================================================================
//This code is to enter "AGI" into "Company" field
w.findElement(By.xpath("//*[starts-with(@id,'174:')]")).sendKeys("AGI");//Does not execute
w.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
//================================================================================
WebElement X;
X=w.findElement(By.xpath("html/body/div[5]/div[4]/div/div[2]/div/div[3]/div/button[2]"));
X.click();
w.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
System.out.println("hiiiiiiii" +w.getTitle());
}
}
seems like you have to use absolute path or make your own custom xpath(which have been explained in module 13 ).