How to open a link in a new tab or window and switch to it with Selenium WebDriver

The following codes are works both in Firefox and Chrome browsers.

Open a link in a new window and switch to it:

How to test different resolutions – Part one – Chrome resolutions testing

Often testing can mean checking a sites pages in different resolutions. When a site gets a new layout, it is important to make sure it displays correctly on different browsers and resolutions. While adjusting the resolution manually is an option, it takes too long.
In this post we will talk about resolution testing on Chrome. We were testing some possibilities, and will share our experience with you. We tried a few extensions to see which of them can speed up or make our work easier for us.
Their drawback of these extensions is that web-sites won’t recognize small resolutions as handheld devices, because the browser windows are only re-sized. This unfortunately means that you can’t see what a site would look like, on Chrome, on a mobile device. However they are still useful for desktop testing, and if you don’t want to pay for the service, the following extensions are a must try.

Quick and dirty test parametrization – JUnit params

Today I want to talk about a little tool which makes the life of us testers a bit easier.
It is called Junit params.

The  following situation happened with me not so long ago:
The dev team lead asked us a favor to make a set of quick and dirty smoke tests which tests different sites and check if some elements are present.
There are of course different approaches, if we are lucky the function is already automated and documented somewhere, and we just have to make it accessible and runnable by others too.

How to count number of images available on a web page then download them using selenium webdriver?

The simplest way to gather the images from a website is to find them by tagName.
First we create a WebElement list with the elements which tagName is ”img”.
Then we check the elements to be sure that they are displayed.
If they are displayed then we get their names and sources.
To download them we use the “org.apache.commons.io.FileUtils.copyURLToFile” function.
It is very simple, we just need to add the URL and the file path to it.
In the end we write out the number of displayed elements.

Here is to full code:

Screen recording – screencast – part III

In my previous posts I have described my favorite solutions for screen recording(Screen recording – screencast – part I and Screen recording – screencast – part II). Applications are free, just have to create an account. They have some limitations, but for the basic screen recording and image editing, they will work perfectly.
This time I will describe some paid/professional and easy-to-use programs. When we are talking about professional image/video editing, we have to say that there are many applications for this purpose. Most of them are very expensive, but they give lot of tools for image/video editing.

Graphwalker – Guards and actions

In our previous articles we have already discussed about the finite state machines and about how we can take advantage from this utility of the Graphwalker API. It is based on nodes and vertices which are connected to each other to become a graph and forming a test case to make your job easier and clear.
Moreover Graphwalker provides additional possibilities to make the job be in a batter quality. The edges could be extended by expressions and these can modify the further way of test run. Excluding the label the edge can contain two other elements. The first one called guard and another one is action. These have a unique order like this: Label [Guard] / Action1; Action2;

Graphwalker Path generators and Stop conditions

In this post we will try to give some ideas how to use the Graphwalker Path generators combined with Stop conditions. We recommend you to read our latest post about the Graphwalker API , however here is the snippet of code from last post:

ModelHandler modelHandler = new ModelHandler();
File loginModelFile = new File("'your location for the graphml file'/LoginModel.graphml");
Test testModel = new Test(loginModelFile, true, new A_StarPathGenerator(new EdgeCoverage(1.0)), false);
modelHandler.add("Test", testModel);
modelHandler.execute("Test");
Assert.assertTrue(modelHandler.isAllModelsDone());
String actualResult = modelHandler.getStatistics();
System.out.println(actualResult);
testModel.getDriver().quit();

Changing user agent with webdriver

Not so long ago we had to implement a test case where the user goes to a page with an “unknown” browser.
I had to spend some time to find out the proper configuration and made a small post about it to avoid doing it again.

All you have to do is to change the default user-agent. You can do this by instantiating a new ChromeOptions object and add you user agent as an argument.

Very Short example:

public class SampleTestClass  {

@Test
public void sampleTest(){

ChromeOptions chrome = new ChromeOptions();
chrome.addArguments("user-agent=YOUR_USER_AGENT");

WebDriver driver = new ChromeDriver(chrome);

// you can check your user-agent on this site
driver.get("https://www.whatismybrowser.com/");

driver.quit();
}

}

Advanced Google Drive features for max productivity

Google Drive is a file storage and synchronization service provided by Google. Most people think that Google Drive is just a rebranding of Google Docs. However, it is much more than that. Besides the Google Docs office suite, it offers cloud storage, file sharing and collaborative editing.

With the integration of web based apps into Google Drive many features that it lacked are now only one click away. Need to send a fax? Use Hellofax. Need to eSign a document? DocuSign comes to the rescue. Whatever your needs, there is probably an app for it.

Some thoughts on Sauce

We’re started using this service a long time ago, and I can say they improved a lot in the recent years.
It became a reliable cloud system for running automated tests and for manual testing with a wast amount of virtual machine/browser combinations and what I love about them that almost everything is documented.

sc1