Forum Discussion

mfremont-smith's avatar
mfremont-smith
Occasional Contributor
2 years ago
Solved

WaitElement and search from current element

The WaitElement Documentation states: "To search through the entire page starting from the page’s root element, put a double slash (//) at the beginning of the XPath expression. To start the search from the current element, use a dot (.)."

 

My Problem:

This returns a valid object, but it is very slow. I'm guessing its slow because it starts with double slash (//) which means it searches the entire page, of which there are tons of elements.

 

page.tblCell.WaitElement("//a//i[contains(@class,'fa-search')]")

 

This is my attempt at starting the xpath with a dot(.), but it causes an "object does not exist" error:

 

page.tblCell.WaitElement(".a//i[contains(@class,'fa-search')]")

 


Can someone provide a working example of an xpath expression that starts with a dot (.) ?

  • Hi,

     

    I guess that XPath should be like this:

    ".//a//i[contains(@class,'fa-search')]"

    note double slash after dot.

     

    Does it help ?

     

2 Replies

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi,

     

    I guess that XPath should be like this:

    ".//a//i[contains(@class,'fa-search')]"

    note double slash after dot.

     

    Does it help ?