1

I have a simple automation selenium code which visits a website and performs a login operation....

WebDriver driver = new PhantomJSDriver();
        driver.manage().window().maximize();
        driver.manage().timeouts().pageLoadTimeout(30, TimeUnit.SECONDS);
        driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
        driver.get("http://upload4earn.org/");
        TimeUnit.SECONDS.sleep(15);
        driver.findElement(By.xpath("//input[@value='Username']")).sendKeys("Jorge");
        driver.findElement(By.xpath("//input[@value='Password']")).sendKeys("test123456");
        driver.findElement(By.xpath("//input[@value='Submit']")).click();
        TimeUnit.SECONDS.sleep(3);

So after running the script i'm getting the following error

Feb 06, 2019 11:55:21 PM org.openqa.selenium.phantomjs.PhantomJSDriverService <init>
INFO: executable: C:\Users\Nigga\eclipse-workspace\HeadLessBrowser\phantomjs.exe
Feb 06, 2019 11:55:21 PM org.openqa.selenium.phantomjs.PhantomJSDriverService <init>
INFO: port: 40366
Feb 06, 2019 11:55:21 PM org.openqa.selenium.phantomjs.PhantomJSDriverService <init>
INFO: arguments: [--webdriver=40366, --webdriver-logfile=C:\Users\Nigga\eclipse-workspace\HeadLessBrowser\phantomjsdriver.log]
Feb 06, 2019 11:55:21 PM org.openqa.selenium.phantomjs.PhantomJSDriverService <init>
INFO: environment: {}
[INFO  - 2019-02-06T18:25:25.325Z] GhostDriver - Main - running on port 40366
[INFO  - 2019-02-06T18:25:25.960Z] Session [92b8f4f0-2a3c-11e9-844e-25707495b5e3] - page.settings - {"XSSAuditingEnabled":false,"javascriptCanCloseWindows":true,"javascriptCanOpenWindows":true,"javascriptEnabled":true,"loadImages":true,"localToRemoteUrlAccessEnabled":false,"userAgent":"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/538.1 (KHTML, like Gecko) PhantomJS/2.1.1 Safari/538.1","webSecurityEnabled":true}
[INFO  - 2019-02-06T18:25:25.960Z] Session [92b8f4f0-2a3c-11e9-844e-25707495b5e3] - page.customHeaders:  - {}
[INFO  - 2019-02-06T18:25:25.961Z] Session [92b8f4f0-2a3c-11e9-844e-25707495b5e3] - Session.negotiatedCapabilities - {"browserName":"phantomjs","version":"2.1.1","driverName":"ghostdriver","driverVersion":"1.2.0","platform":"windows-7-32bit","javascriptEnabled":true,"takesScreenshot":true,"handlesAlerts":false,"databaseEnabled":false,"locationContextEnabled":false,"applicationCacheEnabled":false,"browserConnectionEnabled":false,"cssSelectorsEnabled":true,"webStorageEnabled":false,"rotatable":false,"acceptSslCerts":false,"nativeEvents":true,"proxy":{"proxyType":"direct"}}
[INFO  - 2019-02-06T18:25:25.961Z] SessionManagerReqHand - _postNewSessionCommand - New Session Created: 92b8f4f0-2a3c-11e9-844e-25707495b5e3
[ERROR - 2019-02-06T18:25:30.524Z] Session [92b8f4f0-2a3c-11e9-844e-25707495b5e3] - page.onError - msg: ReferenceError: Can't find variable: EventTarget

  phantomjs://platform/console++.js:263 in error
[ERROR - 2019-02-06T18:25:30.525Z] Session [92b8f4f0-2a3c-11e9-844e-25707495b5e3] - page.onError - stack:
  setupEventListenerProxy (https://ajax.cloudflare.com/cdn-cgi/scripts/cb7744ae/cloudflare-static/rocket-loader.min.js:1)
  t (https://ajax.cloudflare.com/cdn-cgi/scripts/cb7744ae/cloudflare-static/rocket-loader.min.js:1)
  (anonymous function) (https://ajax.cloudflare.com/cdn-cgi/scripts/cb7744ae/cloudflare-static/rocket-loader.min.js:1)
  (anonymous function) (https://ajax.cloudflare.com/cdn-cgi/scripts/cb7744ae/cloudflare-static/rocket-loader.min.js:1)

  phantomjs://platform/console++.js:263 in error
[ERROR - 2019-02-06T18:25:42.108Z] Session [92b8f4f0-2a3c-11e9-844e-25707495b5e3] - page.onError - msg: TypeError: undefined is not a constructor (evaluating 'c[Y('0x42')](0,12)')

  phantomjs://platform/console++.js:263 in error
[ERROR - 2019-02-06T18:25:42.109Z] Session [92b8f4f0-2a3c-11e9-844e-25707495b5e3] - page.onError - stack:
  (anonymous function) (https://upload4earn.org/:420)

  phantomjs://platform/console++.js:263 in error
[ERROR - 2019-02-06T18:25:54.154Z] Session [92b8f4f0-2a3c-11e9-844e-25707495b5e3] - page.onError - msg: ReferenceError: Can't find variable: EventTarget

  phantomjs://platform/console++.js:263 in error
[ERROR - 2019-02-06T18:25:54.155Z] Session [92b8f4f0-2a3c-11e9-844e-25707495b5e3] - page.onError - stack:
  setupEventListenerProxy (https://ajax.cloudflare.com/cdn-cgi/scripts/cb7744ae/cloudflare-static/rocket-loader.min.js:1)
  t (https://ajax.cloudflare.com/cdn-cgi/scripts/cb7744ae/cloudflare-static/rocket-loader.min.js:1)
  (anonymous function) (https://ajax.cloudflare.com/cdn-cgi/scripts/cb7744ae/cloudflare-static/rocket-loader.min.js:1)
  (anonymous function) (https://ajax.cloudflare.com/cdn-cgi/scripts/cb7744ae/cloudflare-static/rocket-loader.min.js:1)

  phantomjs://platform/console++.js:263 in error

I tried this script with chrome webdriver and it's working fine and i also checked that if javascript is enabled or not and it is enabled by default, also added 15 second sleep to wait if there's cloudflare is checking for ddos. And also tried checking on web for solution but couldn't find any solution for that.

  • If with works with chrome, why not use headless chrome instead of phantomjs? – cody Feb 06 '19 at 20:12
  • @cody Anything wrong with PhantomJS? – undetected Selenium Feb 06 '19 at 20:14
  • 1
    @DebanjanB Well, for one, it's no longer under active development: https://github.com/ariya/phantomjs/issues/15344 – cody Feb 06 '19 at 20:17
  • @DebanjanB But primarily, the OP said it worked with chromedriver, so I was just asking why not use headless chrome instead of phantomjs – cody Feb 06 '19 at 20:18
  • @cody You are referring to a discussion which is almost an year old. Anyways, broadly _PhantomJS_ is still supported and you can find lots of relevant recent discussion on SO itself. – undetected Selenium Feb 06 '19 at 20:21
  • @cody It is a known issue that new contributors often mixes up PhantomJS and Headless Chrome. Perhaps the _browsing engine_ is different in both the cases. So some differences are pretty much expected. – undetected Selenium Feb 06 '19 at 20:26
  • 1
    @DebanjanB , PhantomJS bindings in selenium *are* deprecated and mostly removed. Rather than relying on arbitrary SO discussions, you could always check the code and see for yourself. – Corey Goldberg Feb 07 '19 at 04:25

0 Answers0