C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
Locating Strategies- (By XPath- Using Single Attribute)In this section, you will learn how to locate a particular web element by XPath- Using Single Attribute. Let us consider an example in which we will try to locate the Google Search Engine Text box by XPath-Using Single Attribute. Follow the steps given below to locate the textbox provided on the home page of Google Search Engine.
Note: Browsers like Firefox by default provides the XPath location with single attribute.The syntax for locating elements through XPath- Single Attribute can be written as: //<HTML tag>[@attribute_name='attribute_value'] or //*[@attribute_name='attribute_value'] Note: '*'after double slash is to match any tag with the desired text.Copy the desired dynamic XPath location and paste it in between the Java code for locating the web elements through XPath: findElement(By.xpath("//*[@id="lst-ib"]"));
Next TopicLocating Strategies- By XPath
|