C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
Locating Strategies- (By XPath- Using Single Slash)In this section, you will learn how to locate a particular web element by XPath- Using Single Slash. Single Slash mechanism is also known as finding elements using Absolute XPath. Single Slash is used to create XPath with absolute XPath i.e. the XPath would be created to start selection from the document node/ Start node/ Parent node. Note: XPath Absolute is not recommended because it takes the complete XPath location and if the location of the web element is changed or it belongs to some other parent then XPath will be unable to locate the desired element.The syntax for locating elements through XPath Absolute is written as: //html/body/tag1[index]/tag2[index]/.../tagN[index] Using Single Slash/Absolute XPath, we can write the Java code along with the dynamic XPath location as: findElement(By.xpath("html/body/div[1]/div[2]/div[2]/div[1]/form/div[1]/div/div[1]/div/div/input[1]"));
Next TopicLocating Strategies- By XPath
|