title: SampleResult is not working as Expected with JSR223 sampler in JMeter
body: <p>I have been working with JSR223 sampler with Java as chosen Language. My problem is that when I use SampleResult functions say <code>SampleResult.sampleStart/End()</code>, the error <code>SampleResult: sampleStart called twice</code> is displayed.   </p>
  
  <p>The script:   </p>
  
  <pre><code>/*All import statements*/
  setStrictJava(false);
  
  public static DesiredCapabilities desCapabilities;
  public static WebDriver driver = null;
  public static String IEDriver = "Chrome";
  
  if (IEDriver.equalsIgnoreCase("Chrome")) {
      desCapabilities = DesiredCapabilities.chrome();
      desCapabilities.setPlatform(Platform.ANY);
      desCapabilities.setBrowserName("Chrome");
      ChromeOptions options = new ChromeOptions();
      options.addArguments(new String[] {"--start-maximized"});
      System.setProperty("webdriver.chrome.driver","D:/Bala/Automation/Chrome/chromedriver.exe");
      desCapabilities.setCapability("chromeOptions", options);
      driver = new ChromeDriver(desCapabilities);
      Thread.sleep(20000);
      driver.get("http://google.com");
      SampleResult.setSampleLabel("Login Page Load Time");
      SampleResult.setSuccessful(true);
      SampleResult.sampleStart();
      JavascriptExecutor js = (JavascriptExecutor)driver;
      while(true){ 
         log.info("Started while loop...");
         Boolean isJSLoaded = js.executeScript("return document.readyState;", new Object[] {}).toString().equals("complete");
         Boolean isAjaxLoaded = js.executeScript("return window.jQuery != undefined &amp;&amp; jQuery.active == 0 &amp;&amp; window.$.active", new Object[] {}).equals("0");
         if(!(isJSLoaded) &amp;&amp; !(isAjaxLoaded)){ 
              break; 
         } 
      }
      log.info("Ended while loop...");
      (new WebDriverWait(driver, 60)).until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div[@id='googleHome']")));
      SampleResult.sampleEnd();
      return driver.getWindowHandle();
      } else if {
          /*code for IE browser*/
      }
  </code></pre>
  
  <p>It is working properly when it is given in outside of 'IF' condition.</p>
  
  <p>Below are the things I tried so far:</p>
  
  <p>Create a constructor for SampleResult and call its methods: This didn't give me the ERROR, instead, time is recorded from the beginning of the thread.</p>
  
  <pre><code>SampleResult result = new SampleResult();
  result.setSampleLabel("Login Page Load Time2");
  result.setSuccessful(true);
  result.sampleStart();
  Thread.sleep(3000);
  result.sampleEnd();
  </code></pre>
  
  <p>How to start recording the time immediately after 'driver.get()' is called?</p>
  
  <p>How to use SampleResult inside 'IF' condition?</p>