RemoteWebDriver causing stackoverflow error when calling switchTo() method - selenium

Selenium Version: 3.7.1
I am automating a java swing application and making use of remote web driver as follows:
DesiredCapabilities dc = new DesiredCapabilities();
dc.setBrowserName("java");
dc.setVersion(" ");
dc.setJavascriptEnabled(true);
dc.setPlatform(Platform.ANY);
javaDriverTest = new RemoteWebDriver(new URL("docker container url"), dc);
Everything works fine apart from the following:
javaDriverTest.switchTo().window(windowName);
and I subsequently get this error:
java.lang.StackOverflowError
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.socketRead(SocketInputStream.java:116)
at java.net.SocketInputStream.read(SocketInputStream.java:171)
at java.net.SocketInputStream.read(SocketInputStream.java:141)
at org.apache.http.impl.io.SessionInputBufferImpl.streamRead(SessionInputBufferImpl.java:137)
at org.apache.http.impl.io.SessionInputBufferImpl.fillBuffer(SessionInputBufferImpl.java:153)
at org.apache.http.impl.BHttpConnectionBase.fillInputBuffer(BHttpConnectionBase.java:344)
at org.apache.http.impl.BHttpConnectionBase.isStale(BHttpConnectionBase.java:364)
at org.apache.http.impl.conn.CPoolProxy.isStale(CPoolProxy.java:114)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:208)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184)
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:88)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:71)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:55)
at org.openqa.selenium.remote.internal.ApacheHttpClient.fallBackExecute(ApacheHttpClient.java:138)
at org.openqa.selenium.remote.internal.ApacheHttpClient.execute(ApacheHttpClient.java:86)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:161)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:600)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:657)
at org.openqa.selenium.remote.RemoteWebDriver.getWindowHandles(RemoteWebDriver.java:505)
at org.openqa.selenium.remote.RemoteWebDriver$RemoteTargetLocator.window(RemoteWebDriver.java:962)
at org.openqa.selenium.remote.RemoteWebDriver$RemoteTargetLocator.window(RemoteWebDriver.java:963)
at org.openqa.selenium.remote.RemoteWebDriver$RemoteTargetLocator.window(RemoteWebDriver.java:963)
at org.openqa.selenium.remote.RemoteWebDriver$RemoteTargetLocator.window(RemoteWebDriver.java:963)
at org.openqa.selenium.remote.RemoteWebDriver$RemoteTargetLocator.window(RemoteWebDriver.java:963)
at org.openqa.selenium.remote.RemoteWebDriver$RemoteTargetLocator.window(RemoteWebDriver.java:963)
at org.openqa.selenium.remote.RemoteWebDriver$RemoteTargetLocator.window(RemoteWebDriver.java:963)
at org.openqa.selenium.remote.RemoteWebDriver$RemoteTargetLocator.window(RemoteWebDriver.java:963)
at org.openqa.selenium.remote.RemoteWebDriver$RemoteTargetLocator.window(RemoteWebDriver.java:963)
at org.openqa.selenium.remote.RemoteWebDriver$RemoteTargetLocator.window(RemoteWebDriver.java:963)
at org.openqa.selenium.remote.RemoteWebDriver$RemoteTargetLocator.window(RemoteWebDriver.java:963)
This doesn't happen all the time. But is quite frequent. Any idea how it can potentially be fixed?

It seems the issue is related to the way I started up the application i.e. I initially used the following:
export DISPLAY=:1.0
javaws -J -Dmarathon.agent=file:/root/Downloads/marathon-java-agent-5.1.4.0.jar.........
but when I added Xvfb to the command i.e.
Xvfb :1.0
export DISPLAY=:1.0
javaws -J -Dmarathon.agent=file:/root/Downloads/marathon-java-agent-5.1.4.0.jar.........
it fixed the issue. Therefore, I believe this issue is indeed not related to RemoteWebDriver, but actually to way the application under test is started.

Related

InvalidArgumentException: invalid argument: Unsupported locator strategy: -custom error with Appium using Selenium ChromeDriver and Chrome

