从另一个类android调用方法时出现空指针异常

时间:2019-02-14 18:31:32

标签: java android selenium

从另一个类android调用方法时,

Null Pointer异常

  

我有1个类,有2个方法,我想在另一个类上调用这两个方法,但是1个方法可以正常工作,但另一个方法却得到了NULL POINTER EXECPTION

package Testing;

import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;


public class Dashboard
{

	public static WebDriver driver;
		static String  baseURL = "https://storedemo.unipagos.com/";
		
		@BeforeClass
		public static void OpenBrowsers()
		{
			System.setProperty("webdriver.gecko.driver", "E:\\Automation\\BrowserDriver\\geckodriver.exe");
			driver = new FirefoxDriver();
			driver.manage().window().maximize();
			driver.get(baseURL);
			driver.findElement(By.id("password_protected_pass")).sendKeys("admin");
			driver.findElement(By.id("wp-submit")).click();
						
		}
		
		@Test
		public static void Checkout() throws InterruptedException
		{
			
			driver.findElement(By.id("billing_first_name")).sendKeys("Sourabh");
			driver.findElement(By.id("billing_last_name")).sendKeys("Nigam");
			
		
		}	
		
}

  

上述类的OpenBrowsers方法可以工作,但Checkout方法上却出现NUll指针异常

package Testing;

import org.testng.annotations.Test;

public class Login2 {
	
@Test

	public static void log2() 
	{
		Dashboard.OpenBrowsers();
	}

@Test
	public static void Login1() throws InterruptedException
	{
	
	Dashboard.Checkout();
	
	}

}

0 个答案:

没有答案