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
FDM
5,8941 gold badge17 silver badges34 bronze badges
asked Aug 20, 2017 at 17:46

1 Answer 1

2

Yes, use the contains function:

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

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.