Skip to main content

Posts

Showing posts from May, 2016

creating first go program

for creating go program open your editor and paste this code, and save it as filename.go for example helloworld.go

package main import "fmt" func main() { fmt.Println("Hello, 世界") }
I will explain these codes in details for now , we will look how to run these code.

to run type go run helloworld.go  in terminal , we get


you can try golang online as well , golang

creating python django project

If you installed and configured python django you can create django project .

for that create a folder any where in you system and open you terminal navigate to that folder and type the django command django-admin startproject projectname  for example django-admin startproject firstdjangoproject


This command will create a folder firstdjangoproject        , navigate inside to the project folder . You can see file structure of django project

I will explain each of this files in detail for now lets run the application

for running the application need to type this command in your terminal

python manage.py runserver

Ignore the migration exception , we can see the application running at localhost port 8000, 8000 is the default port . Now open your web browser and type address http://127.0.0.1:8000 and you can see

if you see this your django application is up and running and you are good to go. press ctrl+c keys to stop the server.

python django installation on ubuntu

If you wish to install Django using the Ubuntu repositories, the process is very straight forward.
First, update your local package index with apt, and then install the python-django package: sudo apt-get update sudo apt-get install python-django You can test that the installation was successful by typing: django-admin --version If you wish to install the latest version of Django globally, a better option is to use pip, the Python package manager. First, we need to install the pip package manager. Refresh your apt package index: sudo apt-get update Now you can install pip. If you plan on using Python version 2, install using the following commands: sudo apt-get install python-pip Now that you have pip, we can easily install Django. If you are using Python 2, you can type: sudo pip install django
You can verify that the installation was successful by typing: django-admin --version 

xpath

It is very easy if you understood the funta behind XPATH . xpath is XML path , XPath is used to navigate through elements and attributes in an XML document . As i said earlier both HTML and XML follows DOM structure , so we can use xpath to navigate elements and attributes in an HTML.
<html> <body> <div class="1"> <div class="2"></div> <div class="1"></div> <div class="2"> <div class="1"> <a id="1">HI</a> <a id="2"> <h1>HI<h2> </a> </div> </div> <div class="3"></div> <div class="2"></div> </div> </body> </html>
we can visualize the above HTML code in DOM structure we get

In Document object Model (DOM) , document is the paren…

locating webelements using selenium

Record and playback is a Novice routine and I am not interested in it.
 Selenium provides several options to locate Web Elements such as (h1,p,div...) .

The attributes id,name,classname are used for identifying particular element inside html for example

<html> <body> <pid="para1">Hi</p> <inputtype=textareaname="text" > <pclass="para2">Hello</p> <pclass="para2">World</p> <aid="linkone">link1</a> </body> <html>
#para1 { color:blue; } .para2 { color:green; }
we are giving id to <p id="para1">  for identify the element in order to change the property of that element. if you are using css or javascript id cannot be repeated unlike class="para2" , class name can be repeated and name is the attribute of input . In selenium there are classes and methods to get these elements by passing this id,name and classname 

In…

how to create a sample selenium program

creating a sample selenium program is very simple you need to create a new project and add a class to new project and save. Now add the selenium library to your IDE Build path.

For example I am creating a sample programs for navigating to a webpage .

For Navigating to Web Page we need a method called "get" which lies inside a class WebDriver , This class is provided by the Selenium library .

We wont talk about TestNG because we don't need it now.

The test step would be

1. You need to fireup the web browser
2. navigate to webpage.

so the code will be like this.

packageseleniumsampleproject; importorg.openqa.selenium.WebDriver; importorg.openqa.selenium.firefox.FirefoxDriver; ** @author pradeek */publicclass SeleniumSampleProject { publicstaticWebDriver driver; publicstaticvoidmain(String[] args) { driver =newFirefoxDriver(); driver.get("http://google.com"); } }

Here we created a instance of WebDriver class as driver and copyi…

prerequisites for Selenium automation.

For starting selenium you need a IDE , you can choose any IDE you want like Netbeans , Eclipse and Jetbrains intellij but this is pay , evaluation period is there.

Next you need to get the selenium libraries , There is two types of libraries Selenium server and Selenium driver either of them do the same but Selenium driver is faster than Selenium Server. you can download either version.

you need another another library for controlling the test that is TestNG .


How automation frameworks works

As i said in the previous post , Every web automation tools helps you to identify the web-element and make a action on it . If you are familiar with javascript Dom Method it would be more easier to understand . In Js there are libraries for locating elements and make a event the specific elements for example

document.getElementById("demo").innerHTML ="Hello World!";
This is Js code for identifying an element whose id is "demo" and we are inserting an text "Hello world" . This id could be the id of a <p> tag or h1 tag etc . We can make an action on this element by various way like onClick(),onLoad(),onHover() etc. you can use TagName or className for identifying elements too in Js .

In order to understand this you need to understand HTML DOM .HTML GUI is a representation of html code in browser . So HTML is not a programming language but some kind of representation of code for the GUI Part.
Another kind of representation is the HTML DOM. Hi…

Selenium Web automation

Selenium is a set of libraries which help you to identify and make action on web elements in a  web page . This is the primary task of every web automation tools . A part from this there are so many libraries to handle several cases in web technology . Selenium wont provide you the complete solution for web automation but almost.  why we need web automation ? QA is the part of every software development cycle , During QA process we need to test each functionality from top bottom that the mandatory thing . Consider we have thousand functionalities , it wont be a problem to test from top to bottom in test cycle for first time . But where feature adding in each day we need to test the feature also make sure that it wont effect stable functionalities so we need to test the rest of the functionalities along with the newer one. This would be tedious task doing the repeated testing on old ones with newer ones. This is where automation come in to play, Software automation applied to on certain …

Python first program

Python can be executed either in command line or file program.

for command line execution you need to get in to python environment, for that need to open your terminal and type python, then you will get in to python environment.

We will print string "Hello World" using python, for that you need to type print "Hello World" . This will print Hello World 



 for exiting from python environment press ctrl+d in pc.

or you can execute through as file program for that , open you text editor and type print "Hello World" and save it as filename.py . for example helloworld.py , for running you need to type python filename.py   and hit enter.