Advertisement
Guest User

Untitled

a guest
Mar 19th, 2017
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.85 KB | None | 0 0
  1. java.lang.NullPointerException
  2. at com.gptoday.pages.Login.ClickJoin(Login.java:20)
  3. at com.gptoday.com.gptoday.testcases.LoginVerification.f(LoginVerification.java:40)
  4. at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  5. at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
  6. at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
  7. at java.lang.reflect.Method.invoke(Unknown Source)
  8. at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:108)
  9. at org.testng.internal.Invoker.invokeMethod(Invoker.java:661)
  10. at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:869)
  11. at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1193)
  12. at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:126)
  13. at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
  14. at org.testng.TestRunner.privateRun(TestRunner.java:744)
  15. at org.testng.TestRunner.run(TestRunner.java:602)
  16. at org.testng.SuiteRunner.runTest(SuiteRunner.java:380)
  17. at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:375)
  18. at org.testng.SuiteRunner.privateRun(SuiteRunner.java:340)
  19. at org.testng.SuiteRunner.run(SuiteRunner.java:289)
  20. at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
  21. at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
  22. at org.testng.TestNG.runSuitesSequentially(TestNG.java:1301)
  23. at org.testng.TestNG.runSuitesLocally(TestNG.java:1226)
  24. at org.testng.TestNG.runSuites(TestNG.java:1144)
  25. at org.testng.TestNG.run(TestNG.java:1115)
  26. at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:132)
  27. at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:230)
  28. at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:76)
  29.  
  30. **My code for Login Page:**
  31. package com.gptoday.pages;
  32. import org.openqa.selenium.By;
  33. import org.openqa.selenium.WebDriver;
  34. public class Login {
  35.  
  36. public WebDriver driver;
  37. By join = By.xpath("//*[@id='members']/a[1]");
  38. By username = By.id("username");
  39. By password = By.id("password");
  40. By loginButton = By.name("Login");
  41.  
  42. /*public Login(WebDriver driver){
  43. this.driver=driver;
  44. }*/
  45.  
  46. public void ClickJoin(){
  47. driver.findElement(join).click();
  48. System.out.println("Clicked Join");
  49. }
  50.  
  51. public void EnterUsername(){
  52. driver.findElement(username).clear();
  53. driver.findElement(username).click();
  54. System.out.println("Username Entered");
  55. }
  56.  
  57. public void EnterPassword(){
  58. driver.findElement(password).clear();
  59. driver.findElement(password).click();
  60. System.out.println("Password Entered");
  61. }
  62.  
  63. public void ClickButton(){
  64. driver.findElement(loginButton).click();
  65. System.out.println("Login Button Clicked");
  66. }
  67.  
  68. }
  69.  
  70. **My Code for "Verification Testcase":**
  71. package com.gptoday.com.gptoday.testcases;
  72.  
  73. import org.testng.annotations.Test;
  74. import com.gptoday.pages.Login;
  75. import org.testng.annotations.BeforeTest;
  76. import org.testng.annotations.AfterTest;
  77. import org.junit.AfterClass;
  78. import org.junit.BeforeClass;
  79. import org.openqa.selenium.By;
  80. import org.openqa.selenium.WebDriver;
  81. import org.openqa.selenium.firefox.FirefoxDriver;
  82. import org.openqa.selenium.firefox.FirefoxProfile;
  83. import org.openqa.selenium.firefox.internal.ProfilesIni;
  84.  
  85. public class LoginVerification {
  86.  
  87. public WebDriver driver;
  88. Login obj = new Login();
  89.  
  90. /*LoginVerification(WebDriver driver){
  91. this.driver =driver;
  92. }*/
  93.  
  94. @BeforeTest
  95. public void amg() {
  96. ProfilesIni prof = new ProfilesIni();
  97. FirefoxProfile ffProfile= prof.getProfile ("vishvesh");
  98. ffProfile.setAcceptUntrustedCertificates(true);
  99. ffProfile.setAssumeUntrustedCertificateIssuer(false);
  100.  
  101. String base_url = "https://www.gptoday.com/";
  102. System.setProperty("webdriver.gecko.driver", "G:/Workplace/AutomationSetupFiles/Geckdriver1/geckodriver.exe");
  103. driver = new FirefoxDriver(ffProfile);
  104. driver.get(base_url);
  105. }
  106. @Test
  107. public void f() {
  108. driver.manage().window().maximize();
  109. obj.ClickJoin();
  110. //driver.findElement(By.xpath("//*[@id='members']/a[1]")).click();
  111. obj.EnterUsername();
  112. obj.EnterPassword();
  113. //obj.ClickButton();
  114. //driver.navigate().refresh();
  115. //WebDriverWait wait = new WebDriverWait(driver,10);
  116. //wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[@id='fpBox1']/a/div")));
  117. }
  118.  
  119. @AfterTest
  120. public void just() {
  121. System.out.println("Success");
  122. }
  123.  
  124. }
  125.  
  126. enter code here
  127. @AfterTest
  128. public void just() {
  129. System.out.println("Success");
  130. }
  131.  
  132. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement