In Baseurl.java, driver is not declared as a global variable. It is declared under basic(). This means driver is accessible only under basic().closeBrowser() cannot have access to driver, hence you are getting the error.
I have a few suggestions to your code.
I believe Baseurl.java is not the class under test. It is provided merely to start and close the browser. So remove the annotation @Test from it.
Countrychoser.java is your test class. So add @Test to it before the method Choser(). I also suggest you make the Choser() method non static.
I see that you have used finally block to close the browser. Since you are using the TestNG framework, you can explore the possibilities of @AfterTest annotation instead.
Similarly @BeforeTest annotation is also useful.
To sum it up, please have at a look at your code with the modifications :-
Baseurl.java
public class Baseurl {
private WebDriver driver; //global variable
public static WebDriver basic() {
driver = new FirefoxDriver();
driver.manage().deleteAllCookies();
driver.get("http://www.sears.com/shc/s/CountryChooserView?storeId=10153&catalogId=12605");
return driver;
}
public static void Closebrowser(){
driver.quit(); // You wont get an error now :)
}
}
Countrychoser.java
public class Countrychoser {
WebDriver driver;
@BeforeTest
public void startTest(){
driver = Baseurl.basic();
}
@Test
public void Choser() {
try {
//driver.findElement(By.className("box_countryChooser")).click();
driver.findElement(By.id("intselect")).sendKeys("India");
driver.findElement(By.xpath(".//*[@id='countryChooser']/a/img")).click();
//window.onbeforeunload = null;
System.out.println("---------------------------------------");
System.out.println("Country choser layer test case-Success");
System.out.println("---------------------------------------");
} catch(Exception e) {
// Screenshot.pageScreenshot();
System.out.println(e);
System.out.println("---------------------------------------");
System.out.println("Country choser layer test case Failed");
System.out.println("---------------------------------------");
}
}
@AfterTest
public void endTest() {
// Screenshot.pageScreenshot();
// Baseurl.Closebrowser();
}
}
Let me know if this helps you.