Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- java.lang.NullPointerException
- at com.gptoday.pages.Login.ClickJoin(Login.java:20)
- at com.gptoday.com.gptoday.testcases.LoginVerification.f(LoginVerification.java:40)
- 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:108)
- at org.testng.internal.Invoker.invokeMethod(Invoker.java:661)
- at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:869)
- at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1193)
- at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:126)
- at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
- at org.testng.TestRunner.privateRun(TestRunner.java:744)
- at org.testng.TestRunner.run(TestRunner.java:602)
- at org.testng.SuiteRunner.runTest(SuiteRunner.java:380)
- at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:375)
- at org.testng.SuiteRunner.privateRun(SuiteRunner.java:340)
- at org.testng.SuiteRunner.run(SuiteRunner.java:289)
- at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
- at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
- at org.testng.TestNG.runSuitesSequentially(TestNG.java:1301)
- at org.testng.TestNG.runSuitesLocally(TestNG.java:1226)
- at org.testng.TestNG.runSuites(TestNG.java:1144)
- at org.testng.TestNG.run(TestNG.java:1115)
- at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:132)
- at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:230)
- at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:76)
- **My code for Login Page:**
- package com.gptoday.pages;
- import org.openqa.selenium.By;
- import org.openqa.selenium.WebDriver;
- public class Login {
- public WebDriver driver;
- By join = By.xpath("//*[@id='members']/a[1]");
- By username = By.id("username");
- By password = By.id("password");
- By loginButton = By.name("Login");
- /*public Login(WebDriver driver){
- this.driver=driver;
- }*/
- public void ClickJoin(){
- driver.findElement(join).click();
- System.out.println("Clicked Join");
- }
- public void EnterUsername(){
- driver.findElement(username).clear();
- driver.findElement(username).click();
- System.out.println("Username Entered");
- }
- public void EnterPassword(){
- driver.findElement(password).clear();
- driver.findElement(password).click();
- System.out.println("Password Entered");
- }
- public void ClickButton(){
- driver.findElement(loginButton).click();
- System.out.println("Login Button Clicked");
- }
- }
- **My Code for "Verification Testcase":**
- package com.gptoday.com.gptoday.testcases;
- import org.testng.annotations.Test;
- import com.gptoday.pages.Login;
- import org.testng.annotations.BeforeTest;
- import org.testng.annotations.AfterTest;
- import org.junit.AfterClass;
- import org.junit.BeforeClass;
- import org.openqa.selenium.By;
- import org.openqa.selenium.WebDriver;
- import org.openqa.selenium.firefox.FirefoxDriver;
- import org.openqa.selenium.firefox.FirefoxProfile;
- import org.openqa.selenium.firefox.internal.ProfilesIni;
- public class LoginVerification {
- public WebDriver driver;
- Login obj = new Login();
- /*LoginVerification(WebDriver driver){
- this.driver =driver;
- }*/
- @BeforeTest
- public void amg() {
- ProfilesIni prof = new ProfilesIni();
- FirefoxProfile ffProfile= prof.getProfile ("vishvesh");
- ffProfile.setAcceptUntrustedCertificates(true);
- ffProfile.setAssumeUntrustedCertificateIssuer(false);
- String base_url = "https://www.gptoday.com/";
- System.setProperty("webdriver.gecko.driver", "G:/Workplace/AutomationSetupFiles/Geckdriver1/geckodriver.exe");
- driver = new FirefoxDriver(ffProfile);
- driver.get(base_url);
- }
- @Test
- public void f() {
- driver.manage().window().maximize();
- obj.ClickJoin();
- //driver.findElement(By.xpath("//*[@id='members']/a[1]")).click();
- obj.EnterUsername();
- obj.EnterPassword();
- //obj.ClickButton();
- //driver.navigate().refresh();
- //WebDriverWait wait = new WebDriverWait(driver,10);
- //wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[@id='fpBox1']/a/div")));
- }
- @AfterTest
- public void just() {
- System.out.println("Success");
- }
- }
- enter code here
- @AfterTest
- public void just() {
- System.out.println("Success");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement