Selenium with Python Interview Questions and Answers
Last updated on 24th Oct 2020, Blog, Interview Question
In case you’re searching for Selenium with Python Interview Questions and Answers for Experienced or Freshers, you are at the correct place. There is parcel of chances from many presumed organizations on the planet. The Selenium with Python advertise is relied upon to develop to more than $5 billion by 2020, from just $180 million, as per Selenium with Python industry gauges. In this way, despite everything you have the chance to push forward in your vocation in Selenium with Python Development.ACTE offers Advanced Selenium with Python Interview Questions and Answers that assist you in splitting your Selenium with Python interview and procure dream vocation as Selenium with Python Developer.
1.What Is Python?
Python is a programming language with objects, modules, threads, exceptions and automatic memory management.
2.How Python Can Be Used In Software Testing?
- To generate test data; parse test results; generate reports; testing API calls etc.
- Python to extract requirements from a Word document.
- For testing tasks automation, setting up environments for tests, extracting performance data, etc…
- Testers use Python extensively in many companies with Selenium for test automation.
- For writing desktop applications used by testers.
- Test data manipulation.
- To build test environment
- Testing with IronPython on .NET
3.What Python Frameworks Do You Know?
Framework called Web2py, PAMIE (Python automation Module for I. E.), The pytest framework
4.What Tools That Helps Python Development Do You Know?
There are good tools for helping Python development such as Notepad++ with the PyNPP plugin and Eclipse with PyDev and PyUnit
5.What Is A “Unittest” In Python?
The unit testing framework of Python is known as “unittest”. It supports the sharing of setups, automation testing, shutdown code for tests, aggregation of tests into collections, among others.
6.How Python Is Interpreted?
Python language is an interpreted language. The Python program runs directly from the source code. It converts the source code that is written by the programmer into an intermediate language, which is again translated into machine language that has to be executed.
7.What Is The Difference Between “xrange” And “range”?
“Xrange” returns the “Xrange” object while range returns the “list” irrespective of the size of the “range”.
8.Define “module” And “package”?
- Each Python program file is a “module”, which imports other modules like “objects” and “attributes”.
- A Python program folder is a “package” of “modules”. A package can have “modules” or “subfolders”.
9.Why is my pip not working when my python is not installed properly?
The executable path is not set properly.
Subscribe For Free Demo[contact-form-7 404 "Not Found"]
10.What are the commands for downloading selenium?
- pip install –U selenium
- sudo pip install python
11.How can we know that our python is properly installed or not?
- pip –version
12.How can we implement unit test framework in our scripts?
By using:- import unittest
13.What are the different locators used?
- 1.Tag name
- 2.Class name
- 4.link text
- 5.Partial link text
- 6.CSS Selector
14.Which is the slowest locator?
15.Which is the best locator?
The selection of the best locator depends on the web elements or the ui page we are automating.
16.What is the library to be imported to add keyboard actions to our scripts?
from selenium.webdriver.common.keys import Keys
17.What is the library to be imported to add mouse actions to our scripts?
from selenium.webdriver.common.actionchains import ActionChains
18.What is Selenium?
It’s a Automation toolkit
19.What is a locator?
It’s an element in web page with which the python script would interact through the selenium driver
20.What is a Webdriver?
Selenium provides a tool to interact with the different web browsers. And they control the operation of the script. Ex: chromedriver, Iedriver, gecko for firefox.
It is the extensible markup language’s pathfinder where the data is stored in XML format like Key value pair
22.What’s the difference between / and // in xpath?
- / : absolute path // relative path
23.What’s the explicit and implicit wait?
- Explicit wait makes the browser wait for a given duration or the condition is true else, it will throw a time exceeded exception.
- Implicit wait- will make the browser wait for a defined time and the execution continues.
24.What are window handles?
Selenium with Python Interview Questions and Answers During the script execution if there is a new window that pops up then they have an address and they have a handle, each handle is listed in the variable handles
Ex: To reference those windows driver.switch_window(browser.window(handle))
25.What are alerts and how do you handle it?
Alerts are the popup windows that you get when there is notification to the user,
Handling them: alert_var = browser.switch_to_alert()
To dismiss: alert_var.dismiss()
To accept: alert_var.accept() etc
Get Selenium with Python 100% Practical Training
26.How to find elements by hyperlink?
- Find_element_by_link_text(“text of that hyperlink”).click()
27.How do you write the text in the login form?
28.What is the difference between close() and quit() func of the browser?
Browser.close() will close the current executing window and you can always switch to other window handles even after closing currently active one.Browser.quit() – will close the complete browser with all the open windows, this func handle and makes sure the processes are closed and terminated correctly without any memory leaks.
29.When the webpage is dynamic, which element locator do we use to locate an element?
30.How do we define a function in Python ?
def functionName: Function body
31.What is an indentation in python?
Python does not use braces to indicate the start & stop of function. It uses indentation (Whitespaces) to make the compiler understand the start & stop of function.
32.What is the syntax for “for” loop if we have to run for loop for 3 times?
for 1 in 5:Print(“)
33.What is WebDriver in selenium?
WebDriver is a plugin that helps to run selenium test scripts on a web browser.
34.What is the WebDriver used to run selenium script on chrome browser?
35.What type of languages can we use to write selenium scripts?
- We can use any scripting language.
- Get Selenium with Python Online Training
36.Can I use selenium for automation scripting without selenium IDE?
Yes, selenium can be imported as a module in any other programming platform & write selenium test scripts.
Learn Selenium With Python Certification Course to Enhance Your CareerWeekday / Weekend BatchesSee Batch Details
37.What is the use of automation testing?
It will reduce manpower & it also reduces the time that we spend on doing Selenium with Python every time.
38.Can we do data-driven testing using selenium?
Yes, bypassing values as parameters during run time.
39.Is selenium helpful for standalone application testing?
No, Selenium is only used as a test automation tool for web driver applications.
40.Why do you prefer to use Python for Selenium?
Python is not very large or complicated and one of the easy-to-use programming languages. Python APIs permit us to connect to the browser through Selenium. Selenium can convey normal Python commands to various browsers, in spite of the disparities in browser design.
41.What versions are there of Selenium?
- Selenium WebDriver – Used for the automation of tests in web applications.
- Selenium IDE – Firefox plugin to record and run tests.
- Selenium Grid – Allows you to run Selenium tests in parallel through multiple machines.
42.What programming languages does Selenium Webdriver support?
Languages supported are: Java, C #, PHP, Ruby, Python.
43.What kind of tests can we perform with Selenium Webdriver?
We can perform functional and regression tests on web applications.
44.What are the limitations of Selenium?
The main limitations of selenium are:
- You can only perform tests in web applications, not for desktop or mobile. (But other tools are available to automate desktop application GUI tests.)
- Captcha and barcode reading cannot be automated with Selenium. Selenium with Python is needed for them.
- The user who is going to perform automatic tests with Selenium Python must have previous knowledge of Python.
45.What are the different types of locators that we can use to search for an element with Selenium?
The locators that we can use with Selenium are ID, Name, ClassName, TagName, LinkText, and Partial LinkText, XPath, CSS Selector.
46.What is an XPath?
Xpath (XML Path Language) is a language that allows you to retrieve information from an XML document by defining a syntax to set parts in an XML document, allowing you to navigate through its elements and attributes, as well as allowing basic manipulation of Booleans, numbers, and strings.
47.What is the difference between / and // in an XPath expression?
We will use / to start the selection from a node in the document. It allows us to create absolute Xpath expressions. We will use // to start the selection from anywhere in the document. It allows us to create relative Xpath expressions.
48.What are the different types of drivers currently supported by Selenium Webdriver?
The supported drivers are Gecko driver (new from Selenium 3 to create an instance of FirefoxDriver), ChromeDriver, InternetExplorerDriver, SafariDriver, OperaDriver, AndroidDriver, IPhoneDriver, and HtmlUnitDriver.
49.How can we select an option of a dropdown using Selenium Webdriver?
To be able to select the value of a dropdown using Selenium Webdriver we have to use the Select class of Webdriver. Through this class we can select a value of a dropdown by its value, its visible text or its index number (position).
50.What is Selenium WebDriver
Selenium Web driver is a set of classes which automate the web application.
51.Is Selenium Web Driver Automation Tool?
No Selenium web Driver is not an Automation tool, it’s a framework or set of classes which is used to automate a web based application.
52.What kind of application best suited for Selenium and why it should be selected.
It is used to automate web based applications and have browser and Platform compatibility. It supports multiple language such as java, C# and Python
Get On-Demand Selenium With Python Training with Industry Concepts By IT Experts
- Instructor-led Sessions
- Real-life Case Studies
53.Can Selenium Web Services be tested using Selenium?
No it is used to automate only web based applications.
54.How Can we launch Different browsers using python?
- driver=webdriver.Firefox(“Path of Firefox Driver”)
- driver=webdriver.Ie(“Path of IE Driver”)
55.How Synchronization works in Selenium.
Synchronization is achieved using Implicit Wait and Explicit Wait.
56.What is Implicit Wait.
Implicit Wait is used to default waiting time.
57.What is explicit Wait.
Explicit Wait is used to halt the execution until condition is met or when time is elapsed.
58.How can I enter the values in the textbox using python?
59.How can we check if control is enabled or not?
, this specific method will return if true or false.
60.How can we get the text of a web element.
this specific method will return innertext of the control.
61.Is there any other way of retrieving text from a web element.
62.What are the different ways of selecting the values in dropdown.
- SelectByValue: select the option based on option value.
- selectByVisibleText: selects the option based on visible text.
- selectByIndex: selects the option base on Index
63.what are the different Navigation command in selenium
it is used to refresh
it is used to navigate back
it is used to move forward
64.What is the difference b/w findelement and findelements
- FindElement returns the first matching element.
- FindElements returns more than one element.
65.what is the difference b/w Driver.Close and Driver.quit
- close is used to close the entire browser
- quit is used to close the working tab.
66.Can selenium handle the windows pop up?
No Selenium can’t handle windows pop Up
67.Can selenium handle WebBased Pop Up.
Yes it can handle web based pop up using
68.How can I capture a screenshot in selenium.
with this method we can take a screenshot.
69.What is switch Class in selenium.
Switch classes are used to switch between the different browser,frames and alert pop up.
70.What Action class in selenium
ACtion class is a user facing API to achieve complex user action events.
71.How can we perform drag drop in selenium
with this method we can perform drag and drop
72.How can mice hover on a control in selenium?
- with the above method we mouse hover on element, element argument is web element where we need to mouse hover.
73.Can we move the mouse control to specific coordinate in selenium
Yes we can, selenium provides an Action class in which we can make use of the act.move_by_offset() method to move the mouse control to specific coordinates.
74.Write a method to read data from a web table for a specific row and column index using selenium.
- def GetData(rowIndex,colIndex):
- table rows=driver.find_element_by_id(“IdValue”).find_elements_by_tag_name(“tr”)
- table Definitions=table rows[rowIndex+1].find_elements_by_tag_name(“td”)
- return table Definitions[colIndex].get_attribute(“innerText”)
75.What are Python unitTest default methods
#Will execute before the execution of each test method
# will execute once before it executes any test methods
#will execute after the execution of each test method
# will execute after it executes all the test methods.
76.How will install selenium in python
We will use PIP command to install selenium
Pip install selenium Version_Nos
77.What is passed in python.
pass means no operation to be done
78.How can we convert string to int in python.
using int(“23″) to convert to int.
str(23) to convert to string
79.How will you handle exception in python
try,except and finally keyword is used to handle the exception
except: #catches the exception
finally: #executes the block whether any exception is raised or not.
80.What are the different data types supported in python
integer,string,float and complex are the supported data types in python
81.What is MRO in python
Method Resolution order is used in inheritance concepts
where class is inheriting multiple classes and in all the parent classes, the same method is defined. Child class is confused which method to call during run time. So the MRO helps to resolve the issue.
82.How will you identify when a web element doesn’t have any of the unique locators?
we can make use of the get_attribute method to get a web element from a list of web elements.
for control in controls:
- if control.get_attribute(“attributename”)==”attributeValue”:
#found the matching control
84.What are the different way entering value TextBox
- other is using Action Class act=ActionChains (driver)
85.What is the use of Xpath
xpath is used to find the web element in a webpage.
86.What are the different exception in selenium
- webdriver exception
- noalertPresent Exception
- nosuchwindow Exception
- no such element exception
87.How will perform double click on web element
Above method will be used to double click on the control.
88.How will you handle multiple windows in selenium
we can use the “switch_to_window” method to switch between the multiple windows. where in argument we would be sending the address of the window in the form of string.
89.What is the framework?
Framework defines a set of rules or best practices which we can follow in a systematic way to achieve the desired results.
90.What are the different automation Frameworks
- Data Driven Framework
- Key Driven Framework
- Hybrid Framework
91.write a program for the below pattern with only one while loop
- a = 0
- bool = True
- if(a<0): break; if(a==5): bool = False if(bool): a = a + 1 else: a = a – 1 print(“*”*a)
92.What is the difference between Assert and Verify?
- Assert it is used to verify the result. If the test case fails then it will stop the execution of the test case there itself and move the control to another test case.
- Verify it is also used to verify the result. If the test case fails then it will not stop the execution of that test case.
93.Why should Selenium be selected as a test tool?
Selenium is free and open source, has a large user base and helps communities cross Browser compatibility (Firefox, Chrome, Internet Explorer, Safari etc.) have great platform compatibility (Windows, Mac OS, Linux etc.)
supports multiple programming languages (Java, C#, Ruby, Python, Pearl etc.) has fresh and regular repository developments supports distributed testing
94.What are the testing types that can be supported by Selenium?
Selenium supports the following types of testing:
- Functional Testing
- Regression Testing
95.When should I use Selenium IDE?
Selenium IDE is the simplest and easiest of all the tools within the Selenium Package. Its record and playback feature makes it exceptionally easy to learn with minimal acquaintances to any programming language. Selenium IDE is an ideal tool for a naïve user.
96.What is the Java implementation of Python popularly known?
97.What is used to create unicode strings in Python?
Add u before the string u ‘mystring’
98.Explain how python is interpreted.
The Python program runs directly from the source code. Each type of Python programs are executed code is required. Python converts source code written by the programmer into intermediate language which is again translated into the native language machine language that is executed. So Python is an Interpreted language.
99.What Are The Benefits Of Using Python?
Python is a programming language with objects, modules, threads, exceptions and automatic memory management. The benefits of pythons are that it is simple and easy, portable, extensible, build-in data structure and it is open source.
Are you looking training with Right Jobs?Contact Us
- Tableau Tutorial
- JIRA Interview Questions and Answers
- SoapUI Interview Questions and Answers
- TestComplete Interview Questions and Answers
- E Learning Sample Resumes
- Apache Oozie Sample Resumes
- Business Objects Interview Questions and Answers
- Cassandra Interview Questions and Answers
- Sqoop Interview Questions and Answers