Selenium Interview Question and Answars
Selenium Interview Question and Answars
1. Tag name
2. Class name
3. id
4. link text
5. Partial link text
6. CSS Selector
7. XPath
8. Name
6) What is a locator?
It’s an element in web page with which the python script would interact
through the selenium driver
7) 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.
8) Whats XPATH?
It is the extensible markup language’s path finder where the data is stored
in XML format like Key value pair
9) Whats the difference between / and // in xpath?
/ : absolute path // relative path
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
15) 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.
16) When webpage is dynamic which element locater do we use to
locate an element?
driver.findElementByXpath()
17) What is WebDriver in selenium?
WebDriver is a plugin that helps to run selenium test scripts on a web
browser.
18) 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.
21) 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.
28) How can enter the values in text box using python.
driver.find_element(By.ID,”Value”).send_keys(“Value”)
29) How can we get text of a web element.
driver.find_element(By.ID,”Value”).text, this specific method will return
innertext of the control.
30) what are the different Navigation command in selenium
it is used to refresh
driver.refresh()
it is used to navigate back
driver.back()
it is used to move forward
driver.forward()
31) What is the difference b/w findelement and findelements
find_element_by_id(“val”).send_keys(“valuetoebeentered”)
other is using Action Class
act=ActionChains(driver)
webdriver exception
noalertPresent Exception
nosuchwindow Exception
nosuchelement exception
timeoutexception
44) 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.
45) 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.
Hard Assert:Hard Asserts are used when you want to halt the
execution of the test script (or test method)
when the assert condition does not match with the expected
result.
Soft Assert:oft Asserts are used when the test script (or test
method) need not be halted
when the assertion condition does not meet the
expected result
48) Why XPath is slower than other locators?
Xpath allows bidirectional flow which means the traversal can be both ways
from parent to child and child to parent as well. Css allows only one
directional flow which means the traversal is from parent to child
only. Xpath is slower in terms of performance and speed