Showing posts with label Eclipse. Show all posts
Showing posts with label Eclipse. Show all posts

Tuesday, August 4, 2015

Python unittest. A bit more practice after theory. Basics and a bit more than basics.

The main purpose of this article is just to share my experience on using unittest module in Python. 

I chose version 2.7.10 for this case, but I think we may expect the same behavior with Python 3.X
Documentation about unittest module available via following link: https://docs.python.org/2/library/unittest.html, the site interface with documentation is easy and you can simply switch to the same topic, but another version of Python.
In this article I will demonstrate my source code snippets with links for GitHub (where you can find full version)
Initially I've prepared a special class with functionality that we will be using to demonstrate unittest usage.
The class can be used for the following:
  1. To generate a dictionary with random keys and values
  2. To store generated dictionary like a JSON object into a file (by using standard library in Python)
  3. To upload from the file the JSON object back to the dictionary
Latest version of the class could be found here (GitHub)
Now let's start with preparation of simple unit tests lists. You can find basic information about the unit test on Wikipedia. It provides enough knowledge to start working with that.

Let's switch to practice. 

Thursday, May 21, 2015

Technical task. Test automation for web-page.

Recently I was asked about preparing of test-automation for the page http://hh.ru/price.
Major agreement: Java and Selenium.
So I would like to share several steps and ideas how I tried to solved required challenge.
I've created the Maven project to avoid problems with dependency for Selenium:


Adding Selenium dependency

Choose version of Selenium

To solve this task I preferred to show several technics, because adding tests with good architecture should not be difficult thing.

Friday, April 24, 2015

Serenity + JUnit for automation

Several days ago I was asked to complete one technical challenge task.
Task description is to prepare automation for set of settings for e-mail processing.
In details you should automate processing of the following:


One criteria is to use Serenity and JUnit
In this article I would not like to go deeper into tests. I would like to share several steps how I configure my project in Eclipse

Monday, February 3, 2014

How I automate testing of one web-application

I would like to share my experience with tests’ integration and preparation for a web-application, using Eclipse, Selenium and testNG.

A few words about the web-application that I need to automate. This is a 7-screen application. The screens have all kind of controls such as our custom control, edit boxes, labels, buttons, radio buttons, combo boxes, menu control and so on. I cannot provide any hard copies of screens or anything else about this tool because this information is confidential.

No doubt, you may find a lot of information on how to do it on the Internet. But I personally have failed to find a link that would contain all necessary information on one page, that’s why I would like to share my own experience.

Let me introduce the task. I have a rich web application developed with GWT. I have a specification, a list of test cases that I've prepared during the previous month and a requirement for additional automatization. I suggest that we have the same environment as our developers have. So I used Eclipse as IDE for development. After that I was trying out different test automatization. Based on my previous experience, the list was as follows:
  1.  UIAutomation - Microsoft Visual Studio is required for development (no such IDE here). When I've looked through on the components tree of the application, I found out a huge hierarchy without any chance to identify required web-control.
  2. AutoIT - Did not 'see' any controls on the web-application
  3. WatIN - Microsoft Visual Studio is required for development (no such IDE here).

The first search sends me to Selenium project, so I read additional forums and articles, and decided to use it. 
The next step is test framework selection. Selenium gives an opportunity to generate the source code for Java and JUnit or testNG. According to this article, I decided to use testNG 
First of all I tried to use Selenium for automatization, just to check if all significant cases can be covered by the Selenium IDE.


It took me a few days to make sure that it is possible to automate the main functionality of the web-application. 
However, I faced some troubles during my investigation.
1.   The name of test case will be converted to class name in Java during the test launch, so in the first place I suggest to avoid test names which contain special symbols like: 'Wheel: Speed 100 km/h', 'Wheel: Speed 200 km/h'
2.   Our application has a complex logic with many events, so I frequently needed to call operations with the “pause” command after it. First, I decided to use '*AndWait' versions of the required commands but it was not applicable for me according to this article (in details: Many Actions can be called with the “AndWait” suffix, e.g. “clickAndWait”. This suffix tells Selenium that the action will cause the browser to make a call to the server, and that Selenium should wait for a new page to load.)

3.   I had a lot of troubles with our custom control, because the 'sendKeys' function call was required to enter the text correctly. Function 'type' does not allow sanding the entered value correctly.
I probably should have been aware about these troubles but I was a beginner in Selenium.
Moreover, you can find information about how to create your first Selenium script by following this link
After that I decided to convert the existing Selenium tests from 'html' to 'java' and configure environment to work with these tests like from IDE.
If you want to learn how to configure a project in Eclipse you may follow this link (or this one and this one ). I used it for my project, but I had to make some changes at the last stage.
I decided to leave the functions generated by Selenium IDE as they are, I added them as separate functions, not as part of the main function. So, my main function looks like:

@Test
public void main() {
    try {
        ConvertedTestFunction();
    }
    catch(Exception e){
        System.out.print("Exception occurs: " + e.getMessage());
        Assert.fail(e.getMessage());
    }

}

'Assert' prefix was  added after I had converted my project to TestNG. (step #8 from link above)
After that I launched Selenium server using this command java -jar selenium-server-standalone-2.39.0.jar like has it was described in section 'Running Standalone Selenium Server for use with RemoteDrivers' of this page.  Afterwards I chose the menu item 'Run As -> TestNG Suite' in menu for testing.xml file (more information can be found in section 'Launching your tests in Eclipse' on this page)

Now all works fine!
Only one case in under investigation. function 'sendKeys' does not exist in realization on java.
Workaround in my case was in using both functions 'type("field", "text to type")' and 'typeKeys("field", "\\13")
I created the required ticket about this issue on official site.

As you can see using of Selenium RC is depricated. All test code should be updated from selenium to webdriver.