So the following code has ID's for each button but they are dynamic every refresh and I've tried using maleBtn = driver.find_element_by_xpath('//button[text()="Male"]').click()
however that doesn't seem to select or click the button.
<div id="759f1410-6451-4e18-8ef7-641692381f54" class="gender-buttons gender component">
<div class="shim"></div>
<div class="error"></div>
<label for="27be9dfd-67f6-4fc1-8e7d-cf18edad0b6d">Gender</label>
<input type="hidden" id="27be9dfd-67f6-4fc1-8e7d-cf18edad0b6d" value="" name="gender" data-componentname="gender">
<ul data-componentname="gender">
<li id="c5348cb4-3dd3-4841-8bec-d41523d16d11" class="">
<input type="button">
<span>Male</span>
</li>
<li id="fd7b0bd9-0c59-41be-8b5c-fbbe1e97ba9b" class="">
<input type="button">
<span>Female</span>
</li>
</ul>
<div class="tip">Please select a preference.</div>
</div>
Any thoughts of making this work?
question from:https://stackoverflow.com/questions/65546174/how-can-selenium-click-a-button-with-a-dynamic-id