Here using xpath / Css, we can combine two locators when ever required, lets see how we can achieve. Identify element using multiple attributes We can directly use them by using id or name locators. With Name - css=input or css=Īll the above syntax are simple. With ID - css=input#email or css=#emailĢ. With ID : - or we can also use as With Name - or we can also use as css we can use as below :ġ. Let us look for xpath examples to use ID and Name effectively with combinationsġ. Though we have some browser plug-ins to generate xpath or css selector, but they are not much useful in real time applications. In many cases like these, we depend locating elements by CSS or by XPath. It is always very important to make test scripts robust with reliable locators that do not break until changes made. You don't need to search for any other locator if there is ID or unique name present in your application.īut with the applications designed using modern JavaScript Frameworks like Angular, React and Vue.js have no proper web elements in DOM. As we know it is always better to use ID and Name to locate the elements which will work for sure. It is very simple to locate elements if the HTML DOM has 'id' or 'name' and they are the safest locators to use. In order to perform any operation on the element like click or type into an element, we need to locate that element.
0 Comments
Leave a Reply. |