Closed michael-logan closed 7 years ago
Sounds like JMeter runs multiple threads? JBrowserDriver is multi-process so you'd probably want the number of processes to match the number of JMeter threads. Settings.builder().processes(numThreads)
JBrowserDriver tracks the number of processes by incrementing a counter when the instance is created and decrementing it when the instance quits. If you create an instance that would exceed the max, the constructor blocks.
Also these separate processes are transparent to users. All the classes you can access such as JBrowserDriver reside in the parent process--then they in turn communicate over RMI to the child process.
One more thing, this should probably be documented better, but the max and counter of processes is per Settings object. So if you build new Settings in each thread, the max should be 1. If you share the same built Settings across threads then the max should be the number of threads.
Overall, I don't know that any of this fixes your problem. Just a guess.
Hi @hollingsworthd
You are correct, JMeter runs multiple Threads. With each Thread (User in JMeter terms), will run my Java Sampler class (the code above). So if I run 3 threads for my Test I have 3 seperate Java processes for the JBrowserDriver.
I think I have nailed down the issue. If the Ajax wait is higher than 999 it happens more often than not. Values around 4000 make it happen all the time.
driver = new JBrowserDriver(Settings.builder().ajaxWait(4000).build());
I tried assigning the ajaxWait with .ajaxWait(4000L) and it didn't help. This doesn't make sense but it is what I'm seeing.
Oh, forgot to mention:
I did add the processes(1) to the Settings and I tried the processes(numThreadsFromJMeter). In both instances the issue still occurred.
The ajax wait means that that much time must pass between any ajax requests before the page is considered loaded (essentially... it's a little more nuanced when considering iframes, redirects, failed requests, etc).
So if you had a client side script that pinged the server every 750ms, then an ajax wait of 1000 would mean the page would never be considered done loading by the driver and it would block forever. And if you had a wait of 30000 then that's high enough there might be unexpected issues with other timeouts at play.
The default I think is 150ms. That's sufficient for many use cases and environments. If a page has no ajax at all, a value of 0ms is fine. And I'm not that familiar with FluentWait but I think it tries to accomplish the same goal (in a very different way) so maybe 0ms makes sense if you're using FluentWait on an ajax page.
I think you want these non-static:
public static String sessionUsername = "";
public static String sessionPassword = "";
public static String Host = "";
public static String Directory = "";
public static boolean StackTraceInResult = false;
public static long MaxWaitTimeSeconds = 0;
public static String TestValue = "";
Hi,
I have a JMeter test, running a Java Sampler test, which in turn uses a JBrowserDriver. I'm noticing my results are not correct.
Here is the basic rundown of my JMeter test:
I am noticing that the result returned after using the JBrowserDriver is the last result. Trying to explain this issue is a little difficult since I haven't pinned down the issue. I notice the problem doesn't occur if I don't create the JBrowserDriver object. Removing the step of "Store the driver in memory" didn't fix the issue.
Assume my CSV contains these values: user1,password1 user2,password2 user3,password3
And my Java Sampler returns results with Log in success and username like this: Log in=Success,Username=user1
I am getting these kind of results: Log in=Success,Username=user2 Log in=Success,Username=user2
If I change the Thread Count to 3 I get these values: Log in=Success,Username=user3 Log in=Success,Username=user3 Log in=Success,Username=user3
Here is my "Java Sampler" code. Am I instantiating the driver incorrectly? Am I storing it into JMeter context incorrectly since it's a separate process? If I remove the JBrowserDriver instantiation the issue doesn't appear.
`package gov.mypkg;
import org.apache.jmeter.protocol.java.sampler.AbstractJavaSamplerClient; import java.io.Serializable; import java.util.concurrent.TimeUnit; import com.machinepublishers.jbrowserdriver.JBrowserDriver; import com.machinepublishers.jbrowserdriver.Settings;
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.htmlunit.HtmlUnitDriver; 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 {
} `