Python Selenium Send Keys 函数不输入文本

Python Selenium Send Keys function does not input text

我正在尝试使用来自 CSV 的文本输入来填充字段,“发送键”适用于除以下字段之外的所有字段

<div class="col-xs-12 col-md-6">
  <div class="custom-select" data-qa="work-tags" data-testid="work-tags" aria-disabled="false">
    <div class="custom-select__label">Tags</div>
    <div class=" css-2b097c-container">
      <div class=" css-yk16xz-control">
        <div class=" css-1hwfws3">
          <div class=" css-1wa3eu0-placeholder">Select</div>
          <div class="css-1g6gooi">
            <div class="" style="display: inline-block;"><input autocapitalize="none" autocomplete="off" autocorrect="off" id="react-select-10-input" spellcheck="false" tabindex="0" type="text" aria-autocomplete="list" value="" style="box-sizing: content-box; width: 2px; background: 0px center; border: 0px; font-size: inherit; opacity: 1; outline: 0px; padding: 0px; color: inherit;">
              <div
                style="position: absolute; top: 0px; left: 0px; visibility: hidden; height: 0px; overflow: scroll; white-space: pre; font-size: 14px; font-family: &quot;Open Sans&quot;, sans-serif; font-weight: 400; font-style: normal; letter-spacing: normal; text-transform: none;"></div>
          </div>
        </div>
      </div>
      <div class=" css-1wy0on6"><span class=" css-1okebmr-indicatorSeparator"></span>
        <div aria-hidden="true" class=" css-tlfecz-indicatorContainer"><svg height="20" width="20" viewBox="0 0 20 20" aria-hidden="true" focusable="false" class="css-19bqh2r"><path d="M4.516 7.548c0.436-0.446 1.043-0.481 1.576 0l3.908 3.747 3.908-3.747c0.533-0.481 1.141-0.446 1.574 0 0.436 0.445 0.408 1.197 0 1.615-0.406 0.418-4.695 4.502-4.695 4.502-0.217 0.223-0.502 0.335-0.787 0.335s-0.57-0.112-0.789-0.335c0 0-4.287-4.084-4.695-4.502s-0.436-1.17 0-1.615z"></path></svg></div>
      </div>
    </div>
  </div>
</div>
</div>

从UI我可以简单地输入文本并保存。

我尝试了以下但没有用。

driver.find_element_by_xpath("//div[@data-qa='work-tags']//div[@class=' css-2b097c-container']//div[@class=' css-yk16xz-control']").click()
time.sleep(1)
driver.find_element_by_xpath("//div[@data-qa='work-tags']//div[@class=' css-2b097c-container']//div[@class=' css-yk16xz-control']").send_keys(SSID_rows[SSIDs][1],Keys.TAB)

谢谢

您正在尝试将文本放入 div。尝试使用 input 节点:

driver.find_element_by_id("react-select-10-input").send_keys(SSID_rows[SSIDs][1],Keys.TAB)