0

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

Yes, use the contains function:

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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