Selenium [Python]如何在隐藏的输入上插入值?

时间:2020-04-14 06:30:18

标签: python python-3.x selenium selenium-webdriver

我正在尝试管理https://www.vocabulary.com/中的单词列表。 但是,我不知道如何在列表中添加一个单词。 网站页面源类似于:

<input type="hidden" id="entryTemplate" value="&lt;li class=&#034;entry&#034; &gt;
    &lt;a tabindex=&#034;-1&#034; class=&#034;deleteEntry ss-delete&#034; title=&#034;delete this entry&#034; href=&#034;javascript:void(0)&#034;&gt;&lt;/a&gt;
    &lt;div class=&#034;field word&#034;&gt;&lt;input class=&#034;wordInput&#034; type=&#034;text&#034; value=&#034;&#034; autocapitalize=&#034;off&#034; placeholder=&#034;add a word&#034;&gt;&lt;/div&gt;
    &lt;div class=&#034;field definition&#034;&gt;&lt;/div&gt;
    &lt;div class=&#034;notesAndExamples grid grid-2 responsive&#034;&gt;
        &lt;div class=&#034;col examples&#034;&gt;
            &lt;label&gt;Example Sentence:&lt;/label&gt;
            &lt;div class=&#034;value&#034;&gt;
                &lt;textarea placeholder=&#034;Write your own example sentence...&#034;&gt;&lt;/textarea&gt;
                &lt;button class=&#034;remove&#034; &gt;&lt;i class=&#034;ss-delete&#034;&gt;&lt;/i&gt; Remove Example&lt;/button&gt;               
            &lt;/div&gt;
            &lt;button class=&#034;browseExamples&#034;&gt;&lt;i class=&#034;ss-openbook icon&#034;&gt;&lt;/i&gt; Browse Example Sentences&lt;/button&gt;                           
        &lt;/div&gt;
        &lt;div class=&#034;col notes&#034;&gt;
            &lt;label&gt;Notes:&lt;/label&gt;
            &lt;textarea maxlength=&#034;500&#034;&gt;&lt;/textarea&gt;
        &lt;/div&gt;        
    &lt;/div&gt;
&lt;/li&gt;" >

当我尝试将单词添加到列表中

inputWord = driver.find_element_by_id("entryTemplate")
inputWord.click()
inputWord.send_keys('expire')

输出

回溯(最近通话最近): 在第16行的文件“ c:/MY_WORK/autoEnglish/Selenium.py” inputWord.click() 单击文件“ C:\ Users \ jatian \ AppData \ Local \ Programs \ Python \ Python38 \ lib \ site-> packages \ selenium \ webdriver \ remote \ webelement.py”,单击行80 self._execute(Command.CLICK_ELEMENT) _execute中的第633行的文件“ C:\ Users \ jatian \ AppData \ Local \ Programs \ Python \ Python38 \ lib \ site-packages \ selenium \ webdriver \ remote \ webelement.py” 返回self._parent.execute(command,params) 在执行的文件“ C:\ Users \ jatian \ AppData \ Local \ Programs \ Python \ Python38 \ lib \ site-packages \ selenium \ webdriver \ remote \ webdriver.py”中执行 self.error_handler.check_response(响应) 文件“ C:\ Users \ jatian \ AppData \ Local \ Programs \ Python \ Python38 \ lib \ site-packages \ selenium \ webdriver \ remote \ errorhandler.py”,行242,在check_response中 引发exception_class(消息,屏幕,堆栈跟踪) selenium.common.exceptions.ElementNotInteractableException:消息:元素不可交互 (会话信息:chrome = 81.0.4044.92)

0 个答案:

没有答案