Performance Testing User Interface with YSlow and Jenkins

I have a web application on which I would like to run Yslow. Tests should be integrated with Jenkins. The application has a login page. If I provide the URL of the application, if the valid user does not log in on the login page. So, how can I test performance using YSLow and Jenkins? Is it possible to automate the registration part?

+7
jenkins phantomjs yslow
source share
2 answers

Since YSlow can generate a performance report from the HAR input file, I would use a proxy server to record performance data when navigating the site using Selenium. This way you can independently measure performance on a real browser (Chrome, Firefox, Safari ...) or on a headless one such as PhantomJS.

To continue, first download the browser proxy and unzip it:

https://github.com/lightbody/browsermob-proxy/releases

Then write code to start the proxy server and run the script with the Selenium client. This example was written in Python, but you can write it in the same way with some Java, Ruby, Javascript or PHP.

from browsermobproxy import Server from selenium import webdriver import json, sys # setup the proxy server server = Server(r"C:\Download\browsermob-proxy-2.1.0-beta-5\bin\browsermob-proxy") server.start() proxy = server.create_proxy() try: # setup the browser profile = webdriver.FirefoxProfile() profile.set_proxy(proxy.selenium_proxy()) driver = webdriver.Firefox(firefox_profile=profile) # start collecting the data proxy.new_har("google") # login to a twitter account driver.get("https://twitter.com/login?lang=en") driver.find_element_by_css_selector(".js-username-field").send_keys("my name") driver.find_element_by_css_selector(".js-password-field").send_keys("my password") driver.find_element_by_css_selector("button.submit").click() # save the collected data to a file with open(sys.argv[1], 'w') as file: file.write(json.dumps(proxy.har, indent=2)) finally: driver.quit() server.stop() 

Finally, to run the script and generate a performance report using the command line:

 python perf-login.py perf-login.har yslow perf-login.har 
+4
source share

yes you can, but you’ll skip this automatic part anyway. You need something more than YSlow and Jenkins. It depended a lot on the architecture of the application network — if you run tests locally or remotely.

Robotframework + Selenium Server

With Robotframework, selenium2library can use Selenium server bindings to manage DOM browsers. In other words, you can create very simple automated tests and actions for logging in. Subsequently, the SSHLibrary or Terminal library can run YSlow commands, and you just need to provide the output files to a Jenkins readable location. This is a fairly complex solution, suitable for an advanced network architecture with many dependencies.

PhantomJS + CasperJs

If you need to run performance tests locally, you can take advantage of the browser without the PhantomJS browser. Combined with CasperJS, you can manipulate using the DOM to create automated login processes. PhantomJS is also compatible with YSlow, so once again you need to locate the output files for Jenkins.

For both solutions (or any other) you will need additional jenkins plugins to read the output files generated by YSlow.

+3
source share

All Articles