Accidentally quit while using JMeter - testing

I use jmeter to test api. After it runs sometime, i press stop button then it quit unexpectedly. Who can help me?
os: macOs
jmeter version: 5.3

First of all don't use GUI for test execution, JMeter GUI is only for tests development and debugging, when it comes to running tests you should launch JMeter in command-line non-GUI mode like:
jmeter -n -t /path/to/test.jmx -l /path/to/result.jtl
if you need to terminate the test before it ends naturally - press Ctrl+C or use stoptest.sh or shutdown.sh script
Normally if something goes wrong there should be some information in jmeter.log file
If there is nothing in jmeter.log file check if there are any .hprof files in the folder where you launch JMeter from
Make sure to follow JMeter Best Practices, for example the very first one suggests using the latest version of JMeter which is JMeter 5.4.1 as of now

Related

Unable to run tests against Safari 11 remotely (ssh, CI)

I'm having troubles running Ruby/RSpec tests against Safari 11 when I'm trying to run tests via ssh manually or via Jenkins (where machine where Safari exists is remote slave).
When executing tests, I'm getting following error:
Selenium::WebDriver::Error::WebDriverError:
unable to connect to safaridriver 127.0.0.1:7050
What is weird is that I'm able to run tests when I'm logged to the Mac machine directly. This leads me to the conclusion that there could be some permission which, by default, disables execution from ssh session but not sure why?
Also, to my knowledge, Safari Driver is part of Safari 10+ and as such is not installed anymore as extension
Update: I've found out that safaridriver executable that should be spawned by tests cannot be spawned from some reason when I login via ssh.
Example:
/usr/bin/safaridriver -p 7050
It will just terminate with non-zero exit code while running same command directly on machine will run safaridriver in foreground. Since I expect Jenkins to be running test job on this machine, my idea to overcome this issue would be to launch safaridriver on this machine (by cron or launchctl) and then use this instance to connect to it with my tests. However, so far, I was not able to make my tests (Selenium/Capybara) re-use existing safaridriver instead of always trying to spawn new one on different port. Any idea on this would also be greatly appreciated.
This is my environment:
OS: MacOS Sierra 10.12.6
Browser: Safari 11.0.2
Thanks in advance
There is a possible workaround to do this. First you need to create a Automator Workflow or Apple Script that launches the SafariDriver
Then save this as a application. Let assume we name it SafariDriver7050.
Then from the SSH session you need to execute
open /Applications/SafariDriver7050.app
This will actually launch SafariDriver in the logged in session and it should work for you.
The caveat being shutting it down, you will need to first kill the SafariDriver7050 app and then you need to kill the safaridriver process. The order matters, else it will create a error dialog on UI
Edit-1:
As you suggested, it would be even easier to do this, when you wrap your test as a app and then it will be automatically be able to launch SafariDriver without any issues. The key to issue is using open command in a SSH session
Edit-2
Why does SafariDriver not work in SSH? Well if you look at the linux counterpart
In case of linux we can use the DISPLAY environment variable to launch an app in an existing display or we can use something like XVFB to launch the browser in a virtual display. That is the concept that most frameworks use in case of linux machines.
But Mac doesn't have such kind of feature, which is why this workaround is needed. Now why it doesn't have that, I am not sure. There may be some other workaround that I may not be aware of, so anyone who has valuable info, can help improve this part of the answer
For my case:
On OSX host side was created Automator app as described above and modified a little bit:
security unlock-keychain -p your_host_password /Users/$USER/Library/Keychains/login.keychain-db
safaridriver --enable
safaridriver -p 7050
On CCI/Jenkins side:
open /Applications/StartSafariDriver7050.app/
run pytest cmd
osascript -e 'quit app "StartSafariDriver7050"'
pkill safaridriver
In Python:
def safaridriver():
return webdriver.Safari(desired_capabilities=Caps.SAFARI, port=7050)

Run : Apache:j-meter in linuxServer as GUI or any other approach

