so basically I'm doing web scraping/website automation,
Here's a simple example of what I'm trying to do:
I'm working on a dynamic page that contains a form, and I want to insert data in this form.
Naturally, this dynamic page changes depending on what I inserted before happening on this page. Here's an example of the input field ID of 5 different pages which I'm trying to insert data in. It is therefore generated automatically, and unique:
- Listing.Item[Chess Size]
- Listing.Item[Shoe Size]
- Listing.Item[Size Trouser]
- Listing.Item[Size]
- Listing.Item[Shoe Size]
The same pattern is the string 'Size' here.
I need to insert data in this field, otherwise, I can't move forward on the form. So here's what I tried:
driver.find_element_by_id('Listing.Item[' + any(str) + 'Size' + any(str) + ']')
But it doesn't work. Maybe I'm wrongly using the function 'any()'.
How can automatically find this unique input in every page I come across, which always contains the string 'Size' in its ID ?
XPath & CSS Selector also contains the other word (for this example: Chess, Shoe, and Trouser) in consequence I can't use them
THANKS for help
EDIT:
Here's the whole corresponding HTML:
<input type="text" id="Listing.Item[Shoe Size]"
name="_st_Shoe Size" size="21" maxlength="50"
aria-required="true" value="">
=> the value of name and id change each time