Posts

Showing posts with the label DOM

XPath unable to find text with   or   using webdriver /

Hi, Some times we face issues to create XPath of  WebElement which have space in starting of it and then we check the element html source where we found &nbsp; or &nbsp is added before the element text while it display as space on UI. Normally we create the XPath to identify this element by adding space in the starting of it but his will not identify the element. There are another workaround to identify this element by contains text method. But if we have to identify the element with exact text having starting space or ending space  then we can use following way to do this. lets see this example <div class="myclass"> <label>AgendaShowCapacity &nbsp; </label> </div> OR <div class="myclass"> <label> &nbsp AgendaShowCapacity</label> </div> Following XPath will not work for this //label[text()='AgendaShowCapacity&nbsp;']  doesn't work Here we have to use follow...

Locating elements using DOM, Css and Xpath

 Refer the below example Whole web page xpath=/html css=html document.documentElement Whole web page body xpath=/html/body css=body document.body All text nodes of web page //text() Element <E> by absolute reference xpath=/html/body/.../.../.../E css=body>…>…>…>E document.body.childNodes[i]...childNodes[j] Element <E> by relative reference //E css=E document.gEBTN('E')[0] Second <E> element anywhere on page xpath=(//E)[2] document.gEBTN('E')[1] Image element //img css=img document.images[0] Element <E> with attribute A //E[@A] css=E[A] dom=for each (e in document.gEBTN('E')) if (e.A) e Œ Element <E> with attribute A containing text 't' exactly //E[@A='t'] css=E[A='t']  Element <E> with attribute A containing text 't' //E[contains(@A,'t')]  Element <E> whose attribute A begins with 't' ...