package day4;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class sample_script_xpath {
public static void main(String[] args) {
String browser="Mozilla";
WebDriver driver = null ;
if(driver.equals("Mozilla"))
driver=new FirefoxDriver();
else if(driver.equals("Chrome"))
driver=new ChromeDriver();
driver.get("https://login.salesforce.com/?locale=in");
WebElement UserName=driver.findElement(By.id("username"));
UserName.sendKeys("SampleUser");
}
}
Error :
Exception in thread "main" java.lang.NullPointerException
at day4.sample_script_xpath.main(sample_script_xpath.java:14)
Instructor
Ashish Thakur Replied on 08/11/2019
if(driver.equals("Mozilla"))
should be
if(browser.equals("Mozilla"))