Nightwatch.js without Java - java

Is it possible to use Nightwatch.js without installing Java? There are official Selenium JavaScript bindings (WebDriverJS, selenium-webdriver). Is there a reason Java is required?

I am catering to a JavaScript community so I am trying to run nightwatchjs locally without introducing Java myself. I am certain that if you run a remote Selenium Server, that remote instance has to have the Java server running to pass off commands to the remote browser-specific driver. E.g.: ChromeDriver.
That said, I was under the impression that one could connect a standard client directly to a standard WebDriver (ChromeDriver) locally without having to stage the Java selenium-server-standalone-2.xx.0.jar server. With nightwatchJS being the 1st client I have tried, it was very hard to find a configuration where that would work since all the documentation indicates what Nate Stone is saying above. All examples that I have seen indicate that the location of the selenium-server-standalone-2.xx.0.jar needs to be stipulated:
selenium": {
"start_process": true,
"server_path": "lib/selenium-server-standalone-2.53.0.jar",
"cli_args" : {
"webdriver.chrome.driver" : "/Users/greg.kedge/bin/chromedriver"
},
"log_path": "integration/log" }
He's what I can say: if you want nightwatch to start (and stop) the server for you for the duration of the tests ("start_process": true), it does seem to be necessary to run the Java server.
However, through much trial, if you want to start the ChromeDriver on your own on the command line, thereby having it up all the time, I can run the ChromeDriver without the Java Selenium standalone. CAVEAT: Only attempted on OS X so far... So, assuming ChromeDriver is in your $PATH:
% chromedriver --url-base=/wd/hub
Starting ChromeDriver 2.21.371459 (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4) on port 9515
Only local connections are allowed.
Now grab that port (9515) and update your nightwatch.json to dictate you want to use Chrome. I am setting the default, but you could set up a Chrome-specific environment. Remove the "selenium" block from your nightwatch.json altogether and now tell nightwatch where it can find a running server AND what type of browser that is serving:
"test_settings": {
"default": {
"launch_url": "http://localhost:8888/",
"selenium_host": "127.0.0.1",
"selenium_port": "9515",
"silent": true,
"firefox_profile": false,
"screenshots": {
"enabled": false,
"path": ""
},
"desiredCapabilities": {
"browserName": "chrome",
"javascriptEnabled": true,
"acceptSslCerts": true,
"__commentOut: chromeOptions" : {
"args" : ["start-fullscreen"]
}
},
}
}
Using it this way works for me; I can run nightwatch to drive Chrome without a Java Selenium standalone server in-play. Again, this is on OS X using a ChromeDriver that is always running. I can't figure out how to get nightwatch to manage starting/stopping the ChromeDriver without adding the Java Selenium standalone server to the mix.

There is now documentation on the official site on how to do it.
I had some trouble with the configuration, so I have created a sample repository with working code:
https://github.com/zeljkofilipin/mediawiki-nightwatch

Well Nightwatch.js runs it's tests against the Selenium server. The Selenium server is a Java-Servlet.
So to use Nightwatch.js you just "indirectly" need Java (it's not needed for Nightwatch.js, but for Selenium).
However you are able to use different languages as Selenium Client, since you are able to download different WebDriver Language bindings here
++++++++++++++++++EDIT++++++++++++++++++
Those WebDrivers/bindings are independent of Nightwatch.js. You can use these WebDrivers/bindings without a Selenium server, if your tests and your browser run on the same machine. In this case you do not need Java, since the WebDriver runs the tests directly against a browser (this is further detailed here)
Nightwatch.js on the other hand definitelly requires java, because it needs the "Selenium-Standalone-Server" which is written in Java. As far as I know there are no other implementations for other languages, which is why it's not possible to run it without java.
Nightwatch sends HTTP requests to the Selenium-Standalone-Server (here comes java) and the server creates a session with the browser.
So to sum up: No Java --> No "Selenium-Standalone-Server" --> No testing with Nightwatch.js

There is:
Specify in global.js file the following:
const chromedriver = require('chromedriver');
module.exports = {
before: function (cb) {
chromedriver.start();
cb();
},
after: function (cb) {
chromedriver.stop();
cb();
},
Go to nightwatch.conf.js specify the global path there
That way you selenium will be diverted via Chromedriver without you needing selenium on your machine.

Related

Jmeter and MemCached Sets and Gets

So apologies if what I ask is trivial but I am experimenting with Memcached and Jmeter. I have a Memcached server setup (as far as I can tell) and am able to make telnet requests to it via telnet IP PORT and additionally set and get using commands set and get appropriately.
Now point me to a different application if perhaps this is the wrong choice; but my understanding was that Jmeter should allow me to pound the server with equivalent Set and Get requests.
Unfortunately the experimental platform is a remote linux PC running Rockylinux which is similar to CentOS / RedHat to my understanding (I didn't set this part up); and as a result I do not have a GUI to launch while on the Linux PC. I have however opened Jmeter up on my local PC on windows and understand I should be able to send the test file over and run it.
I followed these instructions to try to setup a TCP sampler and set the "text to send" field as below; after doing the additional step in the link regarding the precompiler.
set tutorialspoint 0 900 9${CR}${LF}
memcached${CR}${LF}
quit${CR}${LF}
Running the above as a headless jmeter session doesn't generate any errors called [./jmeter -n -t "Sample.jmx" -l testresults.jtl"] but when I connect via telnet I'm also not seeing the value for the key "tutorialspoint" get updated. When manually doing the get and set I am seeing updates. Any ideas what I could be doing wrong? Checking the log indicates ResponseCode 200 OK as expected. Is there a good method to debug something in a Headless setup?
Thanks for your time.
I believe the easiest way is using Memcached Java Client library
Download spymemcached-2.12.3.jar and drop it to "lib" folder of your JMeter installation (or any other location in JMeter Classpath)
Restart JMeter to pick the .jar up
Add JSR223 Sampler to your test plan and use the following code snippets:
def client = new net.spy.memcached.MemcachedClient(new InetSocketAddress('your-memcached-host', your-memcached-port)) - for connecting to the server
client.set('tutorialspoint', 900, 'memcached').done to write memcached to the tutorialspoint key for 15 minutes
client.get('tutorialspoint') - to read the value of tutorialspoint key
client.shutdown() - to disconnect
More information on Groovy scripting in JMeter: Apache Groovy - Why and How You Should Use It
Demo:

Browser Stack | Selenium Webdriver | Handling Windows host file enteries

I have Hybrid Framework using Selenium Webdriver that successfully executes test cases against Firefox, Chrome and IE. Now, I wanted to run this entire suite using Browserstack.
However, when I try to access the application I make entries in the host file - the ipaddress and the host name. This makes sure that I'm hitting the exact server.
Using Java code on https://www.browserstack.com/automate/java I'm able to execute a sample script.
However, how can I pass the ipaddress mapping of my application to my Selenium instance when executing it on Browserstack?
The BrowserStack Local Testing feature (https://www.browserstack.com/local-testing) should help you test your private servers configured in your hosts file. Please follow these steps:
1) Download and execute the Local Testing binaries (https://www.browserstack.com/local-testing#command-line) using the following command:
./BrowserStackLocal ACCESS_KEY -forcelocal
The '-forcelocal' parameter will route all traffic via your machine which allows you to test servers configured in your hosts file on BrowserStack.
2) Add the capability 'browserstack.local'='true' in your test scripts and execute them.

Selenium can't start session because url doesn't support http post

I'm trying to run some Selenium tests for an application while it is started, but am getting a runtime exception:
Could not start Selenium session: HTTP method POST is not supported by this URL
The application we made has no need for a POST method. Is there any way to make Selenium work without needlessly implementing one? Why is it required in the first place?
The parameters to pass for DefaultSelenium are as follows according to the api documentation:
serverHost - the host name on which the Selenium Server resides
serverPort - the port on which the Selenium Server is listening
browserString - the command string used to launch the browser
browserURL - the starting URL including just a domain name
You need to direct it to where an instance of your selenium server is running (which could be remotely or locally). I am going to guess that localhost:8080 is where you have deployed a separate application that you want to test with selenium.
So, the details you provide are for the selenium server, not for your application. If you download the standalone server and run it locally, you only need to change the port to match that of the selenium server instance. You can download the selenium standalone server from their main website, and when you run it, it will tell you the port that it uses (by default it is 4444).
Why not just use WebDriver instead?
WebDriver driver = new FirefoxDriver();
driver.get("URL")
You can read more about how to use it on the documentation page on the selenium website.

javascript check if java enabled in IE WITHOUT running jar

I wanna detect if java is enabled in a browser without running any jars.I did this in Chrome and Firefox with the navigator.plugins and it's working great, but in IE its returning always true.Any ideas?Thanx in advance.

Why multiple chromedriver instance keeps on running after completion of a test suite

I am using chrome driver 2.1 and Google chrome 28.
Selenium standalone server 2.31. I run a set of 350 test and at the end 25 chrome-driver instances are running.
I don't know what test framework are using, but for me it happened with Selenium and MSTest. The problem was that the [TestCleanup] attribute is not executed if something fails while the code from [TestInitialize] is running.
Because of this, since I was calling driver.Quit() in my [TestCleanup] I ended up having a lot of server instances opened, and even managed to deplete the server machine's memory after some huge UI changes in our app.
It's not just in case of chrome driver. It is the same with firefox driver.
If you forgot to use server.stop() or your program interrupted in between, you can use this port to start your server from next time
import org.browsermob.proxy.ProxyServer;
Import the above.
String sePortNumber = System.getProperty("WEBDRIVER_SERVER_PORT_NUMBER");
if (sePortNumber == null) {
sePortNumber="0";
}
ProxyServer server = new ProxyServer(Integer.parseInt(sePortNumber));
server.start();
You will get a random unused port every time.

Categories

Resources