Reputation: 63
I am trying the following simple code, which works as per expectation on my localmachine
public class NewTest
{
@Test
public void f() throws IOException
{
Properties obj = new Properties();
FileInputStream fileobj = new FileInputStream("C:\\selenium_Automation\\data_links.properties");
obj.load(fileobj);
System.setProperty("webdriver.chrome.driver", "c:\\drivers\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get(obj.getProperty("crm_url"));
System.out.println("Complete");
}
}
but when i try the same code on a different machine i get the following
FAILED: f
java.lang.NullPointerException: null value in entry: url=null
at com.google.common.collect.CollectPreconditions.checkEntryNotNull(CollectPreconditions.java:33)
at com.google.common.collect.SingletonImmutableBiMap.<init>(SingletonImmutableBiMap.java:39)
at com.google.common.collect.ImmutableBiMap.of(ImmutableBiMap.java:57)
at com.google.common.collect.ImmutableMap.of(ImmutableMap.java:80)
at org.openqa.selenium.remote.RemoteWebDriver.get(RemoteWebDriver.java:306)
The code works fine if i replace (obj.getProperty("crm_url")) with the actual URL, but i have several different links stored in the properties file and i need them to be read from that place. What i am doing wrong can some please tell me the reason behind the NUll pointer expection for the URL
Upvotes: 3
Views: 15272
Reputation: 1
Make sure that the location of properties file is correct wherever you are utilizing it e.g. in case of FileInputStream
Upvotes: 0
Reputation: 91
Even I had faced this issue. I deleted the target folder before running the code and my issue was resolved.
Upvotes: -1
Reputation: 1
The issue here I can assume is that the url you are using in the properties file must be wrong or it might have the inverted commas. If it has the inverted commas i.e url="https://www.google.com" then remove it.
Upvotes: 0
Reputation: 7388
This is the error you get when you try to add a null
object to an immutable map in the google common library. My guess would be that the org.openqa.selenium.remote.RemoteWebDriver.get
is attempting to find do that and your file path is null or something similar. I would check the url but that is only a guess.
Upvotes: 4
Reputation: 2981
If I had to guess, I would say that the location of your properties file is different on the other machine.
Upvotes: 1