I have apache j meter installed in my local machine which has .bat file .sh executable files in it, to run in gui mode in windows, now i want to execute it on server which is in linux environment, how can i run as gui mode in server?
Actually you should not be running JMeter in GUI mode, you should use GUI mode for tests development and/or debugging. When it comes to executing the load test itself make sure you run JMeter in command-line non-GUI mode like:
jmeter -n -t test.jmx -l result.jtl
In regards to how you can proceed there are several options:
Develop the test under Windows, transfer the .jmx file to Linux box using pscp, WinSCP, FileZilla, etc.
Develop the test under Windows and run JMeter in distributed mode, i.e. have JMeter Master on Windows and JMeter Slave on Linux, see JMeter Distributed Testing Step-by-step guide for more details
You can install X Window Server implementation on Windows box (i.e. Xming or Cygwin/X and use X forwarding so you will run JMeter on linux and see its GUI on Windows.

Testing with Web Driver and Selenium through Codeception

I know I'll get crap for this but it's worth it if someone can help.
I can't find a guide, tutorial, or instructions anywhere for installing web driver on a windows machine. I've got a site running on a homestead vagrant box and need a way of running acceptance tests locally. I had tests setup using PhpBrowser but those don't simulate JavaScript. If anyone knows of a guide to do this or a better way to run acceptance tests it would help immensely. I've got Ajax calls so PhpBrowser and resources like it won't work.
Thanks!
Just download the selenium webserver the jar file and run it in a command shell with java -jar selenium-server-standalone-2.43.1.jar. The selenium server will now listen on the default port 4444. If you run your test it should work as expected. Keep in mind that selenium webserver opens firefox and uses it for testing. It's pretty useful for watching the test cases.
If you want a headless test (no visible browser) you need to download phantomjs. Unpack it and run the phantomjs.exe with --webdriver=4444 as an argument (so phantomjs.exe --webdriver=4444).
Download and Run the selenium-server-standalone-2.43.1.jar as stated in the comment. I had to add firefox_binary: C:\Program Files (x86)\Mozilla Firefox\firefox.exe under capabilities: in my acceptance.suite.yml file. I also added it to the path variable but I'm not sure if that made a difference. Had to add the firefox_binary to make it work.

selenium script has to run continuously in server with out using eclipse

is it possible to run selenium script in server without using eclipse or command prompt.for every fixed time intervals my selenium script has to run automatically in backend with out any browser opening
This can be split into two questions;
Can I schedule a Selenium test?
Yes, there are many options including using a CI tool such as Jenkins, Hudson, Team City,etc. Alternatively you could write a shell script to run the command line, and schedule this to run every x hours.
Can I run Selenium without opening a browser?
Yes. As mentioned before you could go headless, but depending on complexity of your application and test, you may find headless is not suitable. However, you can use RemoteWebdriver to launch a browser on a different machine but the test would still be run on your back end, it would just be the browse launched remotely. See https://code.google.com/p/selenium/wiki/Grid2 and https://code.google.com/p/selenium/wiki/RemoteWebDriverServer

Jenkins running selenium tests without opening browser

I browsed a lot on this topic. There are different variations of this question or no answer to fix my issue. Any help is appreciated.
I have installed firefox on my VM as root in /usr/bin/firefox.
I downloaded the maven project to run selenium tests, and run it
manually on my VM using mvn clean install command. This opens the
browser and also successfully runs the test.
Now I run Jenkins as myself ( JAVA_HOME is /usr/java/latest and started the service as
nohup java -jar jenkins.war --httpPort=-1 --httpsPort=8082; version
is 1.522).
Create a new freestyle s/w project; Configure the job
to download the maven project and invoke maven target 'clean
install';
When I run the job, I can see the steps in the console
output but the browser is not opening. It also locks up my AD account.
Why is this happening? What is the fix?
nohup runs Jenkins in the background (http://en.wikipedia.org/wiki/Nohup), in which case according to this post Jenkins will start the browser in the background as well.
Try starting jenkins without nohup so that it runs in the foreground (java -jar jenkins.war --httpPort=-1 --httpsPort=8082).
Or you can start Jenkins as a daemon (this Jenkins Wiki page contains an example of init script). When Jenkins is started as daemon, the browser started by its job is visible.