I'm trying to run the test.ai plugin for appium (https://github.com/testdotai/appium-classifier-plugin). It has a custom locator strategy. I set up appium (version 1.13.0, also tried downgrading to 1.9.2-beta.2) and did:
'npm install -g test-ai-classifier'
it was installed, as shown:
https://i.stack.imgur.com/fwtkt.png
I then wrote a simple test to check if everything is set up correctly:
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.remote.MobileCapabilityType;
import io.appium.java_client.MobileBy;
import io.appium.java_client.MobileElement;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
import org.junit.Before;
import org.junit.After;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
public class TestClass {
private AppiumDriver driver;
private By cart = MobileBy.custom("cart");
#Before
public void setUp() throws MalformedURLException {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, "Android");
capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "9");
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "NB1GAD17B1504154");
capabilities.setCapability(MobileCapabilityType.BROWSER_NAME, "Chrome");
HashMap<String, String> customFindModules = new HashMap<>();
customFindModules.put("ai", "test-ai-classifier");
capabilities.setCapability("customFindModules", customFindModules);
capabilities.setCapability("shouldUseCompactResponses", false);
driver = new AndroidDriver(new URL("http://localhost:4723/wd/hub"), capabilities);
}
#After
public void tearDown(){
}
#Test
public void testMethod(){
goToWebsite(driver);
openCartUseAi(driver);
}
public void goToWebsite(AppiumDriver driver){
driver.get("https://www.ebay.com/");
}
public void openCartUseAi(AppiumDriver driver){
driver.findElement(cart).click();
}
}
This causes the following error when ran:
/usr/lib/jvm/java-1.11.0-openjdk-amd64/bin/java -ea -Didea.test.cyclic.buffer.size=1048576 -javaagent:/home/piotrek/intellij/ideaIC-2019.1.2/idea-IC-191.7141.44/lib/idea_rt.jar=46303:/home/piotrek/intellij/ideaIC-2019.1.2/idea-IC-191.7141.44/bin -Dfile.encoding=UTF-8 -classpath /home/piotrek/intellij/ideaIC-2019.1.2/idea-IC-191.7141.44/lib/idea_rt.jar:/home/piotrek/intellij/ideaIC-2019.1.2/idea-IC-191.7141.44/plugins/junit/lib/junit-rt.jar:/home/piotrek/intellij/ideaIC-2019.1.2/idea-IC-191.7141.44/plugins/junit/lib/junit5-rt.jar:/home/piotrek/IdeaProjects/appiumTestMVN/target/test-classes:/home/piotrek/Downloads/selenium-server-standalone-3.141.59.jar:/home/piotrek/.m2/repository/io/appium/java-client/7.0.0/java-client-7.0.0.jar:/home/piotrek/.m2/repository/org/seleniumhq/selenium/selenium-java/3.141.59/selenium-java-3.141.59.jar:/home/piotrek/.m2/repository/org/seleniumhq/selenium/selenium-chrome-driver/3.141.59/selenium-chrome-driver-3.141.59.jar:/home/piotrek/.m2/repository/org/seleniumhq/selenium/selenium-edge-driver/3.141.59/selenium-edge-driver-3.141.59.jar:/home/piotrek/.m2/repository/org/seleniumhq/selenium/selenium-firefox-driver/3.141.59/selenium-firefox-driver-3.141.59.jar:/home/piotrek/.m2/repository/org/seleniumhq/selenium/selenium-ie-driver/3.141.59/selenium-ie-driver-3.141.59.jar:/home/piotrek/.m2/repository/org/seleniumhq/selenium/selenium-opera-driver/3.141.59/selenium-opera-driver-3.141.59.jar:/home/piotrek/.m2/repository/org/seleniumhq/selenium/selenium-remote-driver/3.141.59/selenium-remote-driver-3.141.59.jar:/home/piotrek/.m2/repository/org/seleniumhq/selenium/selenium-safari-driver/3.141.59/selenium-safari-driver-3.141.59.jar:/home/piotrek/.m2/repository/net/bytebuddy/byte-buddy/1.8.15/byte-buddy-1.8.15.jar:/home/piotrek/.m2/repository/org/apache/commons/commons-exec/1.3/commons-exec-1.3.jar:/home/piotrek/.m2/repository/com/google/guava/guava/25.0-jre/guava-25.0-jre.jar:/home/piotrek/.m2/repository/com/google/code/findbugs/jsr305/1.3.9/jsr305-1.3.9.jar:/home/piotrek/.m2/repository/org/checkerframework/checker-compat-qual/2.0.0/checker-compat-qual-2.0.0.jar:/home/piotrek/.m2/repository/com/google/errorprone/error_prone_annotations/2.1.3/error_prone_annotations-2.1.3.jar:/home/piotrek/.m2/repository/com/google/j2objc/j2objc-annotations/1.1/j2objc-annotations-1.1.jar:/home/piotrek/.m2/repository/org/codehaus/mojo/animal-sniffer-annotations/1.14/animal-sniffer-annotations-1.14.jar:/home/piotrek/.m2/repository/com/squareup/okhttp3/okhttp/3.11.0/okhttp-3.11.0.jar:/home/piotrek/.m2/repository/com/squareup/okio/okio/1.14.0/okio-1.14.0.jar:/home/piotrek/.m2/repository/org/seleniumhq/selenium/selenium-support/3.141.59/selenium-support-3.141.59.jar:/home/piotrek/.m2/repository/org/seleniumhq/selenium/selenium-api/3.141.59/selenium-api-3.141.59.jar:/home/piotrek/.m2/repository/com/google/code/gson/gson/2.8.5/gson-2.8.5.jar:/home/piotrek/.m2/repository/org/apache/httpcomponents/httpclient/4.5.6/httpclient-4.5.6.jar:/home/piotrek/.m2/repository/org/apache/httpcomponents/httpcore/4.4.10/httpcore-4.4.10.jar:/home/piotrek/.m2/repository/commons-logging/commons-logging/1.2/commons-logging-1.2.jar:/home/piotrek/.m2/repository/commons-codec/commons-codec/1.10/commons-codec-1.10.jar:/home/piotrek/.m2/repository/cglib/cglib/3.2.8/cglib-3.2.8.jar:/home/piotrek/.m2/repository/org/ow2/asm/asm/6.2.1/asm-6.2.1.jar:/home/piotrek/.m2/repository/org/apache/ant/ant/1.10.3/ant-1.10.3.jar:/home/piotrek/.m2/repository/org/apache/ant/ant-launcher/1.10.3/ant-launcher-1.10.3.jar:/home/piotrek/.m2/repository/commons-validator/commons-validator/1.6/commons-validator-1.6.jar:/home/piotrek/.m2/repository/commons-beanutils/commons-beanutils/1.9.2/commons-beanutils-1.9.2.jar:/home/piotrek/.m2/repository/commons-digester/commons-digester/1.8.1/commons-digester-1.8.1.jar:/home/piotrek/.m2/repository/commons-collections/commons-collections/3.2.2/commons-collections-3.2.2.jar:/home/piotrek/.m2/repository/org/apache/commons/commons-lang3/3.8/commons-lang3-3.8.jar:/home/piotrek/.m2/repository/commons-io/commons-io/2.6/commons-io-2.6.jar:/home/piotrek/.m2/repository/org/springframework/spring-context/5.1.0.RELEASE/spring-context-5.1.0.RELEASE.jar:/home/piotrek/.m2/repository/org/springframework/spring-aop/5.1.0.RELEASE/spring-aop-5.1.0.RELEASE.jar:/home/piotrek/.m2/repository/org/springframework/spring-beans/5.1.0.RELEASE/spring-beans-5.1.0.RELEASE.jar:/home/piotrek/.m2/repository/org/springframework/spring-core/5.1.0.RELEASE/spring-core-5.1.0.RELEASE.jar:/home/piotrek/.m2/repository/org/springframework/spring-jcl/5.1.0.RELEASE/spring-jcl-5.1.0.RELEASE.jar:/home/piotrek/.m2/repository/org/springframework/spring-expression/5.1.0.RELEASE/spring-expression-5.1.0.RELEASE.jar:/home/piotrek/.m2/repository/org/aspectj/aspectjweaver/1.9.1/aspectjweaver-1.9.1.jar:/home/piotrek/.m2/repository/org/slf4j/slf4j-api/1.7.25/slf4j-api-1.7.25.jar:/home/piotrek/.m2/repository/junit/junit/4.12/junit-4.12.jar:/home/piotrek/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar com.intellij.rt.execution.junit.JUnitStarter -ideVersion5 -junit4 TestClass,testMethod
Jun 07, 2019 1:43:44 PM io.appium.java_client.remote.AppiumCommandExecutor$1 lambda$0
INFO: Detected dialect: W3C
org.openqa.selenium.InvalidArgumentException: invalid argument: Unsupported locator strategy: -custom
(Session info: chrome=74.0.3729.157)
(Driver info: chromedriver=74.0.3729.6 (255758eccf3d244491b8a1317aa76e1ce10d57e9-refs/branch-heads/3729#{#29}),platform=Linux 5.0.0-15-generic x86_64)
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: 'piotrek-VirtualBox', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '5.0.0-15-generic', java.version: '11.0.3'
Driver info: io.appium.java_client.android.AndroidDriver
Capabilities {browserName: Chrome, customFindModules: {ai: test-ai-classifier}, databaseEnabled: false, desired: {browserName: Chrome, customFindModules: {ai: test-ai-classifier}, deviceName: NB1GAD17B1504154, platformName: android, platformVersion: 9, shouldUseCompactResponses: false}, deviceManufacturer: HMD Global, deviceModel: TA-1004, deviceName: NB1GAD17B1504154, deviceScreenSize: 1440x2560, deviceUDID: NB1GAD17B1504154, javascriptEnabled: true, locationContextEnabled: false, networkConnectionEnabled: true, platform: LINUX, platformName: Android, platformVersion: 9, shouldUseCompactResponses: false, takesScreenshot: true, warnings: {}, webStorageEnabled: false}
Session ID: 6cb83c3b-3405-483a-8dc3-21eec62b4676
*** Element info: {Using=-custom, value=ai:cart}
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:187)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:122)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:239)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:42)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
at io.appium.java_client.android.AndroidDriver.execute(AndroidDriver.java:1)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:323)
at io.appium.java_client.DefaultGenericMobileDriver.findElement(DefaultGenericMobileDriver.java:62)
at io.appium.java_client.AppiumDriver.findElement(AppiumDriver.java:1)
at io.appium.java_client.android.AndroidDriver.findElement(AndroidDriver.java:1)
at io.appium.java_client.FindsByCustom.findElementByCustom(FindsByCustom.java:38)
at TestClass.openCartUseAi(TestClass.java:64)
at TestClass.testMethod(TestClass.java:49)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
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.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Process finished with exit code 255
Can anyone tell me what I'm doing wrong? When rewriting this test to not use the plugin, everything works fine, so Appium is set up correctly.
I had a look at this doc, but still can't see what I'm missing: http://appium.io/docs/en/advanced-concepts/element-finding-plugins/
Thank You in advance for your help!
PS not sure if this is relevant, but I'm using an Ubuntu virtual machine for this
This error message...
org.openqa.selenium.InvalidArgumentException: invalid argument: Unsupported locator strategy: -custom
...implies that the ChromeDriver was unable to initiate/spawn a new WebBrowser i.e. Chrome Browser session due to an invalid argument within an Unsupported locator strategy.
Your main issue is the incompatibility between the version of the binaries you are using as follows:
You are using chromedriver=2.46
Release Notes of chromedriver=2.46 clearly mentions the following :
Supports Chrome v71-73
You are using chrome=74.0
Release Notes of ChromeDriver v74.0 clearly mentions the following :
Supports Chrome v74
So there is a clear mismatch between ChromeDriver v2.46 and the Chrome Browser v74.0
Solution
Upgrade ChromeDriver to ChromeDriver v75.0 level.
Upgrade Chrome to Chrome v75 level. (as per ChromeDriver v75.0 release notes)
Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
Okay, got this figured out myself. Apparently Appium and Test.Ai don't yet support a custom locator strategy on web apps. This only works on native apps for now. Shame they didn't put this info in their documentation :P
Set this capability,
setCapability("chromeOptions", ImmutableMap.of("w3c", false));
On my side got the same issue, I was try out this code it worked smoothly.

