Grails, Geb, Selenium w/ Chrome: Unable to Connect? - grails

Problem
My selenium functional test is failing when I run using the Chrome driver, but works when using Firefox.
My Environment
Mac OS X Mountain Lion
Chrome Version 22.0.1229.94
Build info: version: '2.2.1', revision: '16551', time: '2012-04-11 21:42:35'
System info: os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.8.2', java.version: '1.6.0_35'
Driver info: driver.version: ChromeDriver
Steps to Reproduce
The exception occurs when using the Geb Grails example application from github.
Run the application using the Chrome driver:
grails -Dgeb.env=chrome test-app
The tests will begin to run, an instance of Chrome is successfully opened, but nothing happens afterwards. The Chrome browser isn't directed to a url, it just sits there with a silly grin on its face. The below error is thrown in the console after a 15 second (or so) timeout.
The Error
Caused by: org.openqa.selenium.WebDriverException: Unable to either launch or connect to Chrome.
Please check that ChromeDriver is up-to-date. Using Chrome binary
at: /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
My Debugging Steps
Per this stackoverflow post, I've attempted various different versions of the driver with no effect.
The tests are successful when using the Firefox driver (sadly, I must test with Chrome).
Attempt to use the latest beta of chrome Version 23.0.1271.40 beta. no luck.
Upgraded the geb and selenium versions in the test app to latest and greatest: def gebVersion = "0.7.2" def seleniumVersion = "2.25.0"
Humble Thanks Section
Thanks for taking a look at this. I'd love to adopt geb, but its been an uphill battle to date.

Might be a silly answer but did you install the chrome driver? http://code.google.com/p/selenium/wiki/ChromeDriver
For Firefox, you don't need to install a driver but for Chrome and IE, you do. That may be why your tests are running using FF and not chrome.
Good luck!

I am not sure that it is Geb related, I think you will get the similar behaviour when you run the tests using WebDriver Chrome Driver.
I have seen these kind of errors when Chrome is not on the path.
chrome.binary should always be the absolute path to the actual executable. for mac, this usually look like:
/Applications/Google Chrome.app/Contents/MacOS/Google Chrome
What version of Selenium/WebDriver you are using?

Related

Rails headless browser testing without installing browser

