C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
Locating Strategies- (By XPath- Using contains())In this section, you will learn how to locate a particular web element by XPath- Using contains() method. "contains()" is used to identify an element, when we are familiar with some part of the attributes value of an element. Let us consider an example in which we will try to locate the Google Search Engine Text box by XPath- Using contains() 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 contains() method can be written as: //<HTML tag>[contains(@attribute_name,'attribute_value')] or //*[contains(@attribute_name,'attribute_value')] Using XPath- conatins() method, we can write the Java code along with the dynamic XPath location as: findElement(By.xpath("//*[contains(@id,'lst-ib')]"));
Next TopicLocating Strategies- By XPath
|