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
Yes, use the contains
function:
//*[contains(@id, 'sub_allGoods_')]
answered Aug 20, 2017 at 17:54
-
@user8459020 no problem, can you accept my reply as answer so the question doesn't remain open?FDM– FDM2017年08月20日 18:10:53 +00:00Commented Aug 20, 2017 at 18:10