We're doing some testing in Rails using a headless browser for our feature tests using RSpec and the web drivers gem: https://github.com/titusfortner/webdrivers to get the Chrome driver.
However we've had some issues whereby some developers don't have Chrome installed (and don't intend to) and also we have our app running on a Jenkins pipeline and we want to avoid having to install Chrome on the server for the tests...
Is it possible to run a headless browser without installing the actual browser as well as a hard dependancy on the system that the tests run on?
I've read conflicting articles that state headless allows you to still do your testing either when the system doesn't have the browser installed... but at the same time the documentation for Chrome and Firefox state the browser also needs to be installed when using their drivers.
https://github.com/rubycdp/cuprite I also came across this which bypasses the need for WebDriver etc... but still seems to have a hard dependancy on having Chrome installed on the system the tests run on.
You have to choose a browser:
Chrome: chromedriver
Firefox: geckodriver
Edge: edgedriver
Internet Explorer: iedriver
See https://github.com/titusfortner/webdrivers

Debug of Angular Dart stopped working in PhpStorm

I have quite big Angular Dart project in PhpStorm. I was able to debug it, but suddenly it doesn't work anymore (for few weeks). I'm not sure what's the reason as I upgraded PhpStorm, Dart Plugin and Dart. But I expect debug to be working with all updates.
I created the simpliest Angular Dart app (ToDo example) to see if it helps. It didn't.
Dart VM version: 2.3.1 (Tue May 21 19:28:38 2019 +0200) on "linux_x64"
PhpStorm 2019.1.2
Build #PS-191.7141.52, built on May 8, 2019
JRE: 1.8.0_202-release-1483-b49 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Linux 5.0.17-300.fc30.x86_64
PhpStorm Dart plugin v191.7221
Google Chrome Version 74.0.3729.169 (Official build) (64bit)
Dart is listening on port 53322 for HTTP connections from browser, PhpStorm is listening on debug port 63344 (and has a connection from Chrome), Chrome is listening on debug port 45389 (and has a connection from PhpStorm).
When I open http://localhost:53322/index.html I see the app, but the execution is not stopped on breakpoints.
I've found similar bugs (https://youtrack.jetbrains.com/issue/WEB-30593, Angular dart on WebStorm. Debug is no more working) but the provided solutions didn't help.
Is there a way to make debug working again? I'd like to avoid downgrading.
Not specific to Angular - debugging web apps doesn't work with SDK 2.3.1. Please follow WEB-39095 for updates.
Workarounds:
Start debug session from WebStorm. Breakpoints won't work. Stop Debug
session.
Without closing the project go to Terminal and run pub global activate webdev 1.0.1.
Start debug session from WebStorm again. Breakpoints should work.
Or:
Run webdev server manually from Terminal explicitly specifying hostname, for example: pub global run webdev serve --hostname 127.0.0.1 web:53322
In the IDE create JavaScript Debug run configuration that opens webdev URL directly, e.g. http://localhost:53322/index.html, press Debug
Update: it was a bug in webdev (no sourcemaps on ipv4). Bug is fixed in webdev 2.0.7. No actions needed, WebStorm will auto-update webdev automatically to the latest version

Site rendering broken on iOS and Mac OSX after moving to JDK 10 and JSF 2.3 with WildFly

Good day
Issue below is solved on WildFly 13 by disabling HTTP/2 (while still keeping TLS for HTTPS).
Even the non effected browser and system combos (all the non Apple stuff) seem to load much faster now.
Follow instructions from this post on how to disable HTTP/2:
https://developer.jboss.org/message/984394?et=watches.email.thread#984394
From the ./jboss-cli.sh cli just run:
/subsystem=undertow/server=default-server/https-listener=https:write-attribute(name=enable-http2,value=false)
And reload / restart the server. All devices render perfectly and fast.
I am leaving the below if somebody else runs into a similar error.
I updated my code and POM file to use the Java EE 8 dependencies for WildFly 13 based on the WildFly 13 BOM POM and the #Balusc JSF 2.3 Java EE 8 kickoff sample application.
So I set it to use:
JSF 2.3.5.Final
OmniFaces 3.1
PrimeFaces 6.2.7
On desktop (all operating systems with all of the latest browsers) the site works 100% and the war is deployed in half the time.
However the site fails to render correctly on my iPhone. I tried all browsers installable from the app store, and the one that looks the nearest to correct is Firefox.
However even with Firefox I can't get pass the login screen.
On Android and all non Apple based products the site works without any error logs.
Is anybody aware of issues rendering JSF 2.3 on Apple based products?
Any pointers on what to look for, add or change will be most appreciated.
See below for log file info:
The initial error only triggered from iOS / Mac OSX is an UNDERTOW error with OmniFaces info (we are using TLS for HTTPS, but before moving all to JSF 2.3 everything worked 100% with zero errors or warnings in logs)
2018-07-30 09:09:18,741 ERROR [io.undertow] (default task-3078) UT005085: Connection io.undertow.server.protocol.http2.Http2ServerConnection#7e55834 for exchange HttpServerExchange{ GET /edsnext/javax.faces.resource/omnifaces.js.xhtml request {accept=[text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8], accept-language=[en-us], :authority=[edsnext.megchemsa.com:62543], accept-encoding=[gzip, deflate], :path=[/edsnext/javax.faces.resource/omnifaces.js.xhtml?ln=omnifaces&v=3.1], user-agent=[Mozilla/5.0 (iPhone; CPU iPhone OS 12_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.0 Mobile/15E148 Safari/604.1], :scheme=[https], cookie=[JSESSIONID=U5X9u-A83bccAnpA1XUnEFzmngqI9iDJwuIiU_Qo], :method=[GET], Referer=[https://edsnext.megchemsa.com:62543/edsnext/], upgrade-insecure-requests=[1], Host=[edsnext.megchemsa.com:62543]} response {Expires=[Mon, 30 Jul 2018 09:57:18 GMT], ETag=[W/"5933-1532705069245"], Last-Modified=[Fri, 27 Jul 2018 15:24:29 GMT], Set-Cookie=[JSESSIONID=U5X9u-A83bccAnpA1XUnEFzmngqI9iDJwuIiU_Qo.edsnext; path=/edsnext], Content-Type=[application/javascript], Date=[Mon, 30 Jul 2018 07:09:18 GMT], :status=[200]}} was not closed cleanly, forcibly closing connection
Then the following PrimeFaces resource not found warnings (and login page is rendered incorrectly on iOS)
2018-07-30 09:09:21,056 WARNING [javax.enterprise.resource.webcontainer.jsf.application] (default task-3091) JSF1064: Unable to find or serve resource, fa/fontawesome-webfont.eot, from library, primefaces.
2018-07-30 09:09:21,056 WARNING [javax.enterprise.resource.webcontainer.jsf.application] (default task-3084) JSF1064: Unable to find or serve resource, fonts/lato-regular-webfont.svg, from library, primefaces-omega.
2018-07-30 09:09:21,056 WARNING [javax.enterprise.resource.webcontainer.jsf.application] (default task-3082) JSF1064: Unable to find or serve resource, fa/fontawesome-webfont.ttf, from library, primefaces.
2018-07-30 09:09:21,056 WARNING [javax.enterprise.resource.webcontainer.jsf.application] (default task-3100) JSF1064: Unable to find or serve resource, fa/fontawesome-webfont.svg, from library, primefaces.
2018-07-30 09:09:21,056 WARNING [javax.enterprise.resource.webcontainer.jsf.application] (default task-3103) JSF1064: Unable to find or serve resource, fonts/lato-bold-webfont.svg, from library, primefaces-omega.
2018-07-30 09:09:21,056 WARNING [javax.enterprise.resource.webcontainer.jsf.application] (default task-3091) : java.nio.channels.ClosedChannelException
EDIT: Added log file info pointing to UNDERTOW errors followed by lots of PrimeFaces missing resources.
EDIT 2:
Ok, I tested this with:
Server side:
CentOS 7.5 all updated
Oracle JDK 10.1
WildFly 13.0.0.Final
JSF 2.3.5.SP1
PrimeFaces 6.2.7
OmniFaces 3.1
The following setups renders the site perfectly with zero errors or warning at debug level:
CentOS GNOME 7.5 Chromium
CentOS GNOME 7.5 Firefox Developer Edition
Windows 10 Chrome
Windows 10 Firefox Developer Edition
Android Studio Nexus 5 AVD APK 28 Chrome
Samsung Galaxy S7 Chrome
Samsung Galaxy S7 Firefox
All browsers installable from the Apple app store including Safari fails to render the site. All have the UNDERTOW error.
Tested with Mac OSX - latest updated version - also fails with the UNDERTOW error.
I logged a bug report with Apple. Problem is though that a substantial amount of users are effected by this due to having to access the Web app via their iPhone or iPad.
What else can I do to expedite this?
To resolve this error disable HTTP/2 on WildFly 13 with:
Follow instructions from this post on how to disable HTTP/2:
https://developer.jboss.org/message/984394?et=watches.email.thread#984394
From the ./jboss-cli.sh cli just run:
/subsystem=undertow/server=default-server/https-listener=https:write-attribute(name=enable-http2,value=false)
Restart / reload the server and all is well.

How to run webdriver test cases on remote staging server(ubuntu) using jenkins?

I pushed the code on github
I have configured Jenkins on
staging.website.com:8xxx , its a Ubuntu machine
I am able to access this ubuntu machine via putty.exe from my windows7 machine
I am able to fetch the code on github via Jenkins means I am able to run the build via Jenkins but it fails as Problem: I am not able to launch the browser.
I tried
DesiredCapabilities capability = DesiredCapabilities.firefox();
capability.setCapability("platform", Platform.LINUX);
capability.setCapability("binary", "usr/bin/firefox");
driver= new FirefoxDriver();
driver.get("mytestproject.com");
but it gives error( though I am using latest selenium jar 2.35.0, tried maven clean and restart of server) :
Failed to connect to binary FirefoxBinary(/usr/bin/firefox) on port 7055; process output follows: Error: no display specified Error: no display specified Build info: version: '2.35.0', revision: '8df0c6bedf70ff9f22c647788f9fe9c8d22210e2', time: '2013-08-17 12:46:41' System info: os.name: 'Linux', os.arch: 'amd64', os.version: '3.5.0-21-generic', java.version: '1.7.0_25' Driver info: driver.version: FirefoxDriver
org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:118)
at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:251)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:110)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:195)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:190)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:186)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:99)
I have checked using sudo lsof -i :7055that nothing is using this port (via putty on remote ubuntu machine)
But after reading many forums I couldnt solve it. So I tried to use phantomjs but it also gave error :
I tried :
dCaps = new DesiredCapabilities();
dCaps.setJavascriptEnabled(true);
dCaps.setCapability("takesScreenshot", false);
driver = new PhantomJSDriver(dCaps);
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.get(Prod);
It gave red line below driver = new PhantomJSDriver(dCaps); . Actually I dont know how to use Phantom.js in Maven project.
What I want to achieve : I want to run test case on this remote ubuntu staging server, nomatter headless (ghostdriver) or firefox.
I think it might be failing from Jenkins because it is running in a new terminal window with no display defined. It appears as though the Firefox process doesn't allow this.
"Error: no display specified"
This might help:
How can I specify a display?
Why you not let it to use default Firefox binary? Jenkins need only Firefox that is installed for All Users. If i remember correctly firefox is default in any Ubuntu.
Failed to connect to binary FirefoxBinary(/usr/bin/firefox) on port 7055;

Grails 1.3.7 spring security - No thread-bound request found at start

Suffering badly from the bug below.
See http://jira.grails.org/browse/GPSPRINGSECURITYCORE-98
Works fine in my mac os x environment but fails badly on my collegues ubuntu.
/S
Removing the resources plugin seems to fix it for us.

Resources