Getting org.openqa.selenium.UnsupportedCommandException: mouseMoveTo

I am using selenium 3.5.3 and standalone selenium box.
I am trying to hover an element with following code:
RemoteWebDriver driver = null;
DesiredCapabilities dc = new DesiredCapabilities();
dc.setCapability("browserName", "firefox");
dc.setCapability("version", "55");
dc.setCapability("auth",GlobalProperties.seleniumboxAuthKey());
try {
driver = new RemoteWebDriver(new
URL("http://myseleniumboxurl.com/wd/hub"), dc);
}
catch (MalformedURLException e) {
System.out.println(e);
}
driver.get("https://github.com/SeleniumHQ");
Actions action = new Actions(driver);
WebElement elem = driver.findElement(By.xpath("//a[contains(#href, '/pricing')]"));
action.moveToElement(elem).perform();
I am getting following exception:
Caused by: org.openqa.selenium.UnsupportedCommandException: mouseMoveTo
at org.openqa.selenium.remote.http.AbstractHttpCommandCodec.encode(AbstractHttpCommandCodec.java:220)
at org.openqa.selenium.remote.http.AbstractHttpCommandCodec.encode(AbstractHttpCommandCodec.java:118)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:637)
at org.openqa.selenium.remote.RemoteExecuteMethod.execute(RemoteExecuteMethod.java:35)
at org.openqa.selenium.remote.RemoteMouse.mouseMove(RemoteMouse.java:89)
at org.openqa.selenium.support.events.internal.EventFiringMouse.mouseMove(EventFiringMouse.java:58)
at org.openqa.selenium.remote.server.handler.interactions.MouseMoveToLocation.call(MouseMoveToLocation.java:59)
at org.openqa.selenium.remote.server.handler.interactions.MouseMoveToLocation.call(MouseMoveToLocation.java:32)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at org.openqa.selenium.remote.server.DefaultSession$1.run(DefaultSession.java:176)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Any possible workaround or solution please?
In Selenium 3.5.0 mouse move not working properly. So you can use java script libraries and use a java script command to mouse move on element

