grails + selenium-rc plugin - cannot run sample test - grails

I have no idea what I do wrong. I would like to use selenium-RC plugin for Grails to do some functional testing. I have created sample test using build-in script (i guess add-selenium-test), which generated (i modified it slighty):
import grails.plugins.selenium.*
import org.junit.*
import static org.junit.Assert.*
import static org.hamcrest.Matchers.*
#Mixin(SeleniumAware)
class FirstTestTests {
#Before void setUp() {
}
#After void tearDown() {
super.tearDown()
}
#Test void something() {
selenium.open "/activate"
assertTrue selenium.isTextPresent("activate")
}
}
I configured SeleniumConfig
selenium {
slow = false // true to run tests in slow resources mode
singleWindow = true // true for single window mode, false for multi-window mode
browser = "*firefox" // can include full path to executable, default value is *firefox or *iexplore on Windows
url = "http://localhost:8080" // the base URL for tests, defaults to Grails server url
defaultTimeout = 3000 // the timeout after which selenium commands will fail
windowMaximize = true // true to maximize browser on startup
screenshot {
dir = "./target/test-reports/screenshots" // directory where screenshots are placed relative to project root
onFail = true // true to capture screenshots on test failures
}
server {
host = "localhost" // the host the selenium server will run on
port = 4444 // the port the selenium server will run on
}
userExtensions = "" // path to user extensions javascript file
}
and I then I typed
grails test-app :selenium
and it seems that everything is done correctly:
INFO 19:30:08,304 RemoteWebDriver instances should connect to: http://127.0.0.1:
4444/wd/hub org.openqa.selenium.server.SeleniumServer
Starting Selenium server on port 4444 ...
INFO 19:30:08,312 Version Jetty/5.1.x org.openqa.jetty.http.HttpServer
INFO 19:30:08,315 Started HttpContext[/selenium-server/driver,/selenium-server/d
river] org.openqa.jetty.util.Container
INFO 19:30:08,318 Started HttpContext[/selenium-server,/selenium-server] org.ope
nqa.jetty.util.Container
INFO 19:30:08,321 Started HttpContext[/,/] org.openqa.jetty.util.Container
INFO 19:30:08,326 Started org.openqa.jetty.jetty.servlet.ServletHandler#55881a8f
org.openqa.jetty.util.Container
INFO 19:30:08,328 Started HttpContext[/wd,/wd] org.openqa.jetty.util.Container
INFO 19:30:08,338 Started SocketListener on 0.0.0.0:4444 org.openqa.jetty.http.S
ocketListener
INFO 19:30:08,340 Started org.openqa.jetty.jetty.Server#42aefb01 org.openqa.jett
y.util.Container
Starting Selenium session for http://localhost:8080 ...
INFO 19:30:08,502 Checking Resource aliases org.openqa.jetty.util.Credential
INFO 19:30:08,510 Command request: getNewBrowserSession[*firefox, http://localho
st:8080, ] on session null org.openqa.selenium.server.SeleniumDriverResourceHand
ler
INFO 19:30:08,512 creating new remote session org.openqa.selenium.server.Browser
SessionFactory
INFO 19:30:08,586 Allocated session 9250557308cc4886a25100eb6c5f3d7e for http://
localhost:8080, launching... org.openqa.selenium.server.BrowserSessionFactory
INFO 19:30:08,717 Preparing Firefox profile... org.openqa.selenium.server.browse
rlaunchers.FirefoxChromeLauncher
INFO 19:30:11,726 Launching Firefox... org.openqa.selenium.server.browserlaunche
rs.FirefoxChromeLauncher
The firefox window is opened, but nothing loads and nothing seems to proceed. Do I miss something?

