Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/flash/4.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 3.x 如何将文本置于段落之间<;p></p>;python/selenium上的标签?_Python 3.x_Selenium_Selenium Chromedriver - Fatal编程技术网

Python 3.x 如何将文本置于段落之间<;p></p>;python/selenium上的标签?

Python 3.x 如何将文本置于段落之间<;p></p>;python/selenium上的标签?,python-3.x,selenium,selenium-chromedriver,Python 3.x,Selenium,Selenium Chromedriver,我在一个网站上测试一些自动化功能,在iframe中遇到了一个标记。我需要在标记之间专门填充一些文本 我已经尝试过使用.text()=“一些文本”,但它不起作用 我也尝试过做.text('some text'),但没有成功 我最近刚开始学习python和selenium,所以出于某种原因,这很难理解 Python代码 from selenium import webdriver browser.get('www.somewebsite.com') iframe = browser.find_ele

我在一个网站上测试一些自动化功能,在
iframe
中遇到了一个
标记。我需要在

标记之间专门填充一些文本

我已经尝试过使用
.text()=“一些文本”
,但它不起作用 我也尝试过做
.text('some text')
,但没有成功

我最近刚开始学习python和selenium,所以出于某种原因,这很难理解

Python代码

from selenium import webdriver
browser.get('www.somewebsite.com')
iframe = browser.find_element_by_id('IFR1')
browser.switch_to.frame(iframe)
browser.find_element_by_tag_name("p").text() = 'this is a txt test'
print('success')
我希望
标记有“这是一个txt文本”,但什么也没有发生

browser.find_element_by_tag_name("p").innerHTML = 'this is a txt test'


经过多次尝试和错误后,我能够使用
ActionChains(浏览器)。发送_键(“这是一个测试”)。执行()
以实现在标记中写入一些文本的功能

您到底想做什么?Selenium主要是一种在网页上执行自动测试的工具;用它来改变页面内容没有多大意义。我实际上是在用excel文件填写我工作的公司使用的表格。除了
iframe
中的文本框外,我可以填充所有其他webelements,当用户在文本框中输入任何文本时,

标记会发生变化感谢您的回复!我尝试了所有三个选项,即使代码运行了所有行,它也没有改变

标记之间的文本。它没有显示任何错误
browser.find_element_by_tag_name("p").innerText = 'this is a txt test'
aEle = browser.find_element_by_tag_name("p")
aEle.setAttribute("innerHTML","this is a txt test")