How to view documents using Visual Studio

View documents in Visual Studio with an amazing tool

Xpath Axes

A very useful trick for automation

Review: Spire.DataExport for .NET

A great tool for exporting data in .NET

How to install Arch Linux, step by step, for VMware Workstation (Part I)

First part of a installation tutorial for this beloved OS

How to setup a local repository in Ubuntu

The steps to have a local repo in Ubuntu

Friday, December 19, 2014

Send secret messages with Qlink.it

Some time ago I wrote a short anonymity guide in Internet. I didn't know Qlink.it back then, but I would have included in that article. It's such a simple idea that when you hear about it, you think "why I didn't thought about it before??".

The service, as I said, is very simple. You can use it following these steps:

1. Go to Qlink.it.
Qlink main page

2. Write a secret message (you can also attach a file and include your IP, although I don't think that's a good idea).
3. Click 'qlink it!'
4. A link will be generated, and now you can send it through email or other mediums.
Qlink generated
5. The link can be accessed only once. It expires after that (for example, try this link. It's broken)
Expired message
As you can see, it can't get much simpler than this. This is one of those moments when you realize that you had this necessity, but you couldn't formulate it coherently. Well, these guys could.

I think this is great news, but take into account that this service is still in the Beta phase. However, I like it because it does not rely on passwords. It's not like sending a .zip file with a password, since someone could get a copy of it and ultimately unencryp it. Here, you know that nobody saw the link until you click it. Apart of that, there are no traces of where the link was created.

Maybe the only part I don't like is the name. It's clear that the creators of the app wanted to give it a name that follows all the rules of marketing, but the '.it' does not deliver a clear message. When I think about it, it's just 'Qlink', without the '.it'. But that's just a detail.

I recommend to check the details of the service here. I think this has a future. Next time I'll review the Android app that they already have in Google Play.

Thursday, December 18, 2014

Java + Selenium + Maven + TestNG + ReportNG integration

Java and Selenium work great together. They are a popular combo when it comes to Automation Testing. In this article I'll show you how to integrate Java, Selenium and also Maven, TestNG and ReportNG. This set of tools provide enough flexibility to create a tailored automation framework for almost any automation project. It is not so difficult, but it can take some time. This is what I'll use in this example:
  • Ubuntu 14.04 (get it here)
  • Eclipse Luna (get it here)
Requisites:
  • Maven installed
  • Eclipse integrated with Maven and TestNG (I recommend to read this article before if you need further details)
In this case, I'll work with the default driver provided by Selenium. That means that the tests will only run with Firefox.

Steps:

Create a basic Maven project

1. Open Eclipse
2. Click File>New>Project...
New Project menu
3. Select Maven>Maven Project, then click Next
Maven project
4. Click Next twice
5. Enter the Group ID and the Artifact ID (if you don't know what are they about, please check this). You can use the following configuration. Then click Finish.
Maven Project configuration

Add required dependencies

The heart of a Maven project is the pom.xml file. Here you can specify important aspects of the project, and also you can add dependencies. This is like adding .jar libraries, but Maven handles everything and in most cases, it is possible to find the dependency in the Maven online repository.

1. In the Package explorer, double click the file pom.xml
POM location
2. In the main panel, click "pom.xml":
POM edition
3. Now, add the following code to the pom.xml file:

<dependency>
  <groupId>org.testng</groupId>
  <artifactId>testng</artifactId>
  <version>6.1.1</version>
  <scope>test</scope>
</dependency>

The file should look like this:
TestNG dependency
4. Add the following code to the pom.xml file:

<dependency>
  <groupId>org.uncommons</groupId>
  <artifactId>reportng</artifactId>
  <version>1.1.4</version>
</dependency>

The file should look like this:
ReportNG dependency
5. Finally, add the following code to the pom.xml file:

<dependency>
  <groupId>org.seleniumhq.selenium</groupId>
  <artifactId>selenium-java</artifactId>
  <version>2.44.0</version>
</dependency> 

6. Now you need to add the Surefire plugin to use ReportNG to get better reports and also to specify an .xml file where the test cases will be listed. So, add the following lines to the pom.xml file:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.5</version>
            <configuration>
                <properties>
                    <property>
                        <name>usedefaultlisteners</name>
                        <value>false</value>
                    </property>
                </properties>
                <suiteXmlFiles>                    <suiteXmlFile>src/test/java/net/testools/resources/testSuite.xml</suiteXmlFile>
                </suiteXmlFiles>
            </configuration>
        </plugin>
    </plugins>
</build>

Place that just outside <project></project>.

Run a basic test case

1. Create a simple test case. I created one that just opens the browser and closes it. This is the code:

package net.testools.test_project;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.Assert;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

public class TestoolsTest {
public TestoolsTest() {
}
WebDriver driver = new FirefoxDriver();

@BeforeMethod
public void setUp() {
driver.get("http://www.testools.net");
}

@Test
public void simpleTest() {
Assert.assertTrue(driver.findElement(By.id("Header1_headerimg")).isDisplayed());
}

@AfterMethod
public void tearDown() {
driver.close();
}
}

And this is the folder structure I'm using:
Folder structure
2. Create the .xml file to run the test cases. If you see closely at the picture above, there's a file named testSuite.xml. Create it at the same folder level with the following code:

<?xml version="1.0" encoding="UTF-8"?>
<suite name="TestSuite">
  <listeners>
    <listener class-name="org.uncommons.reportng.HTMLReporter" />
    <listener class-name="org.uncommons.reportng.JUnitXMLReporter" />
  </listeners>
  <test name="Test1">
    <classes>
      <class name="net.testools.test_project.TestoolsTest" />
    </classes>
  </test>
</suite>

And, finally, that's all. Now, to try your configuration, open a terminal and go to the root of your project (where the pom.xml file is). Now, run this command: mvn clean install. If everything went well, you should see something like this in the terminal after the test ran:
Tests run
And here's a screenshot of the report enhanced with ReportNG. This is generated by default at: /test-project/target/surefire-reports:
ReportNG report

I know that there's plenty of space for mistakes with this, so you probably won't get it working the first time, but it's actually easy once you understand how Maven and the tools work. Good luck!

Saturday, December 13, 2014

Integrating Maven and TestNG with Eclipse

OK, this a pretty simple article, but I decided to publish this first as a requisite to integrate Java + Selenium + Maven + testNG + ReportNG. I don't want that to be a extremely long text, so this short article will help to reduce it. Just in case, I'm using a Ubuntu 14.04 machine, but the instructions are valid for Windows as well, as long as they are not commands in the terminal. Let's get started!

Requisites:

  • Eclipse (the latest version, download it here. I used Eclipse Luna, which includes Maven support)
  • Maven installed (instructions below)

Steps:

Installing Maven

1. Open a terminal
2. Enter the following classic command:

sudo apt-get install maven

3. Once the required files are downloaded and installed, type this in the console: mvn
If you see something like this:
Congratulations! Now you have Maven installed on your computer. However, you'll see an error message like this:

That means that you don't have your JAVA_HOME environment variable set. To do that in Ubuntu 14.04, open a terminal and enter the following command:

sudo gedit ~/.bashrc

Note: Gedit is a text editor, very useful. If you don't have it yet, install it with: sudo apt-get install gedit

A text editor will be opened. Go to the bottom of the text and enter the following lines:

export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64/jre
export PATH=$PATH:/usr/lib/jvm/java-7-openjdk-amd64/jre

Of course, you need to set the path where you have Java installed. Now, save the file and type this in the console:

source ~/.bashrc

Try the command mvn again. It should be working now.

Installing Eclipse and testNG

1. Once you download the compressed Eclipse file, just extract it somewhere. Once you do that, double click the "eclipse" icon:
Eclipse will open.
2. Go to Help > Eclipse Marketplace...
3. In the 'Find' field enter testng and click 'Go'.
4. Click 'Install' in 'TestNG for Eclipse'
5. Click 'Confirm'
6. Select 'I accept the terms of the licence agreement' and click 'Finish'
7. Click 'OK' in the Security Warning dialog.

8. Restart Eclipse and that's it, you now have testNG integrated with Eclipse.

With that, you'll be ready for the next article.

Monday, December 8, 2014

Tip: How to solve the problem "VMware Workstation cannot create ~/.vmware directory"

vmWare Ubuntu
When I installed VMware Workstation 10 in my Ubuntu 14.04 (you can check some old instructions here, they still work) I had a problem. Whenever I started VMware, I noticed that the machines I had and all the preferences were gone, and a message warned me: VMware Workstation cannot create ~/.vmware directory. That's the directory where VMware stores all data related to preferences. For example, if you hide the toolbar, next time you'll see that it is displayed again, since VMware couldn't save those settings.

The solution for this is very simple. Just run this in a terminal:

sudo chown -R username:username ~/.vmware

For example:

sudo chown -R john:john ~/.vmware

This problem is caused because the ~/.vmware folder is owned by the root user. If you just follow the default instructions to install VMware you'll stumble upon this problem. The command just changes the ownership to your user, and that's it. I hope this little tip is useful!