Skip to content
This repository has been archived by the owner on Nov 29, 2018. It is now read-only.

I Have written the code for the gmail login to valid 10 login creditanals,When im running the code getting the problem as below given.PLease verify the code as well as problem and give the solution. #7761

Closed
lukeis opened this issue Mar 4, 2016 · 2 comments

Comments

@lukeis
Copy link
Member

lukeis commented Mar 4, 2016

Originally reported on Google Code with ID 7761

package SeleniumtestNG;
import java.io.FileInputStream;
import jxl.Sheet;
import jxl.Workbook;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.Test;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.AfterTest;
import com.thoughtworks.selenium.Selenium;
public class GmailLogin {
    public WebDriver driver;
    public Selenium selenium;
  @Test
  public void Verifygmaillogin() throws Exception{
      FileInputStream fi=new FileInputStream("D:\\Workspace_Latest\\Automation\\Testdata\\Logingmail.xls");
      Workbook w=Workbook.getWorkbook(fi);
      Sheet s=w.getSheet("gmail");
      for (int i = 1; i < s.getRows(); i++) {
          driver.findElement(By.id("Email")).sendKeys(s.getCell(0,i).getContents());
        driver.findElement(By.id("Passwd")).sendKeys(s.getCell(1,i).getContents());
          driver.findElement(By.id("signIn")).click();Thread.sleep(6000);
 if (selenium.isElementPresent(".//*[@id='gb']/div[1]/div[1]/div[2]/div[5]/div[1]/a/span"))
{
driver.findElement(By.xpath(".//*[@id='gb']/div[1]/div[1]/div[2]/div[5/div[1]/a/span")).click();
             }
if (selenium.isElementPresent("Sign out")) { driver.findElement(By.linkText("Sign out")).click();
 if(selenium.isElementPresent("Sign in with a different account")){
driver.findElement(By.linkText("Sign in with a different account")).click();
}
        } else {
System.out.println("Invalid Creditnals");
}
      }
  }
  @BeforeTest
  public void beforeTest() {
    driver=new FirefoxDriver();
    driver.get("http://gmail.com");
    driver.manage().window().maximize();
     }
 @AfterTest
  public void afterTest() {
  }

}
--------------
[TestNG] Running:
  C:\Users\chandra\AppData\Local\Temp\testng-eclipse--1306388759\testng-customsuite.xml

FAILED: Verifygmaillogin
java.lang.NullPointerException
    at SeleniumtestNG.GmailLogin.Verifygmaillogin(GmailLogin.java:29)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)
    at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)
    at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
    at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
    at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
    at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
    at org.testng.TestRunner.privateRun(TestRunner.java:767)
    at org.testng.TestRunner.run(TestRunner.java:617)
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
    at org.testng.SuiteRunner.run(SuiteRunner.java:240)
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)
    at org.testng.TestNG.run(TestNG.java:1057)
    at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
    at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)


===============================================
    Default test
    Tests run: 1, Failures: 1, Skips: 0
===============================================


===============================================
Default suite
Total tests run: 1, Failures: 1, Skips: 0
===============================================

[TestNG] Time taken by org.testng.reporters.SuiteHTMLReporter@1beea90: 129 ms
[TestNG] Time taken by org.testng.reporters.XMLReporter@402e11: 17 ms
[TestNG] Time taken by [FailedReporter passed=0 failed=0 skipped=0]: 14 ms
[TestNG] Time taken by org.testng.reporters.jq.Main@d75cf7: 61 ms
[TestNG] Time taken by org.testng.reporters.JUnitReportReporter@17035c6: 12 ms
[TestNG] Time taken by org.testng.reporters.EmailableReporter2@1189cbb: 12 ms

Reported by suryash143 on 2014-08-16 17:54:47

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

This is not the proper forum for general help requests. Please direct your question
to selenium-users@googlegroups.com

Reported by jmleyba on 2014-08-17 05:13:28

  • Status changed: Invalid
  • Labels removed: Status-Untriaged

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

Reported by luke.semerau on 2015-09-17 18:24:20

  • Labels added: Restrict-AddIssueComment-Commit

@lukeis lukeis closed this as completed Mar 4, 2016
@SeleniumHQ SeleniumHQ locked and limited conversation to collaborators Mar 4, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant