How to run selenium server in bash - linux

So I've been reading this article about running selenium-ide recorded tests in chrome on windows(http://www.software-testing-tutorials-automation.com/2016/08/run-selenium-ide-test-in-google-chrome.html). I'm using Ubuntu though, and I use newer selenium server version. How should I modify this command for it to work on linux:
java -jar selenium-server-standalone-2.46.0.jar -Dwebdriver.chrome.driver=chromedriver.exe
I know that i have to delete ".exe" but i get an error like this:
Exception in thread "main" com.beust.jcommander.ParameterException: Unknown option: -Dwebdriver.chrome.driver=chromedriver
at com.beust.jcommander.JCommander.parseValues(JCommander.java:742)
at com.beust.jcommander.JCommander.parse(JCommander.java:282)
at com.beust.jcommander.JCommander.parse(JCommander.java:265)
at com.beust.jcommander.JCommander.<init>(JCommander.java:210)
at org.openqa.grid.selenium.GridLauncherV3$1.setConfiguration(GridLauncherV3.java:227)
at org.openqa.grid.selenium.GridLauncherV3.buildLauncher(GridLauncherV3.java:155)
at org.openqa.grid.selenium.GridLauncherV3.main(GridLauncherV3.java:75)

The -Dwebdriver… parameter needs to be passed to java, not Selenium itself. So just switching the argument order should work for you:
java -Dwebdriver.chrome.driver=chromedriver.exe -jar selenium-server-standalone-2.46.0.jar
Relevant Github issues: 1, 2

Related

Selenium webdriver.Remote gets SSL errors on Linux, works on macOS

I'm trying to scrape a third party site using Selenium (I tried using Beautiful Soup, but their authentication system is too difficult to understand so I bailed and used Selenium instead).
I'm using a python script that uses the latest Selenium 3.12.0 drivers, and the selenium-server-standalone-3.12.0.jar. Both my Linux and macOS boxes are running jdk 1.8.0_172.
If I run the script on either Linux or macOS with the selenium server on macOS it works great. If I run the script on either Linux or macOS with the selenium server on Linux, it fails to load jQuery with the following error:
18:28:02.453 ERROR [DefaultJavaScriptErrorListener.loadScriptError] - Error loading JavaScript from [https://ww6.fltplan.com/js/jquery-1.12.3.min.js].
javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1002)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1385)
The site I'm scraping is written very primitively (looks like something out of GeoCities) so it's very likely it's doing something absurd. Oh, and this code was working a few weeks ago and I "froze" it, but then it stopped working in Linux and I had to start tinkering with it again.
Here's my connect code:
capabilities = {
'browserName': 'htmlunit',
'version': 'firefox',
'platform': 'ANY',
'javascriptEnabled': True,
'acceptInsecureCerts': True,
}
driver = webdriver.Remote(
# "http://192.168.1.46:4444/wd/hub", webdriver.DesiredCapabilities.HTMLUNITWITHJS
# "http://localhost:4444/wd/hub", webdriver.DesiredCapabilities.HTMLUNITWITHJS
"http://localhost:4444/wd/hub", capabilities
)
driver.get("https://www.fltplan.com/")
The first commented out Remote url is to Selenium running on my macOS box, it works. The second and third are attempts to make it work on Linux, so far unsuccessful. The second one is the one that worked up until a few weeks ago.
I think I have a solution. I make a copy of the java.security file in java_home/jre/lib/security and commented out all the "disabledAlgorithms" lines in the file. I start up the selenium server with nohup java -Djava.security.properties==java.security.copy -jar selenium-server-standalone-3.12.0.jar and it seems to work now.
I'd be interested in hearing an explanation why this works. I assume it means the site they're trying to download jquery from uses encryption that jdk 1.8 disables because it's considered too weak.

Unable to open Pyspark Shell

I am running ./bin/pyspark at to open the pyspark shell but I get the following error :
`py4j.protocol.PY4JNetworkError: An error occurred while trying to connect to the Java Server`
Searched about it a lot. Couldn't find a solution.
How should I resolve this ?
Thanks,
This issue seems like your Java issue
Please use commands to check your java process in your machine
ps -ef|grep java
If doesn't works then please try to update your Java JDK to new.
Download:http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

Running Selenium IDE scripts in different browser using node.js

I have created multiple scripts using Selenium IDE. I can run this script only in Firefox using the extension. I want to run these scripts on different browsers like Chrome/IE using node.js. I know I can run it via java commands, but is there any way I can run it via nodejs?
Running IDE test Suites can be trigged from the command line using the selenium jar file. You can launch any browser from that command line (not just firefox).
Webdriver supports javascript/node:
http://www.seleniumhq.org/download/
http://seleniumhq.github.io/selenium/docs/api/javascript/index.html
But to run IDE tests in other browsers look at the documentation here:
https://wiki.mozilla.org/Running_IDE_scripts_with_Selenium_RC
java
-jar selenium-server.jar
-userExtensions user-extensions.js
-htmlSuite
"*chrome"
"<base URL>"
"<Selenium test suite file>"
"<results log file>"
-timeout nnnn
Specifically look at the first paramaeter after -htmlSuite:
1st parameter is the browser to run the script in. In RC 1.0.1 *chrome
= Firefox, *iehta = Internet Explorer. (options in RC 1.0.2 are expected to be *firefox and *iexplore, respectively)

unable to connect to chromedriver http://127.0.0.1:46050 (Selenium::WebDriver::Error::WebDriverError)

I get this error when I run my cucumber tests:
"*Unable to either launch or connect to Chrome. Please check that ChromeDriver is up-to-date. Using Chrome binary at: /opt/google/chrome/google-chrome (Selenium::WebDriver::Error::UnknownError)
*"
I downloaded the chromdriver, unzip it, copy it to the path (/opt/google/chrome/google-chrome ) and sudo chmod +x /opt/google/chrome/google-chrome.
which google-chrome : /usr/bin/google-chrome
which chromedriver : /usr/share/ruby-rvm/gems/ruby-1.9.2-p318/bin/chromedriver
capybara (1.1.2)
cucumber (0.9.4)
cucumber-rails (0.3.2)
selenium-webdriver (2.20.0)
I searched my error but none of the answers worked for me!
When I run my test I do not see chrome starts!
I really dont know what is wrong! I tried two different versions of chromedriver!
Jenkins should run/executes my tests in CI.The tests work when you run them but not when Jenkins runs them? I could run them by another user and then I installed jenkins and I get this error. I get the same error when I run my tests in terminal at terminal as well.Did you read https://wiki.jenkins-ci.org/display/JENKINS/My+software+builds+on+my+computer+but+not+on+Jenkins ? I couldnt find much about my problem here. xvfb: I installed the plugin in the jenkins but in the build environment if I click "run xvfb before the build and shut it down after", I get this error: "FATAL: null java.lang.NullPointerException"
Please provide more details. How does this question relate to Jenkins? Is Jenkins executing the tests? The tests work when you run them but not when Jenkins runs them? You do not go so far as to say that out loud, but I will assume it because it is what people usually need help with.
Did you read https://wiki.jenkins-ci.org/display/JENKINS/My+software+builds+on+my+computer+but+not+on+Jenkins ?
If you are executing Chrome inside a Jenkins job, do you have something like https://wiki.jenkins-ci.org/display/JENKINS/Xvfb+Plugin or https://wiki.jenkins-ci.org/display/JENKINS/Xvnc+Plugin installed?
chromedriver can be installed in two ways: downloading, decompressing the zip and putting the file in "/usr/bin" or adding the "chromedriver-helper" gem in your Gemfile.
Choose one or another way because doing both many time it causes problems. If you are installing chromedriver from google, be sure to uninstall the gem:
gem uninstall chromedriver-helper
and be sure chromedriver is in your path:
which chromedriver
Give this a try instead => https://github.com/flavorjones/chromedriver-helper
Finally I found the answer:
if you want to run GUI tests on Jenkins CI running on Windows do not
configure it as a windows service instead run it from the command
prompt or set it up as a scheduled task to run on windows logon using
the command “java -jar jenkins.war”
taken from this article

Unable to run Selenium with htmlSuite on Linux with no GUI

I've created a very basic test using Selenium IDE and converted it into an HTML suite. I've setup a VM running CentOS 5.5 to perform Selenium tests.
When I try to use this command,
java -jar selenium-server-standalone-2.14.0.jar -multiwindow -htmlSuite "*firefox" "http://www.example.com" "login-test-suite.html" "sel-results.html"
I receive the following output with an exception http://pastie.org/2956400
Someone told me that Selenium is not able to find firefox in /usr/lib/firefox and that was correct, so I created a symlink
ln -s /usr/lib64/firefox-3.6 /usr/lib/firefox
But still getting the same error. I don't know how to create a profile in firefox via cli as I'm using SSH. My initial thought was Selenium should create a profile itself and if it can't, then definitely something is wrong.
I'll proceed to develop Selenium test in Python only when I get the simple htmlSuite test running.
I think suite file of your scripts folder, needs to be given folder permission to access by selenium. Hope we can give it in unix. Try to give the permission and try to run one more time. Hope this will help you.
Regards,
Neel

Resources