Hi JBrowserDriver - check the docs - I would guess this is what is spawning a process from https://github.com/MachinePublishers/jBrowserDriver/issues/94 Problem is, each JBrowserDriver, as I understand it, is a system *process*
On Fri, Jul 8, 2016 at 12:27 PM, Michael Logan <[email protected]> wrote: > I don't think I am. Here is my code for creating the JBrowserDriver, > logging into the website, and then finally storing into the JMeter context > variables. > > > package gov.state; > > import org.apache.jmeter.protocol.java.sampler.AbstractJavaSamplerClient; > import java.io.Serializable; > import java.util.concurrent.TimeUnit; > import com.machinepublishers.jbrowserdriver.JBrowserDriver; > import org.apache.commons.lang.BooleanUtils; > import org.apache.jmeter.config.Arguments; > import org.apache.jmeter.samplers.SampleResult; > import org.openqa.selenium.*; > import org.openqa.selenium.support.ui.ExpectedConditions; > import org.openqa.selenium.support.ui.WebDriverWait; > import org.apache.jmeter.protocol.java.sampler.JavaSamplerContext; > > public class InstantiateBrowser extends AbstractJavaSamplerClient > implements Serializable { > > private static final long serialVersionUID = 5710042664127564753L; > private JBrowserDriver driver; > private String lastStep; > public static String Username = ""; > public static String Password = ""; > public static boolean ErrorCapture = false; > public static String ErrorDetailPath = ""; > public static String Host = ""; > public static String Directory = ""; > String executionTag; > > @Override > public Arguments getDefaultParameters() { > //add arguments to the JMeter Java Sample page. > Arguments defaultParameters = new Arguments(); > defaultParameters.addArgument("Username", "<<Username to use>>"); > defaultParameters.addArgument("Password", "<<Password to use>>"); > defaultParameters.addArgument("ErrorCapture","false"); > defaultParameters.addArgument("ErrorDetailPath", "The path to save > source and screenshots with a trailing slash."); > defaultParameters.addArgument("TEBSHost","http://thissite.com"); > defaultParameters.addArgument("TEBSDirectory", "appdirectory"); > return defaultParameters; > } > > public void setUp(JavaSamplerContext context) throws Exception { > //set the execution tag for log statements > executionTag = "ExecutionTimestamp::" + Common.GetTimeStamp(); > > //try to get the parameters that were passed in. > try { > Username = context.getParameter("Username"); > Password = context.getParameter("Password"); > ErrorCapture = > BooleanUtils.toBoolean(context.getParameter("ErrorCapture")); > ErrorDetailPath = context.getParameter("ErrorDetailPath"); > Host = context.getParameter("TEBSHost"); > Directory = context.getParameter("TEBSDirectory"); > } > catch (Exception ex) { > Common.ExceptionToSysOut(executionTag, ex); > Common.wl(executionTag, "Exception with parameters"); > } > > //instantiate the browser > try { > driver = new JBrowserDriver(); > } catch (Exception ex) { > Common.ExceptionToSysOut(executionTag, ex); > } > > driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); > } > > @Override > public SampleResult runTest(JavaSamplerContext context) { > > // Create the result > SampleResult result = new SampleResult(); > > // start the timer > result.sampleStart(); // start stopwatch > > try { > > //run setUp > setUp(context); > > //access the website > driver.get(Host + "/" + Directory + "/login.jsp"); > > lastStep = "Trying to log in..."; > > driver.findElement(By.id("loginText")).clear(); > driver.findElement(By.id("loginText")).sendKeys(Username); > driver.findElement(By.name("password")).clear(); > driver.findElement(By.name("password")).sendKeys(Password); > driver.findElement(By.xpath("//button[contains(.,'Sign > In')]")).click(); > > //Validate that we see the session as logged in. > WebElement elementLoggedIn = null; > try { > //Let's wait at most 20 seconds for the result to appear. > elementLoggedIn = (new WebDriverWait(driver, 20)) > > > .until(ExpectedConditions.presenceOfElementLocated(By.xpath("//td[contains(.,'Logged > In As')]"))); > //if we have gotten to this point we can assume that login > was successful. > //set the result to success > result.setSuccessful(true); > result.setResponseMessage("Verification Passed"); > > //grab the JMeter context and store the browser into memory > org.apache.jmeter.threads.JMeterContext jmetercontext = > org.apache.jmeter.threads.JMeterContextService.getContext(); > org.apache.jmeter.threads.JMeterVariables vars = > jmetercontext.getVariables(); > //we are storing the driver as a variable named "browser" > vars.putObject("browser", driver); > jmetercontext.setVariables(vars); > } > catch (NoSuchElementException ex) { > Common.wl(executionTag, "Element not found."); > Common.ExceptionToSysOut(executionTag, ex); > ErrorToDisk.WriteIt(driver, ErrorDetailPath, > "InstantiateBrowser", executionTag); > result.setSuccessful(false); > result.setResponseMessage(executionTag + "::Element Not > found 1." + Common.ExceptionToString(ex)); > > result.setDataType(org.apache.jmeter.samplers.SampleResult.TEXT); > } > catch (Exception ex) { > Common.wl(executionTag, "Unexpected exception"); > Common.ExceptionToSysOut(executionTag, ex); > ErrorToDisk.WriteIt(driver, ErrorDetailPath, > "InstantiateBrowser", executionTag); > result.setSuccessful(false); > result.setResponseMessage(executionTag + "::Element Not > found 2." + Common.ExceptionToString(ex)); > > result.setDataType(org.apache.jmeter.samplers.SampleResult.TEXT); > } > > //stop the clock > result.sampleEnd(); > > } catch (Exception e) { > \\remove for brevity > > } > > //return the result > return result; > } > > @Override > public void teardownTest(JavaSamplerContext context) { > //driver.quit(); > super.teardownTest(context); > } > > > > } > > On Fri, Jul 8, 2016 at 3:00 PM, Deepak Shetty <[email protected]> wrote: > > > The sampler itself should run as the same java process - are you sure you > > arent launching processes from within the sampler ? > > > > On Fri, Jul 8, 2016 at 11:56 AM, Michael Logan <[email protected]> > > wrote: > > > > > Hi, > > > > > > I am trying to use the Java Request Sampler to test my website. I am > > > noticing that my requests get started as another process, not as a > thread > > > under the JMeter process. Is this what is supposed to happen with a > > custom > > > Java Request Sampler? My custom Java Request Sampler extends the > > > AbstractJavaSamplerClient > > > > > > Behavior during test run. > > > JMeter version 2.13 - I see an external java process for each user. > > > JMeter version 3.0 - I see an many more java processes, I shut-down the > > > test when I saw about 15 of them. > > > > > > Here is the outline of my test: > > > Thread Group (5 users, 35 second ramp up, 1 loop) > > > - Java Request Sampler (create the browser, log into a website, store > the > > > browser in JMeter context) > > > - Runtime Controller (Runtime 480 seconds) > > > - - Java Request Sampler (do an action in the website) > > > - end Runtime Controller > > > - Java Request Sampler (log out of the application, close the driver) > > > > > > Is this normal behavior? If so, how can I control those spawn Java > > > processes? I do launch JMeter from the .bat file that specifies all > the > > > JVM parameters. > > > > > > Thanks in advance for any help. > > > > > >
