0% found this document useful (0 votes)
28 views9 pages

Selenium With Python Interview Question

The document contains a comprehensive list of interview questions and answers related to Selenium, covering topics such as WebDriver, locators, synchronization, and handling web elements. It also includes Python-related queries, exception handling, and automation frameworks. The content is structured in a Q&A format, making it a useful resource for individuals preparing for Selenium interviews.

Uploaded by

mani sharma
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views9 pages

Selenium With Python Interview Question

The document contains a comprehensive list of interview questions and answers related to Selenium, covering topics such as WebDriver, locators, synchronization, and handling web elements. It also includes Python-related queries, exception handling, and automation frameworks. The content is structured in a Q&A format, making it a useful resource for individuals preparing for Selenium interviews.

Uploaded by

mani sharma
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

***************************selenium interview questions *****************************

Q1) What is Selenium Webdriver?


Selenium Web driver is set of class which used computerize the web application.

Q2) Is Selenium Web Driver Automation Tool?


No Selenium web Driver is not an Automation tool, it’s a framework or set of class which is
used to automate a web based application.

Q3) Can Selenium Web Services tested using Selenium?


No it is used to automate only web based application.

Q4) what is different locator supported in selenium?


Different Locators are:
* ID
* ClassName
* Name
* TagName
* LinkText
* Partial Link Text
* XPATH
* CSS

Q5) How Can we presentation Different browser using python?


For Chrome
driver=[Link](“PathofChromedriver”)
For Firefox
driver=[Link](“Path of Firefox Driver”)
for IE
driver=[Link](“Path of IE Driver”)

Q6) what kind of application best suitable for Selenium and why it should be
selected?
It is used to automate web based application and have browser and Platform compatibility.
It supports multiple languages such as Java 8 features, C# and Python.

::::::::::::::::::::::::::::::::::::::::::::: selenium online training :::::::::::::::::::::::::::::::::::::::::::::::::::


***************************latest selenium version*****************************

Q7) How Synchronization works in Selenium?


Synchronization is achieved using Implict Wait and Explicit Wait.

Q8) what is Implicit Wait?


Implicit Wait is used to default waiting time.

Q9) What are the different ways of selecting the values in dropdown?
* SelectByValue: select the option based on option value.
* selectByVisibleText: select the option based on visible text.
* selectByIndex: selects the option base on Index

Q10) How can enter the values in text box using python?
driver.find_element([Link],”Value”).send_keys(“Value”)

Q11) what is the difference b/w findelement and findelements?


FindElement returns first matching element.
FindElements returns more than one elements.

Q12) How can we get text of a web elements?


driver.find_element([Link],”Value”).text, this exact method will return inner text of the
control.

Q13) Is there any other way of reteriving text of web element?


driver.find_element([Link],”Value”).get_attribute(“InnerText”)

Q14) what is explicitly Wait?


Explicit Wait is used to halt the execution until condition is met or when time is elapsed.

Q15) what are the different Navigation commands in selenium?


it is used to refresh
[Link]()
it is used to navigate back
[Link]()
it is used to move forward
[Link]()

============================== selenium training ================================


***************************selenium interview questions *****************************

Q16) How can we checked if control enabled or not?


driver.find_element([Link],”Value”).is_enabled(), this detailed method will return if true or
false.

Q17) what is the difference b/w [Link] and [Link]?


Close is used to close the entire browser
quit is used to close the working tab.

Q18) How can we perform drag and drop in selenium?


act=ActionChains(driver)

act.drag_and_drop(sourcelement,targetelement), with this method we can perform drag


and drop

Q19) Can we move the mouse control to specific coordinate in selenium?


Yes we can, selenium training offers Action class in which we can make use of the
act.move_by_offset() method to move the mouse control to specific organizes.

Q20) How can capture screenshot in selenium?


driver.get_screenshot_as_file (“filename”) with this method we can take screen shot.

Q21) What are switch Class in selenium?


Switch class are used to switch between the different browsers, frames and alert pop-up.

Q22) What Action class in selenium?


Action class is user facing Application Programming Interface API to achieve difficult user
action events.

Q23) Can selenium handle the windows pop up?


No Selenium can’t handle windows pop Up

Q24) How can mouse hover on a controls in selenium?


act=actionChains(driver)
act.move_to_element(element)
with the above method we mouse hover on element, element argument is web element
where we need to mouse hover.

::::::::::::::::::::::::::::::::::::::::::::: selenium online training :::::::::::::::::::::::::::::::::::::::::::::::::::


***************************latest selenium version*****************************

Q25) Can selenium handle WebBased Pop Up?


Yes it can handle webbased pop up using “driver.switch_to_alert()”

Q26) Write a method to read data from webtable for specific row and column index using
selenium.
def GetData(rowIndex,colIndex):
tablerows=driver.find_element_by_id(“IdValue”).find_elements_by_tag_name(“tr”)
tableDefinitons=tablerows[rowIndex+1].find_elements_by_tag_name(“td”)
return tableDefinitons[colIndex].get_attribute(“innerText”)

Q27) What are Python unitTest default methods?


#Will execute before the execution of each test method
def setUp(self):
pass

# will execute once before it executes the any test methods


