Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3
Lecture 15: Selenium Xpath, locator Notes
Question 1: WHAT IS LOCATOR?
ANSWER: To Capture any web element, we have to use locators. There are different types of locators in Selenium. There are 8 types of locators By.id(), By.name(), By. Tagname(), By. Classname(), By. Linktext(), By.partialLinkText(), By.xpath, By.cssSelector(). But among them, only xpath is most popular and reliable in every company, and some companies use id, name, and xpath. In the interview, they can ask questions about xpath only.
Question 2: What is the use of xpath?
Answer: Xpath is definitely a locator. It is used to find the web Element on the web page. It is very useful to identify the dynamic web elements. Xpath is a very powerful locator.
Question 3: What do you mean by Dynamic objects?
Answer: Dynamic object are those which object properties changes frequently. Question 4: How many types of xpath are there? Answer: There are different types of xpath. Normally we call 2 types of xpath. 1. Absolute xpath (/ Single slash) 2. Relative xpath (//Double slash)
****Interview Question: What is single slash xpath? Or, Which xpath
do we use? Or, Can you explain about xpath? Or, What is your understanding of xpath? Or, Do you use locator? Or, What type of locator do you use for capture the web element? Answer: There are different types of locators, but we use xpath as locator.
***Interview Question: Which xpath do we use mainly at the office?
Answer: Mainly, we use Relative xpath (// Double slash) at the office. ****Interview Question: What is single slash xpath? OR, Do you have any knowledge about absolute xpath? OR, Do you know how absolute xpath works? OR, Do you have any knowledge about single slash xpath? Answer: Single Slash xpath is Absolute xpath/ Absolute xpath is called (/Single Slash) xpath. Absolute or single slash xpath is we have to go from Grandparents, then Parents, then Child (Grandparents > Parents > Child). In other word, We have to go from the Root to the specific Object. In that case, if grandparents change, then automatically, parent and child will change. If anywhere anything changes, then we can’t identify the object. For absolute xpath, we need to maintain sequence.
****Interview Question: Do you have any idea about double slash
xpath? Answer: //Double slash is, Relative xpath / Relative xpath is called Double slash xpath. Here, relative means we are going to specific project, and then we use relative xpath. If I have some situations in my project, to overcome those situations, I use relative xpath.
***Interview Question: What is the difference between single slash
and double slash xpath? Answer: Single slash starts from it’s root. We have to go from root to specific object. That means if anything changes, the path changes automatically. We know developers always update features or sometimes remove or add features. In that case, the whole xpath will change, and it will not work anymore, and it will be valueless. In other words, we can say the single slash/Absolute Xpath is the relation of Grand Parents > Parents > Child. I have to go from the Root to the Specific Object. That means, if grandparents change, parents change, if anywhere anything changes, then we cannot identify the object. We need to maintain the sequence. That is why we don’t use absolute xpath. On the other hand, // Double slash is Relative Xpath ( ), and Relative means we can go to a specific Object. we don’t need to go to it’s root. We use relative Xpath because it is reliable and popular. In case of this xpath, we can go to the specific object or code to find a unique xpath directly. So, any change that happens in the root will not affect this xpath. So, we always prefer //double slash. Question 5: What is custom xpath? Answer:
**** We keep our web element in the pageobjectmodel
(POM)package In this Lecture, we have learned about 3 things about automation First Annotation@ FindBy Then, we will use the locator, then the webelement, then the name of the webelement, and then create a method.
الشركات العسكرية و الأمنية الخاصة و دورها كفاعل مؤثر في العلاقات الدولية Private Military and Security Companies and Their Role as Influential Actor in International Relations
RNA Sequence Structure and Function Computational and Bioinformatic Methods 1st Edition Jan Gorodkin - Download the entire ebook instantly and explore every detail