Wednesday, September 17, 2014

Best ever set of "Selenium Interview Questions"

CLICK HERE FOR COMPLETE QUESTION SET      Selenium interview questions



TESTING WORLD
Call or WhatsApp: 8743913121
www.youritmentor.in
www.worldtesting.in
Video Ad : https://www.facebook.com/video.php?v=569070436559995&set=vb.100003711325602&type=2&theater&notif_t=like

Training in Selenium, QTP, LoadRunner, Jmeter, SoapUI, Mobile Automation, Manual Testing

View Courses @ www.youritmentor.in


All Supported Element Locators in Selenium

Element Locator
Supported in RC
Supported in Webdriver
Id
id=
findElementById
Name
name=
findElementByName
Identifier
identifier=
fot Available
Link
link=
findElementByLinkText
findElementByPartialLinkText
CSS
css=
findElementByCssSelector
DOM
dom=
Not Available
XPATH
xpath=//
findElementByXpath
Class Name
class=
findElementByClassName
Tag Name
Not available
findElementByTagName


=================================================================

Annotations in Junit

@Test

@Test(timeout=500)

@Test(expected=IllegalArgumentException.class)

@Before (Will execute before every @Test Annotation)

@After            (Will execute after every @Test Annotation)

@BeforeClass (Will execute before executing any other annotation, execute only once at the start)

@AfterClass (Will execute after executing all other annotation, execute only once at the end)

@Ignore( used with @Test annotation, will skip execution of particular test method)

@Parameterized     (used for running my test case with multiple data)


Sunday, September 14, 2014

Python for Testers : Variables


Variables in Python

Variables are used to hold data, and value of variable can be change
In python we need not to declare variable, variables are declared automatically when we assign value to it

I=10;  #  int type variable is declared

J=100.055;   #  float type variable is declared

K=”Hello World”;  #   String type variable is declared

Program ::: Variable.py



Python for Testers: Python coding guidelines


Python Coding Guidelines/ Standards

Python is a case sensitive language


Identifier: Name of variable, method, module, class, object etc is called identifier.
                Identifier can have letters, number, _, can start with underscore and alphabets
                Identifier cannot have other special characters
                Class name should start with capital letter other identifier start with small letter
                If identifier start with _, means it need to be private
                If identifier start with __, means it need to be strongly private
                If identifier start and end with __ , means identifier has  language defined special name
                Eg:   __init()__


Blocks in python does not use braces, for blocks we use indentation


Statement in python does not end with semicolon, each line shows a separate statement
                    If we want to write statement in multiple line we can use line continuation symbol(\),  
                    statement contains []{}() does not need line continuation symbol


Comments is created by using # symbol


String         can be placed in ‘’ or “” or(triple) ‘’’    ‘’’ or “””      “”” , triple is used when string
                     exists in more than 1 line


raw_input(“enter data”) its is used to take user from input @runtime
print(“HELLO”)  command is used to print something on console
num = raw_input("Enter a number  :")


Multiple statements in single line can be placed by separating through semi colon



Python for Testers: Creating and Running python programs


Interactive Python
We can start writing python code directly using python interactive environment
For working with python in interactive mode, open command prompt, write python, enter
Now we will be in python interactive mode can write and execute command






Executing Python Code
Apart from running python code in interactive environment, we can execute python from

à Command Line “python   myfile.py”
à Python script can be  executed from python IDE



Start of Python Scripting
Way-1 We can write code in interactive mode, for that go to command prompt and write python, it will invoke python interpreter. Now we can write and execute python statements




Way-2  Open a notepad file and write python scripts there, then go to command prompt and invoke python interpreter with filename as argument here it will execute file






Python for Tester: Python Introduction


PYTHON
Python is a interpreted, interactive, object oriented scripting language
Python is an interpreted language: We can execute it directly by interpreter, no need of compiler
Python is interactive as we can directly start its console and write and execute command
Object oriented, it support OOPS concepts




Installation of Python
Download this .msi installer and run, It will install python and will set it to your path variable as well

