Filed under Automated Website Testing & Monitoring, Selenium WebDriver, UI Testing.

We released a cloud-based web UI testing service that makes life easier to build functional tests and automate the repetitive manual testing of your site. You can catch bugs before your users do.

It’s similar to Selenium WebDriver, but for projects that are short infrastructure and/or coding expertise to confidently develop and manage automated test suites.

Create new automated website test

automated-website-testing-add-steps-new-ui-test

 

Choose the desired steps

automated-website-testing-choose-step

 

View Results and Metrics

automated-website-testing-results

With the Automated Website Testing service from LoadFocus.com you can automate manual regression tests in just minutes and run them from the cloud to check for regressions.

Get notified when your tests fail and automatically find technical errors, review detailed issue reports with screenshots and videos of the bug in action.

Filed under Selenium WebDriver, Test Automation.

In order to select a dropdown value with Selenium WebDriver you have to create a Select (in C# it’s called SelectElement) element and not use the default WebElements.

More details are available in the Video Course on How to Select a Dropdown in Selenium WebDriver.

 

 

import org.openqa.selenium.support.ui.Select;

Use our previous post to locate elements with Selenium WebDriver.

Select dropdown = new Select(driver.findElement(By.id("identifier")));

Let’s consider the following dropdown element for our example:

<select id="mySelect">
<option value="option1">France</option>
<option value="option2">Italy</option>
<option value="option3">Spain</option>
</select>

1. Identify the select HTML element:

WebElement mySelectElement = driver.findElement(By.id("mySelect"));
Select dropdown= new Select(mySelectElement);

or pass it directly to the Select element:

Select dropdown = new Select(driver.findElement(By.id("mySelect")));

2. To select an option you can do:

All select/deselect methods will throw NoSuchElementException if no matching option elements are found.
Select by Visible Text (select all options that display text matching the argument):

dropdown.selectByVisibleText("Italy");

or

Select by Index (select the option at the given index. This is done by examining the “index” attribute of an element, and not merely by counting):

dropdown.selectByIndex(2);

or

Select by Option Value (select all options that have a value matching the argument)

dropdown.selectByValue("option2");

3. To deselect an option you can do:

Also, the deselect method will throw UnsupportedOperationException ff the SELECT does not support multiple selections

Deselect all selected entries, valid only when the SELECT supports multiple selections:

dropdown.deselectAll();

Deselect by Visible Text:

dropdown.deselectByVisibleText("Italy");

Deselect by Index

dropdown.deselectByIndex(2);

Deselect by value:

dropdown.deselectByValue("option2");

4. In order to get the selected option:

WebElement mySelectElement = driver.findElement(By.id("mySelect"));
Select dropdown= new Select(mySelectElement);
dropdown.selectByVisibleText("Italy");

WebElement option = dropdown.getFirstSelectedOption();
System.out.println(option.getText()); //output "Italy"

5. In order to get the list of options from a dropdown element:

WebElement mySelectElement = driver.findElement(By.id("mySelect"));
Select dropdown= new Select(mySelectElement);
List options = dropdown.getOptions();
for (WebElement option : options) {
System.out.println(option.getText()); //output "option1", "option2", "option3"
}

You can also use LoadFocus.com to automate your UI Website tests and run the easily from the cloud every 30 minutes and get notified when they fail. Try it now.

 

Check also The Ultimate Selenium WebDriver Testing & Hands-on Guide – Online Course.

Filed under Apache JMeter, Load Testing, Performance Testing.

If you want to start Apache JMeter in non-GUI mode, use the following command line options:

  • -n – non-GUI mode – this specifies JMeter is to run in non-GUI mode
  • -t – JMX file – location of the test plan and the name of JMX file that contains the Test Plan
  • -l – log file name of JTL file to log sample results to

Example

jmeter -n -t my_test_plan.jmx -l log.jtl

 

Optional

  • -j – name of JMeter run log file
  • -r – Run the test in the servers specified by the JMeter property “remote_hosts”
  • -R – list of remote servers Run the test in the specified remote servers
  • -H – proxy server hostname or ip address
  • -P – proxy server port

Example

jmeter -n -t my_test_plan.jmx -l log.jtl -H my.proxy.server -P 8000

 

Tips for running JMeter in non-GUI mode:

  • here are details on how to add jmeter to the PATH variable of your environment
  • remove any listeners that are GUI mode specific (you can do this by opening your JMX file in GUI mode and remove the GUI specific listeners)
  • get summary results in the terminal by activating the summary option in the jmeter.properties file

 

Additional scripts that come with Apache JMeter installation can be found in the /bin folder where you’ve downloaded JMeter.

For Windows systems:

  • jmeter-n.cmd – drop a JMX file on this to run a non-GUI test
  • jmeter-n-r.cmd – drop a JMX file on this to run a non-GUI test remotely
  • mirror-server.cmd – runs the JMeter Mirror Server in non-GUI mode
  • shutdown.cmd – Run the Shutdown client to stop a non-GUI instance gracefully
  • stoptest.cmd – Run the Shutdown client to stop a non-GUI instance abruptly

 

For Unix/Linux systems:

  • mirror-server.sh – runs the JMeter Mirror Server in non-GUI mode
  • shutdown.sh – Run the Shutdown client to stop a non-GUI instance gracefully
  • stoptest.sh – Run the Shutdown client to stop a non-GUI instance abruptly

The commands will only be accepted if the scripts are run from the same host. Details on how to start JMeter on Mac system can be found here. Also, here is how to load test a website with Apache JMeter.

Filed under Chrome Extension, Page Load Time, Website Speed Testing.

LoadFocus today announced the release of its Google Chrome extension as the newest addition to their testing platform. LoadFocus’s Chrome extension allows users to run free website speed tests and see what’s slowing down their websites. They can monitor changes over time for each page and get advice on how to reduce page load times, see also our article on how to boost speed and improve overall SEO of your website.

It’s an easy to use tool which can optimise the performance of your website.

No need to install anything to run a page load test, the Website Speed Test Chrome extension will create everything for you automatically.

Get the Website Speed Testing Chrome extension today.

 

load-focus-website-speed-test-chrome-extension

Filed under Page Load Time, Website Speed Testing.

Slow websites, or slow pages are not good for SEO. In these days everything needs to be fast. If your website loads in more than 2 seconds you’ll probably lose customers, either by not getting ranked properly in search results, either by customers leaving your website due to its speed.

Use a free website speed testing tool like LoadFocus.com

Here are 5 website speed improvements tips that we consider important:

  1. Reduce the overall size of your assets:
    • Minify your JavaScript, CSS files
    • Resize images by using free resizing online tools without losing image quality
    •  Compress assets using Gzip to reduce load time by as much as 70%
  2. Reduce the size of your HTML code
    • Uglify your HTML code of your web pages
    • Release features with fewer lines of code (inspect 3rd party plugins like Editors to understand how much markup they add to your website)
  3. Upgrade your dependencies to the latest version
    • usually the latest versions has many performance improvements
    • even if you need to do some code changes in order to make your code work with the latest version, we still believe it worth giving a try
  4. Reduce the Number Of HTTP Requests
    1.  Group JS and CSS files together
    2. Batch HTTP requests
  5. Use browser caching and remove unused 3rd party libraries or plugins

LoadFocus.com is a Cloud Website Speed Testing Platform used for Testing Websites from Multiple World Locations and Inspecting Result with Full Analytics.

Filed under Load Testing, Page Load Time, Performance Testing, UI Testing.

During Speed testing of your website or web application using LoadFocus (https://loadfocus.com/website-speed-testing) on the Advice section you might get the tip that you need to enable compression like in the image below:

 

advice_enable_compression

 

Compressing responses often significantly reduces the size of transmitted data.
Because the compression happens at runtime this can add a big processing overhead which can affect the performance in a negative way.

Nginx if configured correctly compresses the responses before sending them to the clients and does not double compress the responses which have been already compressed.

In the next tutorial we will show how you can enable compression in case you are using Nginx to serve your files.

1. First locate the Nginx configuration file – nginx.conf
2. Once you located the file open the file and make sure that inside the configuration you can find the following flags:

<strong>gzip on</strong>;
<strong>gzip_disable</strong> "msie6";

<strong>gzip_vary</strong> on;
<strong>gzip_proxied</strong> any;
<strong>gzip_comp_level</strong> 5;
<strong>gzip_buffers</strong> 16 8k;
<strong>gzip_http_version</strong> 1.1;
<strong>gzip_min_length</strong> 1000;
<strong>gzip_types</strong> text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;

3. Explanation of the flags:

gzip on – enables compression

gzip_disable “msie6” – disable compression for IE6 as IE6 doesn’t always read and cache gzipped content properly and you end up with mangled code

gzip_vary on – enables / disables inserting the “Vary: Accept-Encoding” response header field if the directives gzip, gzip_static, or gunzip are active

gzip_proxied any – enables or disables gzipping of responses for proxied requests depending on the request and response; the fact that the request is proxied is determined by the presence of the “Via” request header field

gzip_comp_level 5 – sets a gzip compression level of a response; the values that are acceptable are between 1 and 9; 5 is a good compromise between size and cpu usage

gzip_buffers 16 8k – sets the number and size of buffers used to compress a response; by default, the buffer size is equal to either 4K or 8K, depending on a platform

gzip_http_version 1.1 – sets the minimum HTTP version of a request required to compress a response

gzip_min_length 1000 – specifies the minimum length of the response to compress; the default is 20 bytes; don’t compress anything that’s already small and unlikely to shrink

gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript
– by default gzip compression is applied only to responses with MIME type text/html; to enable it for other types of MIME we need to add them to this flag

4. The flags that are most important are the “gzip on” and “gzip_types”

5. The directives/flags that configure compression can be included in the http context or in a server or location configuration block

6. Restart Nginx by doing sudo service nginx restart

7. After you’ve finishes to enable compression on your server run the LoadFocus speed test again. This time the tip regarding to Enable compression should say that everything is fine.

LoadFocus.com is a Cloud Testing Platform used for Load and Performance Testing for Websites and APIs and Website Speed Testing with Analytics.

Filed under Apache JMeter, Test Automation.

In order to add an XPath Extractor to your JMeter script you need to begin by installing JMeter and create an HTTP Request. If you want to check how you can create a load test with Apache JMeter, please check our previous blog post.

Start by adding a XPath Extractor to your HTTP Request by following the below steps:

  • Select the HTTP Request on the left side, and Right-click it
  • Hover to Add -> Post Processors -> XPath Extractor
  • Click on XPath Extractor
adding-xpath-extractor

Update the XPath Extractor with the desired variable names and expected XPath. We are going to make an HTTP Request to http://example.com/ and based on the HTML response, we are going to extract the H1 tag from the website and use it in the next request.

Update the XPATH Extractor with the following details:

  • Reference Name: The name of the JMeter variable in which to store the result, var1
  • XPath Query: Element query in XPath language. Can return more than one match, //html//h1
  • Default Value: Default value returned when no match found. It is also returned if the node has no value and the fragment option is not selected, NOTFOUND
configure-xpath-extractor-jmeter

Copy the existing HTTP Request and add the variable in the Server Name:

  • www.example.com/${var1}
update-new-http-request-jmeter

In the View Results Tree, you can see that the variable var1 contains the content extracted from the XPATH //html//h1,  Example Domain, and the second request is going to be:

  • GET http://www.example.com/Example Domain/
jmeter-xpath-extracted-variable result-from-xpath-extractor

Have in mind that you can check the XPath also from inside the browser’s console, by typing the following:

 $x('//html//h1') 

which should output the element’s content that was saved inside the ${var1} variable from XPath Extractor.

chrome-browser-console-xpath

In order to run load tests with thousands of threads (users) and to run load tests from different world locations, you can use LoadFocus.com which offers a cloud load testing service, easy to use, which keeps all your tests and test runs in the history automatically.