Am trying to automate button properties,but error is this java.lang.NullPointerException,please help me below is the code

package com.property;



import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;


public class Gbuttonproperty {
	
	
	private WebDriver driver;
	private String buttonText=null;
	private int buttonhight=0;
	
	
	public String buttontext(String locator,String Value) 
	{
	
		if(locator=="xpath")
		{
		 buttonText=driver.findElement(By.xpath(Value)).getText();
		 return buttonText;
		
		}
		else if(locator == "id")
		{
		     buttonText = this.driver.findElement(By.id(Value)).getText();
			return buttonText;
		}
		else if(locator=="name"){
			String buttonText = this.driver.findElement(By.name(Value)).getText();
			return buttonText;
		}
		else if(locator=="classname"){
			String buttonText = this.driver.findElement(By.className(Value)).getText();
			return buttonText;
		}
		else if(locator=="cssSelector"){
			String buttonText =this.driver.findElement(By.cssSelector(Value)).getText();
			return buttonText;
		}
		
		return null;
	}
	public int buttonhight(String locator,String Value){
	
		if(locator== "xpath")
		{
		System.out.println("hello");
		int buttonhight = driver.findElement(By.xpath(Value)).getSize().getHeight();
	    return buttonhight;
		}
		else if(locator == "id")
		{
			int buttonhight =this.driver.findElement(By.id(Value)).getSize().height;
			return buttonhight;
		}
		else if(locator=="name"){
			int buttonhight = this.driver.findElement(By.name(Value)).getSize().getHeight();
			return buttonhight;
		}
		else if(locator=="classname"){
			int buttonhight = this.driver.findElement(By.className(Value)).getSize().getHeight();
			return buttonhight;
		}
		else if(locator=="cssSelector"){
			int buttonhight = this.driver.findElement(By.cssSelector(Value)).getSize().getHeight();
			return buttonhight;
		}
		return 0;
	}

}
package com.properies;
import com.property.Gbuttonproperty;


import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;



public class Gbutton {
    private WebDriver driver;
	private String baseUrl;
	private Gbuttonproperty buttonproperty;
	//Gbuttonproperty b = new Gbuttonproperty();
	
	 @BeforeMethod
	  public void start() throws Exception {
		   baseUrl = "https://www.google.com/";
		   driver = new FirefoxDriver();
		   
	   }
	   @Test  
	   public void button(){
		   driver.get(baseUrl );
		   Gbuttonproperty b=new Gbuttonproperty();
		   
		   b.buttonhight("xpath", "//*[@id='gbqfba']");
		   b=null;
		   b.buttontext("xpath","id('gbqfba')");
		   b=null;
		   
		  
		   }
	   @AfterMethod
		  public void tearDown() throws Exception {
		    driver.quit();
		   
		  }
	   
}

1 answer

plz provide answer to this question

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Friday in Off-topic

Friday Fun: Riddle me this

Happy Friday, Funmakers! We had a Community Team offsite in Austin this week, and my mind feels primed for thinkin' from all the brainstorming we did!  So, this week's Friday Fun thread w...

110 views 12 3
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you