Getting the error java.lang.NoSuchMethodError error while launching the headless browser

While launching the headless browser using Phantomjs, getting the below exception
java.lang.NoSuchMethodError: org.openqa.selenium.os.CommandLine.find(Ljava/lang/String;)Ljava/lang/String;
at org.openqa.selenium.phantomjs.PhantomJSDriverService.findPhantomJS(PhantomJSDriverService.java:232)
at org.openqa.selenium.phantomjs.PhantomJSDriverService.createDefaultService(PhantomJSDriverService.java:181)
at org.openqa.selenium.phantomjs.PhantomJSDriver.<init>(PhantomJSDriver.java:104)
at org.openqa.selenium.phantomjs.PhantomJSDriver.<init>(PhantomJSDriver.java:94)
OS is Mac
Config for launching headless browser is
File src = new File("src/test/resources/phantomjs_mac");
System.setProperty("phantomjs.binary.path", src.getAbsolutePath());
driver = new PhantomJSDriver();
Updated the complete trace
FAILED CONFIGURATION: #BeforeMethod LaunchBrowser
java.lang.NoSuchMethodError: org.openqa.selenium.os.CommandLine.find(Ljava/lang/String;)Ljava/lang/String;
at org.openqa.selenium.phantomjs.PhantomJSDriverService.findPhantomJS(PhantomJSDriverService.java:232)
at org.openqa.selenium.phantomjs.PhantomJSDriverService.createDefaultService(PhantomJSDriverService.java:181)
at org.openqa.selenium.phantomjs.PhantomJSDriver.<init>(PhantomJSDriver.java:104)
at org.openqa.selenium.phantomjs.PhantomJSDriver.<init>(PhantomJSDriver.java:94)
at baseHelper.BrowserLauncher.LaunchBrowser(BrowserLauncher.java:108)
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:497)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:86)
at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:514)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:215)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:589)
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.TestRunner.privateRun(TestRunner.java:782)
at org.testng.TestRunner.run(TestRunner.java:632)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:366)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:361)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:319)
at org.testng.SuiteRunner.run(SuiteRunner.java:268)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1244)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1169)
at org.testng.TestNG.run(TestNG.java:1064)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:113)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:206)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:177)
Here is the Answer to your Question:
When we use Phantomjs we have to provide the absolute path of the Phantomjs executable. Remember to specify the WebDriver Class before specifying the Implementation new PhantomJSDriver();
Here is the example in Windows:
File path=new File("C:\\Utility\\phantomjs-2.1.1-windows\\bin\\phantomjs.exe");
System.setProperty("phantomjs.binary.path",path.getAbsolutePath());
WebDriver driver= new PhantomJSDriver();
driver.manage().window().maximize();
driver.navigate().to("https://www.google.co.in/");
PS: Kindly convert it into Mac recognizable format.
Let me know if this Answers your Question.
System.setProperty("phantomjs.binary.path", src.getAbsolutePath()) does not work in case of PhanotmJS
However, you can setup the DesiredCapabilities and pass it to the PhantomJSDriver.
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY, System.getProperty("user.dir") + /drivers/phantomjs.exe");
WebDriver driver = new PhantomJSDriver(capabilities);
driver.navigate().to("https://www.google.co.in/");
driver.get("http://google.com");
Make sure your pom file does not use selenium version 3.6.0. Instead, use below dependency.
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.5.3</version>
</dependency>
Also, WebDriver driver = new PhantomJSDriver(); will always result in an error so you cannot use an empty constructor.
I hope that helps.

