Python硒Chrome浏览器驱动程序写入youtube实时评论元素不可交互错误

问题描述 投票:0回答:1

我正在学习python3,我想测试一下如何在YouTube视频上插入实时评论。我写了一些代码并做了一些事情,但是我没有写评论输入任何东西:(给我

元素不可交互错误

下面的我的代码:

item = driver.find_element_by_xpath("//*[@class='style-scope yt-live-chat-message-input-renderer'][6]")
item.click()
item.send_keys('Hello !')
item.send_keys(Keys.CONTROL, Keys.ENTER)

Youtube端html代码;

<div id="container" class="style-scope yt-live-chat-message-input-renderer"><div id="top" class="style-scope yt-live-chat-message-input-renderer"><yt-img-shadow id="avatar" height="24" width="24" class="style-scope yt-live-chat-message-input-renderer no-transition" loaded="" style="background-color: transparent;"><img id="img" class="style-scope yt-img-shadow" alt="" height="24" width="24" src="https://yt3.ggpht.com/-vxNGTdc6GA4/AAAAAAAAAAI/AAAAAAAAAAA/MycNveTNV24/s32-c-k-no-mo-rj-c0xffffff/photo.jpg"></yt-img-shadow><div id="input-container" class="style-scope yt-live-chat-message-input-renderer"><yt-live-chat-author-chip class="style-scope yt-live-chat-message-input-renderer"><span id="author-name" dir="auto" class="style-scope yt-live-chat-author-chip">Zeynep Sevim<span id="chip-badges" class="style-scope yt-live-chat-author-chip"></span></span><span id="chat-badges" class="style-scope yt-live-chat-author-chip"></span></yt-live-chat-author-chip><yt-live-chat-text-input-field-renderer id="input" class="style-scope yt-live-chat-message-input-renderer">

    <label id="label" class="style-scope yt-live-chat-text-input-field-renderer">Bir şey söyleyin... (yavaş mod açık)</label>
    <div id="input" contenteditable="" class="style-scope yt-live-chat-text-input-field-renderer" tabindex="0" aria-invalid="" aria-label="Bir şey söyleyin... (yavaş mod açık)"></div>
    <div id="underline" class="style-scope yt-live-chat-text-input-field-renderer">
      <div id="unfocused" class="style-scope yt-live-chat-text-input-field-renderer"></div>
      <div id="focused" class="style-scope yt-live-chat-text-input-field-renderer"></div>
    </div>
    <iron-dropdown id="dropdown" allow-outside-scroll="" no-auto-focus="" vertical-align="bottom" vertical-offset="24" class="style-scope yt-live-chat-text-input-field-renderer" horizontal-align="left" aria-disabled="false" aria-hidden="true" style="outline: none; display: none;"><!--css-build:shady-->

    <div id="contentWrapper" class="style-scope iron-dropdown">
      <div id="dropdown-content" class="dropdown-content style-scope yt-live-chat-text-input-field-renderer" slot="dropdown-content">
      </div>
    </div>

我在哪里弄错了我不知道,知道吗?

python python-3.x selenium youtube
1个回答
0
投票

'路径'看起来不正确; (您可以在“检查”中搜索它以进行尝试)

item = driver.find_element_by_xpath("//div[@id='input']")
item.click()
item.send_keys('Hello !', Keys.ENTER)
© www.soinside.com 2019 - 2024. All rights reserved.