Part 3
11 : Can you lot say me the syntax to open/launch Firefox browser In WebDriver software testing tool?
Answer : We tin opened upward novel Mozilla Firefox browser Instance using bellow given syntax In WebDriver software testing tool.
12 : What Is XPath together with what Is usage of It In WebDriver?
WebDriver driver = novel FirefoxDriver();
VIEW PRACTICAL example.12 : What Is XPath together with what Is usage of It In WebDriver?
Answer : In Selenium WebDriver software testing tool, XPath is used to locate the elements. Using XPath, We tin navigate through elements together with attributes In an XML document to locate software webpage elements similar buttons, text box, links, Images etc..
13 : Which tool you lot are using to uncovering the XPath of whatever element?
Answer : I am using Mozilla Firefox AddOns FireBug together with FirePath to uncovering the XPath of software spider web elements. encounter THIS POST to download it.
VIEW MORE TUTORIALS ON SELENIUM WEBDRIVER
VIEW MORE TUTORIALS ON SELENIUM WEBDRIVER
14 : What is the divergence between absolute XPath and relative XPath?
Answer :
Absolute XPath : Absolute XPath Is the amount path starting from beginning node together with ends with desired descendant element's node. It volition inaugural of all using single forward slash(/) every bit bellow.
Relative XPath : Instead of starting from beginning node, Relative XPath starts from whatever In betwixt node or electrical flow element's node(last node of element). It volition inaugural of all using double forrad slash(//) every bit bellow.
Example Of Relative XPath :
Above XPath Is relative XPath of same calc consequence box given on THIS PAGE.
Answer : There are many dissimilar alternatives In such case.
Alternative 1 : Look for whatever other attribute which Is non changing every fourth dimension In that div node similar name, bird etc. So If this div node has bird attribute hence nosotros tin write xpath every bit bellow.
Alternative 2 : You tin usage absolute xpath(full xpath) where you lot non involve to laissez passer whatever attribute names In xpath.
Alternative 3 : Use starts-with function. In this xpath's ID attribute, "post-body-" component division stay same every time. So you lot tin usage xpath every bit bellow.
Alternative 4 : Use contains function. Same means you lot tin use contains business office every bit bellow.
Absolute XPath : Absolute XPath Is the amount path starting from beginning node together with ends with desired descendant element's node. It volition inaugural of all using single forward slash(/) every bit bellow.
Example Of Absolute XPath :
/html/body/div[3]/div[2]/div[2]/div[2]/div[2]/div[2]/div[2]/div/div[4]/div[1]/div/div/div/div[1]/div/div/div/div[1]/div[2]/form/table/tbody/tr[1]/td/input
Above XPath Is absolute XPath of calc consequence box given on THIS PAGE. It starts overstep node html together with ends amongst input node.
Example Of Relative XPath :
//input[@id='Resultbox']
Above XPath Is relative XPath of same calc consequence box given on THIS PAGE.
15 : How To Handle Dynamic Changing IDs In XPath.
Example : //div[@id='post-body-3647323225296998740']/div[1]/form[1]/input[1]
In this XPath "3647323225296998740" Is changing every fourth dimension when reloading the page. How to grip this situation?
Example : //div[@id='post-body-3647323225296998740']/div[1]/form[1]/input[1]
In this XPath "3647323225296998740" Is changing every fourth dimension when reloading the page. How to grip this situation?
Answer : There are many dissimilar alternatives In such case.
Alternative 1 : Look for whatever other attribute which Is non changing every fourth dimension In that div node similar name, bird etc. So If this div node has bird attribute hence nosotros tin write xpath every bit bellow.
//div[@class='post-body entry-content']/div[1]/form[1]/input[1]
Alternative 2 : You tin usage absolute xpath(full xpath) where you lot non involve to laissez passer whatever attribute names In xpath.
/html/body/div[3]/div[2]/div[2]/div[2]/div[2]/div[2]/div[2]/div/div[4]/div[1]/div/div/div/div[1]/div/div/div/div[1]/div[2]/div[1]/form[1]/input[1]
Alternative 3 : Use starts-with function. In this xpath's ID attribute, "post-body-" component division stay same every time. So you lot tin usage xpath every bit bellow.
//div[starts-with(@id,'post-body-')]/div[1]/form[1]/input[1]
Alternative 4 : Use contains function. Same means you lot tin use contains business office every bit bellow.
div[contains(@id,'post-body-')]/div[1]/form[1]/input[1]