Forum Discussion

enriquebravo's avatar
enriquebravo
Contributor
2 years ago
Solved

Using regexp for FindElement

Hello,   I read several other forum post similar to my issue and seems like regexp and FindElement may not work.   I got the following dynamic xpath: FindElement("//div[@id='__49_0']//input") Unf...
  • chriscc's avatar
    2 years ago

    Hi enriquebravo,

     

    I am not a xpath expert...if the id number is dynamic, and id isn't unique to that div element, then you shouldn't have to look for the id attribute in your expression.  Something like  this might work: FindElement("//div//input")

     

    if the id is unique to that div element then you can simply verify that it exists, something like this might work:  FindElement("//div[@id]//input")

     

    if part of the attribute is unique, like the underscores, then you might be able to use the contains method, like this:  FindElement("//div[contains(@id, '__')]//input")

     

    Not sure if any of this works or helps, but I thought I'd share.