Apache Ignite Cache put fails with in the IgniteRunnable run method

I am getting the below error during the igniteCache.put() in the IgniteRunnable run()
I have only 2 nodes (client and server) .
1) Client creates the cache
CacheConfiguration<Integer, LAttribute> cfg = new CacheConfiguration<Integer, LAttribute>();
cfg.setIndexedTypes(Integer.class, LoanAttribute.class);
cfg.setCacheMode(CacheMode.PARTITIONED);
cfg.setName("inv_result");
cfg.setCopyOnRead(false);
cfg.setAtomicityMode(CacheAtomicityMode.ATOMIC);
2) Client Submit the IgniteRunnable task to Server
3) Client exit the cluster
On the Server (with in run() method)
1) Get the cache and put a value
IgniteCache<Integer, LAttribute> iCache = Ignition.localIgnite().cache("inv_result");
System.out.println("Begin .. "+iCache.size(CachePeekMode.ALL));
iCache.put(la.getId(), la);
Error :
[21:41:14,859][SEVERE][pub-#67%null%][GridJobWorker] Failed to execute job due to unexpected runtime exception [jobId=f4606f39b51-21c994a7-6b35-49fa-b696-582fa7825c31, ses=GridJobSessionImpl [ses=GridTaskSessionImpl [taskName=com.test.ignite.compute.AssetRestrictionComputeJob, dep=GridDeployment [ts=1492836063447, depMode=SHARED, clsLdr=sun.misc.Launcher$AppClassLoader#73d16e93, clsLdrId=438a5f39b51-76a937b0-7831-458b-aee4-cec662f02b0d, userVer=0, loc=true, sampleClsName=o.a.i.i.processors.cache.distributed.dht.preloader.GridDhtPartitionMap2, pendingUndeploy=false, undeployed=false, usage=1], taskClsName=com.bfm.seclending.ignite.compute.AssetRestrictionComputeJob, sesId=c4606f39b51-21c994a7-6b35-49fa-b696-582fa7825c31, startTime=1492836072790, endTime=9223372036854775807, taskNodeId=21c994a7-6b35-49fa-b696-582fa7825c31, clsLdr=sun.misc.Launcher$AppClassLoader#73d16e93, closed=false, cpSpi=null, failSpi=null, loadSpi=null, usage=1, fullSup=false, internal=false, subjId=21c994a7-6b35-49fa-b696-582fa7825c31, mapFut=IgniteFuture [orig=GridFutureAdapter [resFlag=0, res=null, startTime=1492836072829, endTime=0, ignoreInterrupts=false, state=INIT]]], jobId=f4606f39b51-21c994a7-6b35-49fa-b696-582fa7825c31]]
javax.cache.CacheException: class org.apache.ignite.IgniteInterruptedException: Failed to wait for asynchronous operation permit (thread got interrupted).
at org.apache.ignite.internal.processors.cache.GridCacheUtils.convertToCacheException(GridCacheUtils.java:1440)
at org.apache.ignite.internal.processors.cache.IgniteCacheProxy.cacheException(IgniteCacheProxy.java:2183)
at org.apache.ignite.internal.processors.cache.IgniteCacheProxy.put(IgniteCacheProxy.java:1383)
at co.test.ignite.compute.AssetRestrictionComputeJob.run(AssetRestrictionComputeJob.java:110)
at org.apache.ignite.internal.processors.closure.GridClosureProcessor$C4V2.execute(GridClosureProcessor.java:2215)
at org.apache.ignite.internal.processors.job.GridJobWorker$2.call(GridJobWorker.java:556)
at org.apache.ignite.internal.util.IgniteUtils.wrapThreadLoader(IgniteUtils.java:6564)
at org.apache.ignite.internal.processors.job.GridJobWorker.execute0(GridJobWorker.java:550)
at org.apache.ignite.internal.processors.job.GridJobWorker.body(GridJobWorker.java:479)
at org.apache.ignite.internal.util.worker.GridWorker.run(GridWorker.java:110)
at org.apache.ignite.internal.processors.job.GridJobProcessor.processJobExecuteRequest(GridJobProcessor.java:1180)
at org.apache.ignite.internal.processors.job.GridJobProcessor$JobExecutionListener.onMessage(GridJobProcessor.java:1894)
at org.apache.ignite.internal.managers.communication.GridIoManager.invokeListener(GridIoManager.java:1082)
at org.apache.ignite.internal.managers.communication.GridIoManager.processRegularMessage0(GridIoManager.java:710)
at org.apache.ignite.internal.managers.communication.GridIoManager.access$1700(GridIoManager.java:102)
at org.apache.ignite.internal.managers.communication.GridIoManager$5.run(GridIoManager.java:673)
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:745)
Caused by: class org.apache.ignite.IgniteInterruptedException: Failed to wait for asynchronous operation permit (thread got interrupted).
at org.apache.ignite.internal.util.IgniteUtils$3.apply(IgniteUtils.java:766)
at org.apache.ignite.internal.util.IgniteUtils$3.apply(IgniteUtils.java:764)
... 19 more
Caused by: java.lang.InterruptedException
at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1302)
at java.util.concurrent.Semaphore.acquire(Semaphore.java:312)
at org.apache.ignite.internal.processors.cache.GridCacheAdapter.asyncOpAcquire(GridCacheAdapter.java:4597)
at org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache.asyncOp(GridDhtAtomicCache.java:817)
at org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache.updateAsync0(GridDhtAtomicCache.java:1148)
at org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache.putAsync0(GridDhtAtomicCache.java:618)
at org.apache.ignite.internal.processors.cache.GridCacheAdapter.putAsync(GridCacheAdapter.java:2541)
at org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache.put(GridDhtAtomicCache.java:595)
at org.apache.ignite.internal.processors.cache.GridCacheAdapter.put(GridCacheAdapter.java:2215)
at org.apache.ignite.internal.processors.cache.IgniteCacheProxy.put(IgniteCacheProxy.java:1376)
... 16 more
Most likely server node was stopped in the middle of execution. That's the only case when internal Ignite threads are interrupted. When this happens, job can be automatically failed over to another node: https://apacheignite.readme.io/docs/fault-tolerance
I found the reason for the InterruptedException , executionService that i am using on the client side to submit the jobs is not waiting for the job completion .
when i call future.get() .. all good now. Thanks