Sounds to me like an incompatibility between the Selenium RC plugin and the current version of your web browser. You might want to dig into the plugin's dependencies and update everything to the latest versions if you're using a newer version of the browser.
We see this with Geb ( http://www.gebish.org ) when trying to run a webdriver version that is not compatible with the driver version.

Just to add, if you use Chrome and your OS is Ubuntu, then make sure you put the full path to Chrome and make sure that the executable path references chromium-browser and NOT google-chrome.
So your SeleniumConfig should look like this with the relevant line in double asterisks:
selenium {
slow = false
singleWindow = true
**browser = "*googlechrome /usr/bin/chromium-browser"**
url = null
defaultTimeout = 60000
windowMaximize = false
screenshot {
dir = "./target/test-reports/screenshots"
onFail = false
}
server {
host = "localhost"
port = 4444
}
userExtensions = ""
}

Related

Starting Appium programatically using javascript

I am using Javascript with Node.JS and WDIO and trying to start appium programatically in beforeTest hook and stop it in afterTest hook.
I've tried doing so with child_process or some appium-service builder but without any success.
Is there a possibility to start/stop appium server programatically using certain portion of code?
Thanks
You can install appium in your project directory. Import appium and call appium.main(). This will start appium in the default port.
Start appium :
const appium = require('appium');
await appium.main({port : 4723, address : "127.0.0.1"})
Stop appium :
To stop appium programatically, you can kill the process. I used this package - https://www.npmjs.com/package/find-process to find the pid and kill process.
const findProcess = require('find-process')
let processList = await findProcess('port', 4723)
if(processList.length > 0) {
processList.forEach(proc => {
process.kill(proc.pid)
})
}

"Java live reload unavailable" after upgrade to 14.6.0

I'm getting the "Java live reload unavailable"-box after upgrading from 14.4.7 to 14.6.0 with TravaOpenJDK 11.0.9.
Screenshot of "Java live reload unavailable"-box
Is there anything I might have missed in the release notes?
I'm using Gradle with Spring Boot in IntelliJ, and I had included -XX:HotswapAgent=fatjar in my IntelliJ's run configuration. But I didn't respect that bootRun is forking a new JVM! Don't know the coherence to the Vaadin upgrade, but at least it's working now for me after adding -XX:HotswapAgent=fatjar to the bootRun configuration.
In order to not force other developers to use TravaOpenJDK, I'm using this in my build.gradle:
def isUsingTravaOpenJDK() {
// Vendor is AdoptOpenJDK, therefore we identify Trava by its version number:
def knownTravaVersions = ["11.0.9+2-202011221400"]
def currentJVM = System.getProperty("java.vm.version")
return knownTravaVersions.contains(currentJVM)
}
bootRun {
if (isUsingTravaOpenJDK()) {
jvmArgs("-XX:HotswapAgent=fatjar")
}
}
It's currently not possible to use java[.vm].vendor to determine if Trava is used:
java -XshowSettings:properties -version
Property settings:
[...]
java.vendor = AdoptOpenJDK
java.vendor.url = https://adoptopenjdk.net/
java.vendor.url.bug = https://github.com/AdoptOpenJDK/openjdk-support/issues
java.vendor.version = AdoptOpenJDK
java.version = 11.0.9
java.version.date = 2020-10-20
[...]
java.vm.vendor = AdoptOpenJDK
java.vm.version = 11.0.9+2-202011221400

The neo4j cypher shell and the browser connections are working but the golang client connection is not working

I have disabled the authentication on my neo4j server, so I can connect using the cypher shell using no credentials as it follows and is working.
$ ./bin/cypher-shell -a 192.168.0.89
This is how I'm declaring my driver and the session, I also tried using neo4j://* instead of bolt://*:
driver, err := neo4j.NewDriver("bolt://192.168.0.89:7687", neo4j.NoAuth())
if err != nil {
return "", err
}
defer driver.Close()
session, _ := driver.NewSession(neo4j.SessionConfig{AccessMode: neo4j.AccessModeWrite})
defer session.Close()
But that doesn't work either. I'm getting this error when running the hello world from the neo4j olang driver page https://neo4j.com/developer/go/
TLS error: Remote end closed the connection, check that TLS is enabled on the server
There are the logs of the server when it starts:
2021-03-07 23:17:23.227+0000 INFO ======== Neo4j 4.2.3 ========
2021-03-07 23:17:24.119+0000 INFO Performing postInitialization step for component 'security-users' with version 2 and status CURRENT
2021-03-07 23:17:24.119+0000 INFO Updating the initial password in component 'security-users'
2021-03-07 23:17:24.243+0000 INFO Bolt enabled on 192.168.0.89:7687.
2021-03-07 23:17:25.139+0000 INFO Remote interface available at http://192.168.0.89:7474/
2021-03-07 23:17:25.140+0000 INFO Started.
These are all my config settings:
dbms.connector.bolt.advertised_address=192.168.0.89:7687
dbms.connector.bolt.enabled=true
dbms.connector.bolt.listen_address=192.168.0.89:7687
dbms.connector.bolt.tls_level=DISABLED
dbms.connector.http.advertised_address=192.168.0.89:7474
dbms.connector.http.enabled=true
dbms.connector.http.listen_address=192.168.0.89:7474
dbms.connector.https.enabled=false
dbms.default_advertised_address=192.168.0.89
dbms.default_database=neo4j
dbms.default_listen_address=192.168.0.89
dbms.directories.import=/home/eduardo/NEO4J/import
dbms.directories.neo4j_home=/home/eduardo/NEO4J
dbms.jvm.additional=-Dlog4j2.disable.jmx=true
dbms.security.auth_enabled=false
dbms.tx_log.rotation.retention_policy=1 days
dbms.tx_state.memory_allocation=ON_HEAP
dbms.windows_service_name=neo4j
Again, I can connect to the same host and the browser is also working fine:
Thanks in advance for any help :)
Adding to your answer: it is likely you're using the v1.x of the Go driver. If you switch to using the v4.x driver instead, you will not have to specify this config value.
You can upgrade by simply adding v4 in your import statement like so:
import github.com/neo4j/neo4j-go-driver/v4/neo4j
More info: https://github.com/neo4j/neo4j-go-driver/blob/4.2/MIGRATIONGUIDE.md
For anyone looking for the answer, the bolt driver will try to use TLS by default and since in my case is not configured, the encryption needs to be disabled in the driver constructor call.
driver, err := neo4j.NewDriver("bolt://192.168.0.89:7687", neo4j.NoAuth(), func(c *neo4j.Config) { c.Encrypted = false })
Hope this helps other people experiencing the same issue :)