After installation, go to command prompt and type python, here it will display version

Python version can be seen by python -v


If does not display then set python “C:\Python27” in path variable and check again
Ctrl+Z is to come out from interactive mode



High Level features of Python
Easy to write code(very less keywords), simple syntax, no semicolon
Support both structural as well as OOPS style of programming
Interactive language, we can execute single statements as well
Rich set of existing libraries
Can easily be coupled with other languages like Java, C, C++
Support automatic garbage collection
Support all major databases
Supporting large set of platforms like Windows, MAC, Unix, Linux etc

Monday, September 8, 2014

Working with Selenium IDE (Day-2)


               SELENIUM   IDE      TOOLBAR



                                   We have 2 Tabs here

Table :   Shows Selenium command in table format.

Source : Shows Selenium recrded script in HTML format.

Left side of Windows we have space for TEST  CASE :  All test cases will be displayed here.



                              SELENIUM IDE TOOLBAR




Right Side Red Button : This button is used for Start Recording & Stop Recording.

When we open selenium IDE this button is already open.


Left Side Slider: This is used to controlling the speed when we run recording test case.
                             We can control speed of execution of test case.


Then we have 2 Buttons

1 Play button from Left : It is used for execution of complete test suite.

2 1 Play button from Left : It is used to execute only current selenium test case.




Pause / Resume Button : It is used to pause the execution script while running and Resume execution Script.



Step Button :


This button is mainly available/enable when we PAUSE execution of script, it is mainly used for debugging.

As we click on Step Button, Script will move 1 step forward.

Roll UP : Repeated sequence of commands are grouped together.



                                Bottom Panel on Selenium IDE

LOG :   Shows log while execution of script.

Reference :  Gives detail of command that we want to use 

UI Element : Mainly for mapping complex name of application to simple name.

RollUP  :  Repeated sequence of commands are grouped together.


EDIT MENU
à INSERT NEW COMMAND : To enter a new command
à INSERT NEW COMMENT : IT WILL ENTER A COMMENT IN TABLE VIEW






                                                 FILE MENU





ADD Test Case : To add other test cases in this test suite.

Properties : Select test case and click on properties to view properties.




                                      ACTION MENU BAR



Toggle Break Point :  Set Breakpoint, so application will pause at this line, similar to use Pause toolbar button.


Set / Clear Startpoint : Making Start point, so that application will run from particular line it will not start from 1st line.

Execute This Command : Execute only selected command.
 


                                                     Option Menu Bar




Reset IDE Window : Bring IDE window to its original settings.

Format : We can select any format, now In Source tab we will find coding in that format rather than HTML.

ClipBoard Format : We can set clipboard format, now if we select any of the command from Table of Selenium id and paste it anywhere else, it will paste in format which is selected in Clipboard format.




Selenium IDE installation (Day-1)

Install Selenium IDE

Any browser other than Firefox

Step1: Open IE



Step 3: Click on Download

Step 4: Click on Save



Here we will find that “selenium-ide-x.x.x.xpi” file will save in your system.


Step 5: Go to Location, where Downloaded file is saved.

Step 6: Right Click on that saved file, Select Open With à Select Firefox

Step 7: You will get following screen now



Step 8 : Click on Install Now



Step 9: Selenium IDE is installed, click on “Restart Firefox”

Step 10: Go to Tools

Here we will find that selenium IDE is installed .






Selenium Kickoff (Day-1)


          WORKING WITH SELENIUM

SELENIUM

Selenium is the open source tool for functional and regression testing

                    Having 4 Parts
n  Selenium IDE
It’s a java script framework.
It is installed as add-on on Mozilla
It is used to record user steps on application.
n  Selenium RC
It is mainly used to run test suites on multiple browser.

n  Selenium GRID
use to execute test cases on Multiple Browsers/Multiple systems in parallel.

n  WebDriver
New enhancement in selenium, added with selenium 2.0
alternate of selenium RC, provide fast execution of test cases.



Commands used in selenium are called Selenese 



ADVANTAGE OF SELENIUM

