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"

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!

Monday, November 24, 2014

Google Contributor: The web without ads


We all know that most of the Internet is funded on ads. And I personally think this is OK: creating content and managing all the details of a site takes time and sometimes cash. Like radio or TV shows, creators of content need to find funding through ads. This is even more important for a solid industry in Internet. Just imagine this: there would be no social networks, Google, or any other free service if there weren't ads. But some people don't like ads. I'm not one of them, but some find ads so annoying that they would pay to get rid of them. This is already true for some mobile apps, mostly for Android. But what if you were willing to pay to get rid of ads in a regular website? Apparently, this is the question that they asked in Google, and the answer is Google Contributor, an experiment to eliminate ads in the sites you visit.

The idea is simple: you choose a contribution to be paid monthly to the participating sites and you'll see no ads there. Instead, there will be a "Thank you" message where the ads were before.

Ok, I don't see any ads and the content creator just said "Thank you". Is that all? Am I paying just for that? In short, no. The most important benefit for the user is something that everybody is losing online: privacy. Without ads, no one needs to track your preferences or your activity just to show you the right commercial offers. I'm pretty sure there are some people that totally would pay for that. Also, there's some controversy about advertisement as a source of revenue. For example, take into account this SWOT analysis for Facebook. Advertising as a source of revenue is taken as a weakness.

For now, Contributor is only an experiment, and you need to join a wait list to get and invitation and try it. However, this could be a new market for funding the web that's unexplored yet.

For more information, visit the official page of Google Contributor.

Tuesday, November 18, 2014

How to create SQL Server Backups from my Smart Phone

This time we will present a very cool tool.

Simple, fast and easy to learn, versatile. The tool is Sql Bak. You can download the software from this site:
https://sqlbak.com/

The functionality can be summarized in this picture:



You can control and send jobs to backup or restore your SQL Server Database from any device like:
  • A Laptop
  • An iPhone
  • A Windows Phone
  • An Android Device
  • A Linux/UNIX machine
Requirements:

You need to install the SqlBak in the Server with SQL Server Installed. The SqlBak program will allow you to control your application from any device!



Once installed, you have to connect to the SqlBak site and connect with any of these accounts:
  • Twitter
  • Google
  • Facebook


Once logged, you can monitor the machines with the SqlBak installed.


I tried to access from my Samsung Galaxy without any problem. To create a new job. Press the Add new job button.


You can configure it to store the backups in the Clouds (Amazon S3, Dropbox, Google Drive, One drive, etc). In this example I tested Google Drive. Press the Run Now to run the Backup.


The log of the job will show you all the information related to the backup process and any problem that occurred. 


Here you can see some information in the Android device about the backup steps. You also have additional buttons to restore the backup or to download the file.

In this example, I tried it with Google Drive. Open Google Drive.


The file name is ReportServer201411161914.bak. As you can see, the file Repot...4.bak is now in Google Drive.

The SqlBak is a very powerful tool. It is a practical simple tool with a vision to the future. It is fully integrated with the new devices, the cloud and the social networks. It doesn't get any better than this!

Monday, November 17, 2014

How to hover the mouse on an element with Selenium

I use Selenium a lot for testing automation. It's a good tool, and it's completely free, and that's a plus in some projects with limited budget.

So, with that in mind, I'll show you how to hover the mouse on an element using Selenium and Java. I know it's something basic, but I think that I'll save you some time with these tricks. 

For Firefox:

Firefox has an excellent integration with Selenium. You can practically control every aspect of the browser directly from the code. The following code does the work. 



This could be an easy solution for everything, but unfortunately there's a bug for Safari. This is important because most of the times the automated test cases have to run against every important browser. The solution is to use JavaScript and call it from the Java code. In fact, you can use this technique to solve several problems, as long as you know how to use JavaScript. So, here's a workaround for the problem:



However, I noticed that this code does not work all the time. You'll have to find another JavaScript code to use, but that can take some time if you are not an expert on that language. Something that worked for me several times was to simply click on the element, or on the parent element. Usually, the simplest approach is the best.
Related Posts Plugin for WordPress, Blogger...