0
public class LoginPage { 
   private final WebDriver driver;  
   public LoginPage(WebDriver driver) 
   {    
      this.driver = driver; 
   }   
   public void loginAs(String username, String password)
   {  
      /* driver.get("https://login.salesforce.com/?locale=uk"); 
      driver.manage().timeouts().implicitlyWait(05, TimeUnit.SECONDS);
      System.out.println("READ");
      // System.out.println(driver.findElement(By.id("pwcaps")).getText());
      //driver.findElement(By.id(username)).sendKeys("sambit");
      //driver.findElement(By.className(password)).sendKeys("PWD");
      //driver.findElement(By.id(username)).sendKeys("Password");   
      /*if (driver.findElement(By.className("loginButton")).isEnabled())
      {
         System.out.println("entered If loop");
         System.out.println("login Button is enabled");
         driver.findElement(By.className("loginButton")).click();
      }
      else
      {
         driver.close();
      }*/
      if (driver.findElement(By.id("Account_Tab")).isEnabled())
      {
         System.out.println("Account tab is enabled");
      }
      else
      {
         System.out.println("Account tab is not enabled");
      }
   }
   public static void main(String[] args){
      // TODO Auto-generated method stub

      LoginPage login = new LoginPage(new InternetExplorerDriver());  
      login.loginAs("sambit.sabyasachi", "check");
    }

The webpage shows that this field does not enable automatic filling of the form

1
  • I tried running this snipet, but the problem is my script is not able to enter username and pwd in to the saleforce application.The statements have been commented to highlight them Commented Oct 26, 2012 at 9:41

2 Answers 2

1

Please check this code it work fine for me

   public class login 
   {
     public static void main(String[] args) 
      {
        DesiredCapabilities ieCapabilities = DesiredCapabilities.internetExplorer(); 
                    ieCapabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);

          WebDriver iedriver = new InternetExplorerDriver(ieCapabilities);
          iedriver.get("https://login.salesforce.com/?locale=uk");

           try {
              Thread.sleep(4000);
               } catch (Exception e) {
            // TODO: handle exception
             }
                 driver.findElement(By.id("username")).sendKeys("username");   
                 driver.findElement(By.id("password")).sendKeys("password");   
                 driver.findElement(By.id("Login")).click();   

 }
  }
Sign up to request clarification or add additional context in comments.

Comments

0

try the following login function.

public void login(String username, String password){
    driver.findElement(By.name("username")).sendKeys(username);
    driver.findElement(By.cssSelector("input[type='password']")).sendKeys(password);
    driver.findElement(By.cssSelector("input[type='submit']")).click();
}

I am not sure what your intentions are once you are logged in, but this works for us for our salesforce based application testing.

You would call this function after loading up the login page.

2 Comments

I tried this, but this also is not working for me. I am currently using IE8. Following is the error message:Unable to find element with css selector == input[type='password'] (WARNING: The server did not provide any stacktrace information)
I just copied this from the Live salesforce login screen. <input class="txtbox glow" type="password" id="password" name="pw" size="18" autocomplete="off" onkeypress="checkCaps(event)"> If it is similar to the HTML that you have for the password field for Salesforce login screen, then you can use name, id or the css selector described above. If it does not work then can you show me the code that you have for your test?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.