Interview Questions of Python selenium

Q1) What is Selenium and what is composed of?
Ans:

Selenium is a suite of automated web testing resources.

Selenium IDE:

It is a recording and replay method. It is a Plugin for Firefox

WebDriver and RC:

It offers APIs for a number of languages, such as Java, .NET, PHP, etc. The Webdriver and RC browsers work for most of them.

Q2) Why my pip is not working when my python setup is not installed properly?
Ans:

Executable path is not set correctly.

Q3) How Can we open Different browser using python?
Ans:

For Firefox browser

driver=webdriver.Firefox(“Path of Firefox Driver”)

for IE browser

driver=webdriver.Ie(“Path of IE Driver”)

For Chrome browser

driver=Webdriver.Chrome(“Path of Chromedriver”)

Q4) What are the different types of annotations which are used in Selenium?
Ans:

Following are the annotations are used in selenium:

  • Test
  • BeforeClass
  • After
  • Ignore
  • Before
  • AfterClass
  • RunWith
Q5) What is the commands for downloading selenium?
Ans:

pip install –U selenium

sudo pip install python

Q6) What are the different locators used?
Ans:
  • Class name
  • id
  • Tag name
  • Name
  • Partial link text
  • CSS Selector
  • XPath
  • link text
Q7) What is a locator?
Ans:

It is a web page element that the python script can communicate with via the selenium driver.

Q8) What is a Webdriver?
Ans:

Selenium provides a tool for interacting with various browsers on the web. And they control the script’s operation.

Q9) How to find element by hyperlink?
Ans:

Find_element_by_link_text(“text of that hyperlink”).click()

Q10) What is pass in python.
Ans:

Pass means that there is no operation to do.

Q11) Can we use selenium when the webpage and resource locater elements are changing frequently?
Ans:

never.

Q12) What are the different Navigation oprations in selenium?
Ans:

used to refresh

driver.refresh()

used to navigate back

driver.back()

used to move forward

driver.forward()

Q13) What is the WebDriver used to run selenium script on chrome browser?
Ans:

chrome driver

Q14) What is the use of automation testing?
Ans:

This will reduce manpower and thus reduce the amount of time we spend on manual inspection at all times.

Q15) What is used to create unicode strings in Python language?
Ans:

Add u before the string u ‘mystring’

Q16) Why you prefer to use Python for Selenium?
Ans:

Python is one of the easy-to-use programming languages and is not very big or complex. Python APIs allow us, via Selenium, to connect to the browser. In terms of the differences in browser architecture, Selenium can express normal Python commands to different browsers.

Q17) Which is the slowest locator?
Ans:

Xpath.

Q18) When webpage is dynamic which element locater do we use to locate an element?
Ans:

driver.findElementByXpath()

Q19) What is the difference between quit() and close() function of the web browser?
Ans: Browser.quit()

This feature manages the entire browser for all open windows and guarantees that the processes are closed and terminated properly without any memory leaks.

Browser.close()

The latest executing window will close and you can still turn to other window handles, even though the newly running window is locked.

Q20) Whats XPATH?
Ans:

It is the direction finder of the expandable markup language where the data is stored in XML format such as Key value pair.

Q21) What is a Webdriver?
Ans:

Selenium is a tool for interacting with multiple browsers on the internet. And they monitor the script’s operation.

Q22) Explain how to assert text of webpage using selenium 2.0?
Ans:

WebElement el = driver.findElement(By.id(“ElementID”))

String text = el.getText();

Assert.assertEquals(“Element Text”, text);

Q23) What are the different types of drivers currently supported by Selenium Webdriver?
Ans:

The supported drivers are:

  • Gecko driver
  • ChromeDriver
  • InternetExplorerDriver
  • SafariDriver
  • OperaDriver
  • AndroidDriver
  • IPhoneDriver
  • HtmlUnitDriver.
Q24) Explain what is assertion in Selenium and what are the types of assertion?
Ans:

As a verification stage, statement is used. It verifies that the state of the request is in line with what is planned. Assert prove and waitFor are the types of assertion.

Q25) What is the difference between verify and assert commands?
Ans: Verify:

The Verify command tests if the object is on the page, and the test continues to run if it is not. In verification, even if every test fails, all the commands are expected to run.

Assert:

Assert helps you to verify whether or not an element exists on the page. If the proclaimed aspect is not available, the evaluation would end at the phase failed. In other words, at the point where the search fails, the evaluation will be terminated.

Copyright 1999- Ducat Creative, All rights reserved.