Wednesday, December 30, 2015

Python Interview questions

1. What is constructors in python?
2. How do inherit in python?
3. Name the types of datatypes in python?

Python has five standard data types:
1. Numbers
2. Strings
3. List
4. Tuple
5. Dictionary

Python supports four different numerical types:
1. int (signed integers)
2. long (long integers, they can also represented in octal and hexa decimal)
3. Float
4. Complex


4. Name the types of  variables in python? and how to configure the private, public variables and how to access them?

5. How do you reverse the string?


How do you login the webpage using python scripting without selenium web driver?

6. Write a class that keeps track of all the identifiers of objects created while instantiating?

7. Write a method that takes two dimensional list as argument and gives the transpose of the list
(Eg:)
def transpose(input_list):
    #Your Code here
    return output_list

a = [[1,2,3],[4,5,6]]


print transpose(a)
#Outputs[[1,4],[2,5],[3,6]]

8. Read a file and print only the strings from the file.

def Main():
        with open('word.txt','r') as f:
                for line in f:
                        for i in line.split(" "):
                                for x in i.rstrip("\n").split():
                                        if x.isalpha() == True:
                                                print x


if __name__ == "__main__":
        Main()


9. Write a class which implements method overloading?

10. What is the output of the following code?

def fun1(a=None):
    print "In the first function"

def fun1(a):
   print "In the second function"



Saturday, October 31, 2015

API testing: SoapUI property transfer using Groovy scripting

//Importing XML module of SoapUI tool
import com.eviware.soapui.support.XmlHolder



//Access the Get_Employee Response XML and get the value of name tag.
def response=context.expand('${GetEmployee#response}')
def xml=new XmlHolder(response)
def namenode = xml.getNodeValue("//ns:name")
log.info namenode
context.setProperty("name","$namenode")
log.info context.getProperty("name")

//Access the Delete Employee Request XML and store the value grabbed from the Get Employee Response
def requestt = context.expand('${DeleteEmployee#request}')
def xmlreq=new XmlHolder(requestt)
xmlreq.setNodeValue("//typ:guestName", namenode)

//Formatting the xml and put it in the Testcase, Teststeps level 
def dxml = xmlreq.getXml()
testRunner.testCase.testSteps["DeleteEmployee"].setPropertyValue("request",dxml)