è Open Source Tool, so no license fees.
è Support large number of programming language for scripting.
è Support large number of browsers.
è With Selenium Grid, we can execute in parallel, ultimately fast execution.


DISADVANTAGE OF SELENIUM

è Support only Web based applications.
è Its Free, so no support is available.
è No Rich GUI / Lot of programming skills are required.
è Does not support FLASH, Silverlight etc  







PARTS OF SELENIUM
========================================================================                              
SELENIUM IDE        SELENIUM RC          SELENIUM GRID      Webdriver
                                     à RC Server                 à Selenium Hub           ànew enhance
                                     à Selenium Core          à Selenium RC 
                                     à Client Libraries  



                              SELENIUM RC(Remote Control) Components

à RC Server                                 

à Selenium Core                         

à Client Libraries  

The RC Selenium Server
à launches and kills browsers
à  interprets and runs the Selenese commands passed from the test program
à  acts as an HTTP proxy, intercepting and verifying HTTP messages passed between the browser and the AUT.
à Return result of selenium command back to test program.
à Selenium server is bundled with selenium core, automatically inject this selenium core to browser when start browser.

             Selenium-Core
                 is a JavaScript program, actually a set of JavaScript functions which interprets and    
                executes Selenese commands using the browser’s built-in JavaScript interpreter.


 Client libraries
 which provide the interface between each programming language and the Selenium RC  Server.
             Client libraries provide support of different language to selenium



Here is a simplified architecture diagram....

The diagram shows the client libraries communicate with the Server passing each Selenium command for execution. Then the server passes the Selenium command to the browser using Selenium-Core JavaScript commands. The browser, using its JavaScript interpreter, executes the Selenium command. This runs the Selenese action or verification you specified in your test script.



Run Selenium Server

START SELENIUM SERVER


Go to Command Prompt.

Go to directory where selenium server is placed.

Type the command

java –jar selenium-server.jar


                   HOW TO CREATE A BAT FILE TO START SELENIUM SERVER


1-> Open a Notepad
2-> Enter following commands

ECHO "HELLO WORLD"                             //  To display something on console
PAUSE                                                            // Hold Execution until user press Enter
cd D:\                                                             
PAUSE
Cd Program Files\Java\jdk1.6.0\bin\Selenium\
PAUSE
Java -jar Selenium-server.jar

3-> Save File as Name.bat file

Running Selenium Test Case in Eclipse using Junit

Running Selenium Test Case in Eclipse using Junit

1à Open Selenium test case in selenium IDE

2à Export Test Case in Junit4 Format(in Latest IDE, it looks like Java/Junit4/RemoteControl

3à Open that exported file and copy its content.

                                             NOW MOVE TO ECLIPSE

4à Open Eclipse; create a java project, package and java class.

After Creating Project, Go to Src folder , right click and create package

After creating package, right click on package and create a class

5à pick data copied in Step 3 and place it in Java class created in Step 4(after the all existing lines of code)

Note:
 Lot of Red(x) are display on left of line of code so to remove that
è  first , replace class name of java project(class name coming from IDE replaces class name here in Eclipse) 

è Now remove code which is actually generated in java class(left the code which is copy from selenium IDE)
           Few red(X) will be removed
Note:: Still lot of Red Cross(x) is available, it’s because we need to add selenium client libraries for java here in project. Actually in coding we are using selenium class, creating object for that but libraries does not exist in build path of the project.

6à Right Click on Java Projectà Build Path à Configure Build Path

Go to Libraries Tab, Click on Add External Jar Button at right side

Now Selenium server RC jar which we have downloaded while installing selenium server

Close this window, Save, Here we will find that all Red Cross(x) are removed from code lines.
Everything is set now to run test case.
NOW get ready to execute test cases

7à Go to Runà Run as Junit

Here we will find that test case still gets failed it’s because selenium server is down, start selenium server and then run test case as junit.

To Start Selenium Server:  Open command prompt, move to place where jar of selenium server exist
Now write command:   java-jar seleniumserver_jar_name.jar

Test case will run successfully.