Is it possible to locate element by partial id match in Selenium

后端 未结 5 989
旧巷少年郎
旧巷少年郎 2020-11-28 08:36

I am trying to locate elements with generated ids wherein some part of the ID is known; for example:

id=\"page_x002e_x0023_default-create-firstname\"
         


        
5条回答
  •  不知归路
    2020-11-28 09:08

    If you want to go down the xpath route then you could use contains(), like this:

    //*[contains(@id,'_default-create-firstname')]
    

    This will search the entire page for an id that contains the text "_default-create-firstname". It can be easily made more specific

提交回复
热议问题