Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/361.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python selenium-JS发送_键或设置值不起作用_Python_Selenium_Selenium Webdriver_Automation_Automated Tests - Fatal编程技术网

Python selenium-JS发送_键或设置值不起作用

Python selenium-JS发送_键或设置值不起作用,python,selenium,selenium-webdriver,automation,automated-tests,Python,Selenium,Selenium Webdriver,Automation,Automated Tests,HTML代码: <div class='UEclfJ _27cR_W'> <input type ='tel' autocomplete='one-time-code' maxlength = '6'> <input class='_1y306T _2ynKud' maxlength = '1'reandonly value> <input class='_1y306T' maxlength = '1'reandonly value> <i

HTML代码:

<div class='UEclfJ _27cR_W'>
<input type ='tel' autocomplete='one-time-code' maxlength = '6'>

<input class='_1y306T _2ynKud' maxlength = '1'reandonly value>
<input class='_1y306T' maxlength = '1'reandonly value>
<input class='_1y306T' maxlength = '1'reandonly value>
<input class='_1y306T' maxlength = '1'reandonly value>
<input class='_1y306T' maxlength = '1'reandonly value>
<input class='_1y306T' maxlength = '1'reandonly value>

</div>
有人能帮我解决这个问题或给我一些想法吗?我非常感谢:
谢谢关心我的问题。

此代码似乎起到了作用:

number_input = driver.find_element_by_xpath('//input[@type="tel"]')
number_input.find_element_by_xpath('./following-sibling::input').click()
number_input.send_keys('123456')

说明:要通过输入数字,您需要单击要与之交互的第一个单元格

元素不是文本输入字段!为什么要更改其值?我搜索了一些类似这样的主题,解决方案是删除此属性,它可以是send_key。但是,我的问题的此解决方案失败。你能帮我吗?我不知道这个解决方案是从哪里来的,但如果你想像用户那样通过WebDriver与UI交互,显然,从HTML中删除属性是错误的方法。如何将_键发送到不是文本输入字段的元素,兄弟:你需要找到合适的输入字段并向其发送键
number_input = driver.find_element_by_xpath('//input[@type="tel"]')
number_input.find_element_by_xpath('./following-sibling::input').click()
number_input.send_keys('123456')