Java Selenium Element Locations

Sometimes you need to test are the elements in place regarding to each other. Finding inner-child elements, to check do they overlap partially or totally each other.
Are they visible and dimensions regarding the display and so forth. It depends on what do you need, there are wide varieties for testing, from which I will cover the most used cases.

Is this quick tutorial I will cover three basic tests :

  1. Is one element inside the other
  2. Do elements have overlap of borders
  3. Are two elements apart from each others (outside one another with no overlap of borders)

Let see some code, I shall use Java program language with Selenium 2 Webdriver and testNG for unit testing.

Setting up and running a simple AngularJS test

For running our tests we will use Protractor. Protractor is an end-to-end test framework for AngularJS applications.
We will use an existing Selenium grid to run our tests.

You will need NodeJS to install Protractor. You can download it from here: http://nodejs.org/.

Getting started with Webdriver python guide

If you are interested in automated testing web applications with Selenium or Webdriver but you prefer python over Java this getting started guide can help you with basic steps and setup.
The first step is to install python. You can download it from the official site (https://www.python.org/downloads/) or if you use Linux install it from the repositories.

Some useful information for Android and IOS testing

This basic information wrote down in this post is maybe unneeded and not necessary for most of users, but just remember, when you got the first Android/IOS device and need to setup something. So the information below is a basic testing startup guide.
First important thing is to check your Android or IOS device system version. The possibilities are different for Android or IOS systems and the application settings are depending of the OS versions. It is very important to the developers to have the information, which device was used for testing and which characteristics they have.

Local test run – Maven – NoSuchMethodError during driver creation

When you are getting the following exception during firefoxdriver initialization:

java.lang.NoSuchMethodError: org.openqa.selenium.Proxy.extractFrom(Lorg/openqa/selenium/Capabilities;)Lorg/openqa/selenium/Proxy;
        at org.openqa.selenium.firefox.FirefoxDriver.dropCapabilities(FirefoxDriver.java:313)
        at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:191)
        at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:186)
        at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:103)
        at test.java.com.ch.forsight.main.TestBase.getLocalDriver(TestBase.java:85)
        at test.java.com.ch.forsight.main.TestBase.createDrivers(TestBase.java:72)  

try to put this dependency into pom.xml:

        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-firefox-driver</artifactId>
            <version>2.43.1</version>
        </dependency>

If you still getting the same exception you should try to experiment with the order of the imports.
Sometimes small order changes can make the project work again, who knows which one depends on an old utility…

How to avoid App Store rejection

If you are iOS developer, I’m sure that you have heard several stories (or experienced yourself) of how difficult can be to get Apple’s approval for your app. Why does Apple reject apps or what are the big mistakes that most developers make?
I have searched for the reasons and in this post I will give you a little guide what must to be observed to avoid app rejection.
First of all you have to read the “App Store Review Guidelines”. Here you can find every important information what is needed during the development/app building. The list is very long, so it is hard to remember every point from this list, and this was the main reason why has Apple created a page and explain which rules are broken the most often.

Simple and advanced usage of LoadableComponent

We all know that the navigation between pages is sometimes painful, and we need to write a lot lines of code to get to the right place. Using LoadableComponent is a better way to manage your navigation, especially if you need to go through welcome pages, login pages etc. in every single case of test. As simple as possible you just need to extend your Page Object classes with “LoadableComponent< T >” like this:

public class WelcomePage extends LoadableComponent<WelcomePage>

You need to override two methods:

@Override
	protected void isLoaded() throws Error{}

@Override
	protected void load() {}

Page Object pattern and Page Factory

As a developer of automated tests for web pages one always has to deal with often changes on a site. This also means constant changes in test cases too. The developers’ main goal is to make as high quality code as possible with the least investment. This is also true for tests changes. Both goals can be reached with using the correct tool. The Page Object pattern hand in hand with Page Factory could provide a healthy code and maintainable tests.
Page Object is one of the most popular patterns which is used for developing automated web test. It maps the pages to objects which contains all the required data and functions that help the developer to test the site. The fields contain all the information what is needed and the methods do all the job to navigate in pages, fill the inputs or click the buttons.
Web driver provides more way to grab the element from the site. All of them are based on search in DOM tree of the webpage based on locators. The locators are strings that describe the position of the required web element. It can be located based on its name, id or src attributes or any custom conditions like CSS or Xpath selector. Let’s take a look for an example. The test case is really simple. Log in to Gmail and check the title of the next site. If the page title contains word Inbox, it’s done. Otherwise something went wrong.

How to read text from PDF file using Java and Selenium Webdriver

Sometimes we need to verify a PDF content but Selenium WebDriver doesn’t have any direct methods to do that.
If we want to extract the PDF content then we can use for example Apache PDFBox.
Simply download the .jar files and add them to your Eclipse Class path.
Here is a sample script which will extract text from a sample PDF file:

How to test different resolutions – Part two – Firefox resolutions testing

Continuing from the last months Chrome resolution testing, we are going to test tools from Firefox. None of the tools listed simulate mobile devices. So for mobile testing the mobile web address will have to be manually used, as the browser won’t be recognized as a mobile device. Unfortunately this will not work with every site, and even on sites that work, some pages may not be displayed correctly.

FireSizer

This add-on uses the Add-on bar at the bottom of the Firefox window. Unfortunately this feature was removed in Firefox version 29+, so an additional add-on is required to make it work (https://addons.mozilla.org/en-US/firefox/addon/the-addon-bar/). After installing the add-on bar it will appear at the bottom of the screen, from where the FireSizer can be used. The FireSizer will be located in the bottom right of the screen. It will show only as the current window resolution, right clicking the displayed resolution shows additional options. You can select from existing presets, or add you own. You can also save the current window size. This add-on doesn’t resize only the HTML area (viewport), but takes into account window borders, top/bottom status bars, menus, navigation buttons, etc. This isn’t so good for mobile testing, but makes more sense for desktop testing.