Rails server error not clear

Using OS X Sierra
I have a rails app with two parts: front-end and back-end.
On back-end I am using rails 4.
On the front-end I am using Angular.
Whenever I have to start the server locally (for development or test) I use 3 distinct console windows.
one to run grunt watch"
another to run http-server ./build/ -p 8000 -c-1
and the last to run rails server
My local backend repository is just a clone of what is running on production.(minus server configuration)
When I use the fronted connected to my remote server it works without problems. However, when I run the backend locally and try to log in, all I get is the following log, and no responses:
=> Booting WEBrick
=> Rails 4.2.7 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
[2017-01-02 16:19:21] INFO WEBrick 1.3.1
[2017-01-02 16:19:21] INFO ruby 2.3.3 (2016-11-21) [x86_64-darwin15]
[2017-01-02 16:19:21] INFO WEBrick::HTTPServer#start: pid=10496 port=3000
The front end throws the following error:
XMLHttpRequest cannot load localhost:3000/auth_user?
email=admin#railsapp.com&password=VVVVVVVV. Cross origin requests are
only supported for HTTP.
My Angular endpoint file
angular.module( 'common.config', [] )
.factory('endpoints', function() {
var host = 'development';
if (['live.companysite.com'].indexOf(window.location.host) > -1) {
host = 'production';
} else if (['companysite.com'].indexOf(window.location.host) > -1) {
host = 'development';
} else {
host = 'local';
}
var endpoints = {
'production': {
root: 'http://live.companysite.com/'
},
'development': {
root: 'http://companysite.com/'
},
'local': {
root: 'localhost:3000/'
}
};
return endpoints[host];
});
I know that it should be a CORS problem, but as it works perfectly with two remote servers (production and test) I believe that my local configuration might be the problem.
'localhost:3000auth_user?emai' I think you are missing an '/' before auth_user and after :3000, check the line where you define the api in your angular project, probably you need to add a slash .
Check changing this in your config:
'local': { root: "http:// localhost:3000/" }

Appium Server not connected and throwing org.openqa.selenium.remote.UnreachableBrowserException

I have recently started mobile devices automation on appium with the java language.
I am trying to run the initial setup code through program it is returning this failure message.
Caused by: org.apache.http.conn.HttpHostConnectException: Connect to 127.0.0.1:4723 [/127.0.0.1] failed: Connection refused: connect
When Manual run Appium server it doesn't have any errors and server started; the android apk file is installed.
Below is my code; Eclipse doesn't show any errors. I use Android Emulator for this Initial test. Appium and Java Project code in same host machine.
public void setup() throws MalformedURLException {
WebDriver AppWebDriver = null;
AppiumDriver ApUMDriver = null;
AndroidDriver AppiumURLDriver;
URL Serverurl;
// TODO Auto-generated method stub
DesiredCapabilities Appiumcapabiliy = new DesiredCapabilities();
File appDir = new File("c:\ApkbuildsDir");
File app = new File(appDir, "xxx.apk");
Appiumcapabiliy.setCapability("devicename","Device11");
Appiumcapabiliy.setCapability("platformname","Android");
Appiumcapabiliy.setCapability("platformVersion","4.2.2");
Appiumcapabiliy.setCapability("app-package","packagename");
Appiumcapabiliy.setCapability("app-activity","activityscreen");
Appiumcapabiliy.setCapability("app", app.getAbsolutePath());
Serverurl = new URL("http://127.0.0.1:4723/wd/hub");
AppWebDriver = new AndroidDriver(Serverurl,Appiumcapabiliy);
AppWebDriver.manage().timeouts().implicitlyWait(80, TimeUnit.SECONDS);
ApUMDriver.findElement(By.name("My Card"));
}
Could you please guide me how to eliminate this server connect error through program.
Regards, Kiran
Looks like "Appium server" instance is NOT running in your machine. That is, http://127.0.0.1:4723/wd/hub
Please start the Appium server on 4723 port and try execute your code.

Resources