3

I am using the phantomjs webdriver using selenium protocol to render the webpage.When I try to render the webpage ,I am getting the following error in

RemoteWebDriver.get(url)

method eventhough my webdriver is running.

I have also tried restarting the phantomjs webdriver.

org.openqa.selenium.UnsupportedCommandException: Variable Resource Not Found - {"headers":{"Accept-Encoding":"gzip,deflate","Connection":"Keep-Alive","Content-Length":"39","Content-Type":"application/json; charset=utf-8","Host":"10.20.1.239:9517","User-Agent":"Apache-HttpClient/4.5.5 (Java/1.8.0_171)"},"httpVersion":"1.1","method":"POST","post":"{\"url\":\"http://example.com/\"}","url":"/session/07e53c90-6b45-11e9-892c-4faf7180871b/url","urlParsed":{"anchor":"","query":"","file":"url","directory":"/session/07e53c90-6b45-11e9-892c-4faf7180871b/","path":"/session/07e53c90-6b45-11e9-892c-4faf7180871b/url","relative":"/session/07e53c90-6b45-11e9-892c-4faf7180871b/url","port":"","host":"","password":"","user":"","userInfo":"","authority":"","protocol":"","source":"/session/07e53c90-6b45-11e9-892c-4faf7180871b/url","queryKey":{},"chunks":["session","07e53c90-6b45-11e9-892c-4faf7180871b","url"]}}
Command duration or timeout: 10.20 seconds
Build info: version: 'unknown', revision: 'unknown', time: 'unknown'
System info: host: 'ip-10-20-1-73.ec2.internal', ip: '10.20.1.73', os.name: 'Linux', os.arch: 'amd64', os.version: '3.10.0-862.2.3.el7.x86_64', java.version: '1.8.0_171'
Driver info: org.openqa.selenium.remote.RemoteWebDriver
Capabilities [{applicationCacheEnabled=false, rotatable=false, handlesAlerts=false, databaseEnabled=false, version=2.1.1, platform=LINUX, browserConnectionEnabled=false, proxy=Proxy(direct), nativeEvents=true, acceptSslCerts=false, driverVersion=1.2.0, locationContextEnabled=false, webStorageEnabled=false, browserName=phantomjs, takesScreenshot=true, driverName=ghostdriver, javascriptEnabled=true, cssSelectorsEnabled=true}]
Session ID: 07e53c90-6b45-11e9-892c-4faf7180871b
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_171]
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[?:1.8.0_171]
        at 
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
Jebaseelan Ravi
  • 697
  • 8
  • 22
  • what is the URL you are trying to get? can you share your entire code? (how you create the driver etc.) what is the phantomjs driver version you are using? what is the selenium server version ? – Adi Ohana Apr 30 '19 at 14:29
  • try read this post: https://groups.google.com/forum/#!topic/phantomjs/6HIIB5AI010 – Adi Ohana Apr 30 '19 at 14:32
  • Thank you for looking into this.The URL differs from time to time.The error occurs for all the URLs. Phantomjs version is 2.1.1 and selenium version is 2.52.0.We create the driver in following way. new RemoteWebDriver(new URL( cdaddress), capabilities); – Jebaseelan Ravi May 02 '19 at 06:01

1 Answers1

2

RemoteWebDriver is a keyword/researved word. So instances of RemoteWebDriver should be differently named. Additionally while invoking RemoteWebDriver you need to pass the URL of the Selenium Grid Hub and the instance of DesiredCapabilities as mandatory arguments and you can use the following (Windows based) solution:

File path=new File("C:\\Utility\\phantomjs-2.1.1-windows\\bin\\phantomjs.exe");
System.setProperty("phantomjs.binary.path",path.getAbsolutePath());
DesiredCapabilities capabilities = DesiredCapabilities.phantomjs();
capabilities.setPlatform(Platform.XXX);         
driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), capabilities);
driver.get("https://www.google.co.in");
System.out.println(driver.getTitle());
driver.quit();
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352