1

I'm looking for a site where the name of the ID depends on some variables that I can't control.

So the ID can either be "sub_allGoods_4", "sub_allGoods_12" or whatever number:

find_element_by_xpath('//*[@id="sub_allGoods_4"]').text

Is there any way to use a * like to cover those cases?

find_element_by_xpath('//*[@id="sub_allGoods_**"]').text

1 Answer 1

2

Yes, use the contains function:

//*[contains(@id, 'sub_allGoods_')]
1
  • @user8459020 no problem, can you accept my reply as answer so the question doesn't remain open?
    – FDM
    Commented Aug 20, 2017 at 18:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.