• <legend id='9Mhow'><style id='9Mhow'><dir id='9Mhow'><q id='9Mhow'></q></dir></style></legend>

      • <bdo id='9Mhow'></bdo><ul id='9Mhow'></ul>
        <i id='9Mhow'><tr id='9Mhow'><dt id='9Mhow'><q id='9Mhow'><span id='9Mhow'><b id='9Mhow'><form id='9Mhow'><ins id='9Mhow'></ins><ul id='9Mhow'></ul><sub id='9Mhow'></sub></form><legend id='9Mhow'></legend><bdo id='9Mhow'><pre id='9Mhow'><center id='9Mhow'></center></pre></bdo></b><th id='9Mhow'></th></span></q></dt></tr></i><div id='9Mhow'><tfoot id='9Mhow'></tfoot><dl id='9Mhow'><fieldset id='9Mhow'></fieldset></dl></div>
        <tfoot id='9Mhow'></tfoot>
      1. <small id='9Mhow'></small><noframes id='9Mhow'>

      2. 发送密钥不起作用 selenium webdriver python

        时间:2023-07-04

        <small id='97GJx'></small><noframes id='97GJx'>

        <legend id='97GJx'><style id='97GJx'><dir id='97GJx'><q id='97GJx'></q></dir></style></legend>
      3. <i id='97GJx'><tr id='97GJx'><dt id='97GJx'><q id='97GJx'><span id='97GJx'><b id='97GJx'><form id='97GJx'><ins id='97GJx'></ins><ul id='97GJx'></ul><sub id='97GJx'></sub></form><legend id='97GJx'></legend><bdo id='97GJx'><pre id='97GJx'><center id='97GJx'></center></pre></bdo></b><th id='97GJx'></th></span></q></dt></tr></i><div id='97GJx'><tfoot id='97GJx'></tfoot><dl id='97GJx'><fieldset id='97GJx'></fieldset></dl></div>

          <tfoot id='97GJx'></tfoot>

              <bdo id='97GJx'></bdo><ul id='97GJx'></ul>
                <tbody id='97GJx'></tbody>
                  本文介绍了发送密钥不起作用 selenium webdriver python的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我需要将文本发送到描述文本区域.有一些预定义的文本在点击后被清除.我尝试在 sendkeys 之前使用 clear() 或 click() ,但没有任何效果.它会在那里发送文本,但它仍然是灰色的,保存页面后出现描述中没有文本的错误...我可以使用其他东西代替发送密钥吗?谢谢

                  I need to send text to description textarea. There is some predefined text which is cleared after click. I tried to use clear() or click() before sendkeys but nothing works correctly. It will send text there but it is still grey and after saving page there is error that tere is no text in description... Can I use something else instead of send keys? Thanks

                  文本区域看起来像:

                  <textarea id="manage_description" class="eTextArea" name="e.description" cols="" rows="" onfocus="clearDescHint(this);" onblur="resetDescHint(this);" style="color: grey;"></textarea>
                  

                  send_keys 不起作用

                  send_keys not working

                  self.driver.find_element_by_id('manage_description').send_keys("TEST")
                  

                  推荐答案

                  正如你提到的 send_keys("TEST") 不起作用,有几个替代方案将 字符序列 发送到如下所述的各个字段:

                  As you mentioned send_keys("TEST") are not working, there are a couple of alternatives to send a character sequence to respective fields as mentioned below :

                  1. 使用Keys.NUMPAD3 [模拟send_keys("3")]:p>

                  login.send_keys(Keys.NUMPAD3)
                  

                • JavascriptExecutorgetElementById 一起使用:

                • Use JavascriptExecutor with getElementById :

                  self.driver.execute_script("document.getElementById('login_email').value='12345'")
                  

                • JavascriptExecutorgetElementsById 一起使用:

                • Use JavascriptExecutor with getElementsById :

                  self.driver.execute_script("document.getElementsById('login_password')[0].value='password'")
                  

                • <小时>

                  现在谈到你的具体问题,正如你提到的 我尝试在 sendkeys 之前使用 clear() 或 click() 但没有任何效果,所以我们将寻求 的帮助javascriptclick()在文本区域清除预定义文本然后使用send_keys 填充文本字段,如下所示:


                  Now comming to your specific issue, as you mentioned I tried to use clear() or click() before sendkeys but nothing works correctly, so we will take help of javascript to click() on the text area to clear the predefined text and then use send_keys to populate the text field as follows:

                  self.driver.execute_script("document.getElementById('manage_description').click()")
                  self.driver.find_element_by_id('manage_description').send_keys("TEST")
                  

                  更新:

                  正如您有时提到的,有时它会起作用,所以我建议如下:

                  Update :

                  As you mentioned sometimes it works sometimes not, so I would suggest the following:

                  1. 诱导 ExplicitWait 使 textarea 可点击.
                  2. 也可以使用 javascripttextarea 内发送 text.
                  3. 您的代码将如下所示:

                  1. Induce ExplicitWait for textarea to be clickable.
                  2. Use javascript to send the text within the textarea too.
                  3. Your code will look like:

                  my_string = "TEST";
                  elem = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "manage_description")))
                  self.driver.execute_script("document.getElementById('manage_description').click()")
                  self.driver.execute_script("arguments[0].setAttribute('value', '" + my_string +"')", elem);
                  

                  这篇关于发送密钥不起作用 selenium webdriver python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:Python WebDriver如何打印整个页面源(html) 下一篇:接受带有 marionette firefox webdrive python splinter 的 ssl 证书

                  相关文章

                • <small id='ReTiq'></small><noframes id='ReTiq'>

                  • <bdo id='ReTiq'></bdo><ul id='ReTiq'></ul>

                  1. <legend id='ReTiq'><style id='ReTiq'><dir id='ReTiq'><q id='ReTiq'></q></dir></style></legend>
                  2. <tfoot id='ReTiq'></tfoot>
                  3. <i id='ReTiq'><tr id='ReTiq'><dt id='ReTiq'><q id='ReTiq'><span id='ReTiq'><b id='ReTiq'><form id='ReTiq'><ins id='ReTiq'></ins><ul id='ReTiq'></ul><sub id='ReTiq'></sub></form><legend id='ReTiq'></legend><bdo id='ReTiq'><pre id='ReTiq'><center id='ReTiq'></center></pre></bdo></b><th id='ReTiq'></th></span></q></dt></tr></i><div id='ReTiq'><tfoot id='ReTiq'></tfoot><dl id='ReTiq'><fieldset id='ReTiq'></fieldset></dl></div>