【问题标题】:Python Selenium deal with an angucomplete elementPython Selenium 处理一个完整的元素
【发布时间】:2022-01-23 12:23:29
【问题描述】:

我手头有一个 selenium 任务,我尝试发送的输入元素给了我一个 ElementNotInteractableException。认为我的输入位于 angucomplete 元素中。好吧,我对 selenium 并不陌生,但找不到解决方案,因此感谢您对此的任何想法或指导

<angucomplete placeholder="" searchfields="" pause="400" set-focus="tpFocus" selectedobject="tpSelected" titlefield="label" inputclass="form-control form-control-small" matchclass="highlight" api="tpApi" disable="disableSearchBox" stockdetails="stockdetails"
  class="ng-isolate-scope">
  <div class="tp-re angucomplete-holder tp-width">
    <div id="fulltextContainer" style="display: none" class="symbol-info tp-etc">
    </div>
    <input id="txt_search" class="search-box tp-co-1 tp-pa-rl-5 tp-re tp-bo-bo" type="text" placeholder="" onmouseup="this.select();" autocomplete="off" />
    <div id="auto-list-container" class="auto-list-container tp-bg-2 tp-co-1 tp-bo-4 tp-bo tp-width angucomplete-dropdown" style="min-width: 300px; display: none">
      <div style="display: none" id="loading" class="tp-h-35 tp-pa-rl-10 angucomplete-searching"></div>
      <div style="display: none" id="norecord" class="tp-35 tp-pa-rl-10 angucomplete-searching"></div>
      <div id="list_dropdown">
      </div>
    </div>
  </div>
</angucomplete>

【问题讨论】:

  • 可以分享做这个的网站吗?
  • 其实这是个股票经纪网站,需要注册等
  • 能否包含有问题的html代码。

标签: python python-3.x selenium input


【解决方案1】:

使用Javascript设置输入字段的值属性。
例如:

elem = driver.find_element_by_tag_name("input")
value = "The text you want to put"
driver.execute_script("arguments[0].setAttribute('value', '{}')".format(value), elem)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-10-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-05-31
    • 2019-11-14
    • 1970-01-01
    • 2022-01-10
    相关资源
    最近更新 更多