I have been trying for the longest time but I can't get this to work. What I am trying to do is do load testing with Fluentlenium as a base. When I tried to initiate my test, it only open one chrome browser and in my IDE, the same method is running 3x (for example) Sometimes the test passes and sometimes it fails. Its suppose to be launching 3 chrome browser under different port (generated by selenium) but it doesn't, it only launch 1 browser.
Here's my code that's failing:
public class Example extends FluentTestNg {
private final static String DEFAULT_URL = "http://google.com";
@Override
public WebDriver newWebDriver() {
DesiredCapabilities caps = new DesiredCapabilities();
WebDriver driver = new ChromeDriver(caps);
return driver;
}
@Test(invocationCount = 3, threadPoolSize = 3)
public void GoogleTest() throws Exception {
goTo(DEFAULT_URL);
await().until($(".gsfi")).present();
System.out.println(getCookies());
}
}
Heres the stacktrace that was provide that it failed
Starting ChromeDriver 2.30.477690 (c53f4ad87510ee97b5c3425a14c0e79780cdf262) on port 14851
Only local connections are allowed.
Jun 19, 2017 12:53:03 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
Jun 19, 2017 12:53:03 PM org.apache.http.impl.execchain.RetryExec execute
INFO: I/O exception (java.net.SocketException) caught when processing request to {}->http://localhost:14851: Broken pipe (Write failed)
Jun 19, 2017 12:53:03 PM org.apache.http.impl.execchain.RetryExec execute
INFO: Retrying request to {}->http://localhost:14851
org.openqa.selenium.NoSuchSessionException: no such session
(Driver info: chromedriver=2.30.477690 (c53f4ad87510ee97b5c3425a14c0e79780cdf262),platform=Mac OS X 10.12.5 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 59 milliseconds
Build info: version: '3.3.1', revision: '5234b325d5', time: '2017-03-10 09:10:29 +0000'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, networkConnectionEnabled=false, chrome={chromedriverVersion=2.30.477690 (c53f4ad87510ee97b5c3425a14c0e79780cdf262), userDataDir=/var/folders/1j/tdgn9dcn6d9g9dcd3fs8nj8c0000gn/T/.org.chromium.Chromium.yRHaZe}, takesHeapSnapshot=true, pageLoadStrategy=normal, databaseEnabled=false, handlesAlerts=true, hasTouchScreen=false, version=59.0.3071.86, platform=MAC, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true, unexpectedAlertBehaviour=}]
Session ID: 25c29b733c90f9dff2afb69dee6dc1d5
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:216)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:168)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:638)
at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:274)
at org.openqa.selenium.remote.RemoteWebElement.isEnabled(RemoteWebElement.java:148)
at org.fluentlenium.core.proxy.ComponentHandler.isStale(ComponentHandler.java:52)
at org.fluentlenium.core.proxy.AbstractLocatorHandler.present(AbstractLocatorHandler.java:225)
at org.fluentlenium.core.proxy.LocatorProxies.present(LocatorProxies.java:113)
at org.fluentlenium.core.domain.FluentWebElement.present(FluentWebElement.java:132)
at org.fluentlenium.core.conditions.AbstractObjectConditions.verify(AbstractObjectConditions.java:36)
at org.fluentlenium.core.conditions.WebElementConditions.present(WebElementConditions.java:43)
at org.fluentlenium.core.conditions.AbstractFluentListConditions.lambda$present$0(AbstractFluentListConditions.java:79)
at org.fluentlenium.core.conditions.AtLeastOneElementConditions.lambda$buildAtLeastOnePredicate$0(AtLeastOneElementConditions.java:49)
at org.fluentlenium.core.conditions.AtLeastOneElementConditions.verify(AtLeastOneElementConditions.java:35)
at org.fluentlenium.core.conditions.AbstractFluentListConditions.present(AbstractFluentListConditions.java:79)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.fluentlenium.core.conditions.wait.WaitConditionInvocationHandler$2.apply(WaitConditionInvocationHandler.java:216)
at org.fluentlenium.core.conditions.wait.WaitConditionInvocationHandler$2.apply(WaitConditionInvocationHandler.java:212)
at org.fluentlenium.core.conditions.wait.WaitConditionInvocationHandler.lambda$until$0(WaitConditionInvocationHandler.java:156)
at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:209)
at org.fluentlenium.core.wait.FluentWait.untilPredicate(FluentWait.java:131)
at org.fluentlenium.core.conditions.wait.WaitConditionInvocationHandler.until(WaitConditionInvocationHandler.java:144)
at org.fluentlenium.core.conditions.wait.WaitConditionInvocationHandler.until(WaitConditionInvocationHandler.java:175)
at org.fluentlenium.core.conditions.wait.WaitConditionInvocationHandler.waitForCondition(WaitConditionInvocationHandler.java:212)
at org.fluentlenium.core.conditions.wait.WaitConditionInvocationHandler.invoke(WaitConditionInvocationHandler.java:190)
at com.sun.proxy.$Proxy8.present(Unknown Source)
at Example.GoogleTest(Example.java:27)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:86)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:643)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:820)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1128)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:129)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:112)
at org.testng.internal.thread.ThreadUtil$2.call(ThreadUtil.java:64)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:748)
org.openqa.selenium.TimeoutException: Expected condition failed: Elements By.cssSelector: .gsfi (Lazy Element List) is not present (tried for 5 second(s) with 500 MILLISECONDS interval)
Build info: version: '3.3.1', revision: '5234b325d5', time: '2017-03-10 09:10:29 +0000'
Driver info: driver.version: unknown
at org.openqa.selenium.support.ui.FluentWait.timeoutException(FluentWait.java:264)
at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:232)
at org.fluentlenium.core.wait.FluentWait.untilPredicate(FluentWait.java:131)
at org.fluentlenium.core.conditions.wait.WaitConditionInvocationHandler.until(WaitConditionInvocationHandler.java:144)
at org.fluentlenium.core.conditions.wait.WaitConditionInvocationHandler.until(WaitConditionInvocationHandler.java:175)
at org.fluentlenium.core.conditions.wait.WaitConditionInvocationHandler.waitForCondition(WaitConditionInvocationHandler.java:212)
at org.fluentlenium.core.conditions.wait.WaitConditionInvocationHandler.invoke(WaitConditionInvocationHandler.java:190)
at com.sun.proxy.$Proxy8.present(Unknown Source)
at Example.GoogleTest(Example.java:27)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:86)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:643)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:820)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1128)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:129)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:112)
at org.testng.internal.thread.ThreadUtil$2.call(ThreadUtil.java:64)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:748)
I have another method that works fine but I have to pass newWebDriver method for it to work...
public class Example extends FluentTestNg {
private final static String DEFAULT_URL = "http://google.com";
private static ThreadLocal<WebDriver> drivers = new ThreadLocal<WebDriver>();
public void setWebdriver(WebDriver driver){
drivers.set(driver);
}
@Override
public WebDriver newWebDriver() {
return drivers.get ();
}
@BeforeMethod
public void launchbrowser(){
WebDriver drivers = new ChromeDriver();
setWebdriver(drivers);
}
@Test(invocationCount = 3, threadPoolSize = 3)
public void GoogleTest() throws Exception {
newWebDriver().get(DEFAULT_URL);
}
}
Heres the console log of it passing with 3 browsers opening but I can't use Fluentlenium syntax.
Starting ChromeDriver 2.30.477690 (c53f4ad87510ee97b5c3425a14c0e79780cdf262) on port 11700
Only local connections are allowed.
Starting ChromeDriver 2.30.477690 (c53f4ad87510ee97b5c3425a14c0e79780cdf262) on port 35621
Only local connections are allowed.
Starting ChromeDriver 2.30.477690 (c53f4ad87510ee97b5c3425a14c0e79780cdf262) on port 31113
Only local connections are allowed.
Jun 19, 2017 12:59:11 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
Jun 19, 2017 12:59:11 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
Jun 19, 2017 12:59:11 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
The only problem is, I can't use the built in Fluentlenium syntax to it (exp: GoTo,GetCookies, Await, ect.). I have to use Selenium syntax.
Is there any way to get this to work with just Fluentlenium?