C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
Locating Strategies- (By XPath- starts-with())In this section, you will learn how to locate a particular web element by XPath- starts-with() method. "starts-with()" is used to identify an element, when we are familiar with the attributes value (starting with the specified text) of an element. Let us consider an example in which we will try to locate the Google Search Engine Text box by XPath- Using starts-with() method. Follow the steps given below to locate the textbox provided on the home page of Google Search Engine.
The syntax for locating elements through XPath- Using starts-with() method can be written as: //<HTML tag>[starts-with(@attribute_name,'attribute_value')] or //*[starts-with(@attribute_name,'attribute_value')] Using XPath- starts-with method, we can write the Java code along with the dynamic XPath location as: findElement(By.xpath("//*[starts-with(@id,'lst')]"));
Next TopicLocating Strategies- By XPath
|