def setUpClass(cls):
pass
#will execute after the execution of each test method
def tearDown(self):
pass
# will execute after it executes all the test methods.
def tearDownClass(cls):
pass

Q28) Can Image or Captcha be automated using in selenium?


No captcha or image can’t be automated.

Q29) What is difference between list and tuple?


list is mutuable while tuple is not mutuable.

Q30) What is pass in python?


Pass means no operation to be done

============================== selenium training ================================


***************************selenium interview questions *****************************

Q31) How will install selenium in python?


We will use PIP command to install selenium
Pip install selenium Version_Nos

Q32) How can we converts string to int in python?


using int(“23”) to convert to int.
str(23) to convert to string

Q33) How will you handle exception in python?


try,except and finally key word is used to handle the exception

try:
#code
except: #catches the exception
finally: #executes the block whether any exception is raised or not.

Q34) What are the different data types supports in python?


Number, string, float and complex are the supported data types in python

Q35) What is MRO in python?


Method Resolution order is used in inheritance concepts
where class is inheriting multiple class and in all the parent class, same method is defined.
Child class is confused which method to call during run time. So the MRO helps to resolve
the issue.

Q36) How will identify when web element doesn't have any of the unique locater?
We can make use of the get_attribute method to get web element from list of web elements.

for control in controls:


if control.get_attribute(“attributename”)==”attributeValue”:
#found the matching control

Q37) what is difference b/w link text and partial link text?
LinkText will return element which exact match of given text.
Partial link text will return which include the given text.

::::::::::::::::::::::::::::::::::::::::::::: selenium online training :::::::::::::::::::::::::::::::::::::::::::::::::::


***************************latest selenium version*****************************

Q38) What are the different exception in selenium?


* webdriver exception
* noalertPresent Exception
* nosuchwindow Exception
*nosuchelement exception
*timeoutexception

Q39) How to execute java script in selenium login with python?


driver.execute_script(script)
above method will execute the java script.

Q40) what are the different way entering value Textbox?


* driver.find_element_by_id(“Val”).send_keys(“valuetoebeentered”)

* Other is using Action Class


act=ActionChains (driver)
act.send_keys_to_element(control,”Valuetobeenterd”)

Q41) what is the use of Xpath?


Xpath is used to find the web element in webpage.

Q42) What is difference between single and double slash in xpath?


Single slash is start selection from the document node.
Double slash is start selection from anywhere in the document.

Q43) How will perform double click on web element?


act=ActionChains(driver)
act.double_click(control)
Above method will be used to double click on the control.

Q44) What are the different automation Frameworks?


* Data Driven Framework
* Key Driven Framework
* Hybrid Framework

============================== selenium training ================================


***************************selenium interview questions *****************************

Q45) What is framework?


Framework defines a set of rules or best practices which we can follow in systematic way t
achieve the desired results.

Q46) What is difference between getwindowHandle() and getwindowHandles ()


getWindowHAndle()- it is used to get address of the the current browser where the control
is and return type is string.

getwindowshandles ()- it is used to get the address of the all open browser and its return
type is set<string>

Q47) How will you handle multiple windows in selenium?


We can use “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.

Q48) How will you verify if you have switched between the correct windows?
We can verify the window title to see if the we have switched to correct window or not.

driver.switch_to_window(“windowname”)
if [Link]==”ttileNAme”:
#switched to correct window

Q49) How to login into any site if it showing autentication pop up for username and
password?
To achieve this type of issue we can pass username and pwd with URL
[Link]

Q50) How to fetch the current URL in selenium?


driver.current_url returns the current url of the browser

Q51) How do you convert a number into a string?


>use str() inbuilt function in python

Q52) What is slicing?


> Slicing is used to fetch a specific range of items from sequence types like list, tuple,
Strings etc

::::::::::::::::::::::::::::::::::::::::::::: selenium online training :::::::::::::::::::::::::::::::::::::::::::::::::::


***************************latest selenium version*****************************

Q53) what is the o/p of teh following code?


i=6
while (i==6):
print(“Value of i is”+i)
> ‘value of 1 is 6’ and program will not stop

Q54) what is the o/p of len('') ?


>0

Q55) write a program for the below pattern?


1 12 123 1234 12345 > a = 0
While(a<5):
val = 0
while(val<=a): val = val +1 strprint = str(a) print(str(val), end = “”) a = a + 1 print()

Q56) write a program for the below pattern with only one while loop?
*
**
***
****
*****
****
***
**
*
>a=0
bool = True
While(a<=5):
if(a<0): break; if(a==5): bool = False if(bool): a = a + 1 else: a = a – 1 print(“*”*a)

Q57) Does python support Multiple inheritence?


> Yes

============================== selenium training ================================


***************************selenium interview questions *****************************

Q58) Which of the following functions does return a list of elements?


1. find_element_by_xpath
2. find_element_by_id
3. find_elements_by_name
4. find_element_by_partial_link_text
5. find_element_by_link_text
>3

Q59) which of the following is not a valid webdriver class?


1. [Link]
2. [Link]
3. [Link]
4. [Link]
>1

Q60) How to find the length of the list?


? Len(list)

::::::::::::::::::::::::::::::::::::::::::::: selenium online training :::::::::::::::::::::::::::::::::::::::::::::::::::

You might also like