title: why chrome driver is not working in @Before?
body: <p>I have a simple code</p>
  
  <pre><code>  public class PageAvailable {
              @Test
              public void test() {
                  System.setProperty("webdriver.chrome.driver", "C:/Users/JARs/chromedriver_win32/chromedriver.exe");
                  WebDriver driver = new ChromeDriver();
                  driver.get("https://....net");
                  System.out.println(driver.getTitle());
                  driver.close();
              }}
  </code></pre>
  
  <p>above code is working fine<br>
  Now i want this code in more structure way</p>
  
  <pre><code>public class PageAvailable {
  WebDriver driver = new ChromeDriver();
  @Before
  public void be(){
      System.setProperty("webdriver.chrome.driver", "C:/Users/JARs/chromedriver_win32/chromedriver.exe");
      driver.get("....net");
  
  }
  @Test
  public void test() {
      driver.get("https://...net");
      System.out.println(driver.getTitle());
  }
  @After
  public void af(){
  driver.close();
  }}  
  </code></pre>
  
  <p>I am getting following error after executing above code</p>
  
  <blockquote>
    <p>java.lang.IllegalStateException: The path to the driver executable
    must be set by the webdriver.chrome.driver system property; for more
    information, see
    <a href="https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver" rel="nofollow">https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver</a>. The latest
    version can be downloaded from
    <a href="http://chromedriver.storage.googleapis.com/index.html" rel="nofollow">http://chromedriver.storage.googleapis.com/index.html</a>     at
    com.google.common.base.Preconditions.checkState(Preconditions.java:199)
      at
    org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:109)
      at
    org.openqa.selenium.chrome.ChromeDriverService.access$000(ChromeDriverService.java:32)
      at
    org.openqa.selenium.chrome.ChromeDriverService$Builder.findDefaultExecutable(ChromeDriverService.java:137)
      at
    org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:296)
      at
    org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:88)
      at
    org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:116)
      at sample.PageAvailable.(PageAvailable.java:12)   at
    sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown
    Source)   at
    sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown
    Source)   at java.lang.reflect.Constructor.newInstance(Unknown Source)
      at
    org.junit.runners.BlockJUnit4ClassRunner.createTest(BlockJUnit4ClassRunner.java:217)
      at
    org.junit.runners.BlockJUnit4ClassRunner$1.runReflectiveCall(BlockJUnit4ClassRunner.java:266)
      at
    org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
      at
    org.junit.runners.BlockJUnit4ClassRunner.methodBlock(BlockJUnit4ClassRunner.java:263)
      at
    org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
      at
    org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
      at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)  at
    org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)   at
    org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)     at
    org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)   at
    org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)  at
    org.junit.runners.ParentRunner.run(ParentRunner.java:363)     at
    org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
      at
    org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
      at
    org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
      at
    org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
      at
    org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
      at
    org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)</p>
  </blockquote>
  
  <p>I think something is missing from my side.<br>
  Thanks in advance for the help.</p>