Prepare Interview

Mock Exams

Make Homepage

Bookmark this page

Subscribe Email Address

Selenium Interview Questions and Answers

Ques 16. Explain the difference between assert and verify commands?

Assert: Assert command checks if the given condition is true or false. If the condition is true, the program control will execute the next phase of testing, and if the condition is false, execution will stop, and nothing will be executed.

Verify: Verify command also checks if the given condition is true or false. It doesn't halt program execution, i.e., any failure during verification would not stop the execution, and all the test phases would be executed.

Is it helpful? Add Comment View Comments
 

Ques 17. What do you mean by XPath?

XPath is also defined as XML Path. It is a language used to query XML documents. It is an important approach to locate elements in Selenium. XPath consists of a path expression along with some conditions. Here, we can easily write XPath script/query to locate any element in the webpage. It is developed to allow the navigation of XML documents. The key factors that it considered while navigating are selecting individual elements, attributes, or some other part of an XML document for specific processing. It also produces reliable locators. Some other points about XPath are as follows.

  • XPath is a language used for locating nodes in XML documents.
  • XPath can be used as a substitute when you don't have a suitable id or name attribute for the element you want to locate.
  • XPath provides locating strategies like:
    • XPath Absolute
    • XPath Attributes

Is it helpful? Add Comment View Comments
 

Ques 18. Explain XPath Absolute and XPath attributes.

XPath Absolute:

  • XPath Absolute enables users to mention the complete XPath location from the root HTML tag to the specific elements.
  • Syntax: //html/body/tag1[index]/tag2[index]/.../tagN[index]
  • Example: //html/body/div[2]/div/div[2]/div/div/div/fieldset/form/div[1]/input[1]

XPath Attributes:

  • XPath Attributes is always recommended when you don't have a suitable id or name attribute for the element you want to locate.
  • Syntax: //htmltag[@attribute1='value1' and @attribute2='value2']
  • Example: //input[@id='passwd' and @placeholder='password']

Is it helpful? Add Comment View Comments
 

Ques 19. What is the difference between "/" and "//" in XPath?

Single Slash "/": Single slash is used to create XPath with absolute path.

Double Slash "//": Double slash is used to create XPath with the relative path.

Is it helpful? Add Comment View Comments
 

Ques 20. What are the different types of annotations which are used in Selenium?

JUnit annotations which can be used are:

  • Test
  • Before
  • After
  • Ignore
  • BeforeClass
  • AfterClass
  • RunWith

Is it helpful? Add Comment View Comments
 

Most helpful rated by users:

©2024 WithoutBook