JCR Re-opening Connections

I am using JCR 1.0 and I am having problems re-opening JCR connections after I close them.
Here are my two helper methods:
private void openConnection() throws Exception {
loadDbProperties();
repository = new TransientRepository(repositoryConfig,repositoryHome);
session = repository.login(new SimpleCredentials("testUserName","testPassword".toCharArray()));
ws = session.getWorkspace();
rootNode = session.getRootNode();
}
private void closeConnection() throws Exception {
session.save();
session.logout();
session = null;
repository = null;
}
I have two methods called, addProperty() and getProperty(), both need a connection to the JCR repository. I placed the openConnection() and closeConnection() methods at the beginning of both add and get methods but it seems that whichever method runs second is not able to re-open an already closed connection.
This is the exception I get:
javax.faces.el.EvaluationException: javax.jcr.RepositoryException: this session has been closed
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:102)
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
at javax.faces.component.UICommand.broadcast(UICommand.java:315)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:775)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1267)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:82)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:312)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:306)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:550)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:380)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:243)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:288)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
Caused by: javax.jcr.RepositoryException: this session has been closed
at org.apache.jackrabbit.core.SessionImpl.sanityCheck(SessionImpl.java:340)
at org.apache.jackrabbit.core.ItemImpl.sanityCheck(ItemImpl.java:154)
at org.apache.jackrabbit.core.NodeImpl.addNode(NodeImpl.java:1751)
at pgts.trueMiner.core.dao.TenureDAOImpl.addTenure(TenureDAOImpl.java:63)
at pgts.trueMiner.core.biz.TenureServiceImpl.addTenure(TenureServiceImpl.java:63)
at pgts.trueMiner.core.ui.TenureForm.addTenure(TenureForm.java:50)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.sun.el.parser.AstValue.invoke(AstValue.java:234)
at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:297)
at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:98)
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
... 23 more
How do you re-open the same connection? I don't want to always keep the connection open because a lock will prevent other applications from using the repository.
It looks like you try to add a node after the session was closed. I can reproduce the exception using the following test case:
Repository repository = new TransientRepository();
Session session = repository.login(
new SimpleCredentials("admin", "admin".toCharArray()));
session.getWorkspace();
Node rootNode = session.getRootNode();
session.save();
session.logout();
rootNode.addNode("test");
With a recent version of Jackrabbit (I used Jackrabbit trunk) you will get the stack trace of where the session was closed:
Exception in thread "main" javax.jcr.RepositoryException: This session has been closed. See the chained exception for a trace of where the session was closed.
at org.apache.jackrabbit.core.session.SessionState.checkAlive(SessionState.java:121)
at org.apache.jackrabbit.core.session.SessionState.perform(SessionState.java:171)
at org.apache.jackrabbit.core.ItemImpl.perform(ItemImpl.java:91)
at org.apache.jackrabbit.core.NodeImpl.addNodeWithUuid(NodeImpl.java:1790)
at org.apache.jackrabbit.core.NodeImpl.addNode(NodeImpl.java:1742)
at org.apache.jackrabbit.api.Test.main(Test.java:21)
Caused by: java.lang.Exception: Stack trace of where session-admin-4 was originally closed
at org.apache.jackrabbit.core.session.SessionState.close(SessionState.java:246)
at org.apache.jackrabbit.core.SessionImpl.logout(SessionImpl.java:888)
at org.apache.jackrabbit.core.XASessionImpl.logout(XASessionImpl.java:389)
at org.apache.jackrabbit.api.Test.main(Test.java:20)