Привет, люди: я сталкиваюсь со следующей проблемой в Cucumber с Maven / Selenium / Java
Given I go to Google # Step_First.I_go_to_Google()
java.lang.NullPointerException
at java.io.FileInputStream.<init>(FileInputStream.java:130)
at java.io.FileInputStream.<init>(FileInputStream.java:93)
at pages.Page_First.getURL(Page_First.java:38)
at stepdefs.Step_First.I_go_to_Google(Step_First.java:22)
at ✽.I go to Google (src/test/java/features/first.feature:8)
When I query for "<search>" cucumber spring selenium # Step_First.I_query_for_cucumber_spring_selenium(String)
And click search # Step_First.click_search()
Then google page title should become the first page # Step_First.google_page_title_should_become_the_first_page()
java.lang.NullPointerException
at java.io.FileInputStream.<init>(FileInputStream.java:130)
at java.io.FileInputStream.<init>(FileInputStream.java:93)
at pages.Page_First.getURL(Page_First.java:38)
at stepdefs.Step_First.I_go_to_Google(Step_First.java:22)
at ✽.I go to Google (src/test/java/features/first.feature:8)
Это моя функция file:
Feature: Navigation Test
Scenario: Search google.com to verify google search is working
Given I go to Google
When I query for "<search>" cucumber spring selenium
And click search
Then google page title should become the first page
Это метод Page , который я использую:
public void getURL() throws IOException {
Properties Config = new Properties();
//Declares a variable for reading properties from a resource bundle file (*.properties)
Properties p = new Properties();
//Always the Absolute path here.
FileInputStream file = new FileInputStream(System.getProperty("/Users/xxxxxx/Documents/automation_projects/" +
"zero/src/main/resources/data/config.properties"));
Config.load(file);
driver.get(Config.getProperty("url"));
//The String inside the config.properties
String url = p.getProperty("url");
}
В моем файле определения шага у меня есть файл:
@Given("I go to Google")
public void I_go_to_Google () throws IOException {
page_first.getURL();
}
При просмотре информации выше, проблема возникает в этой строке:
FileInputStream file = new FileInputStream(System.getProperty("/Users/xxxxxx/Documents/automation_projects/" +
"zero/src/main/resources/data/config.properties"));
Кстати, мой config.properties файл:
browser = firefox
url = https://www.google.com
Может кто-нибудь помочь мне с этим? Заранее спасибо.