我希望我正确地问了这个问题。我附上了我保存的个人帐户的链接,希望它能打开。
我需要通过 id="react-select-16-input" 找到页面上的输入元素(这是“对象选择” -> 对面是地籍号码输入字段,这就是我需要找到的)。问题是每次 id="react-select-16-input" 都会更改为随机数(不是 16,而是 4 或 20 等)。
当你打开文件时,页面上的 id="react-select-16-input" 元素是这样的:

我正在考虑这样做,找到 class="rros-ui-lib-dropdown__value-container css-1hwfws3" 元素,该元素位于我需要的元素上方(如果您查看浏览器中的开发人员工具),然后使用它从 id="react-select-16-input" (即“react-select-”)中查找部分文本,它找到它,但不想输入或接受它(一般来说 send_keys('52: 18:0060182:759'))。它给出了错误“selenium.common.exceptions.ElementNotInteractableException:消息:元素不可交互”,特别是在 send_keys('52:18:0060182:759') 上
这是我的代码
element = browser.find_element(By.CSS_SELECTOR, '#realEstateItems > div > div.real-estate-selector-base > div > label > div > div.rros-ui-lib-dropdown-container.css-2b097c-container > div > div.rros-ui-lib-dropdown__value-container.css-1hwfws3')
if element.find_element(By.XPATH, '//*[contains(@id,"react-select-")]'):
print('yes')
element.send_keys('52:18:0060182:759')
请帮帮我
呵呵……终于明白了……
这是我需要的代码