RobotFramework做自动化中,能定位到iFrame里面,怎么在iFrame里面输入文字?

摘要:
------------------------------------------------------------------------------发布内容|FAIL|Elementwithlocator'Xpath=//iframe[contains(@id,
01.描述
  • RobotFramework中,能定位到iFrame里面,怎么在iFrame里面输入文字。

如下图:
RobotFramework做自动化中,能定位到iFrame里面,怎么在iFrame里面输入文字?第1张

02.遇到的问题
  • 基本上,不管什么原因的错误,我都记录下来了。
------------------------------------------------------------------------------
帖子内容                                                              | FAIL |
Element with locator 'Xpath=//iframe[contains(@id,'ueditor_0')]' not found.
------------------------------------------------------------------------------
------------------------------------------------------------------------------
帖子内容                                                              | FAIL |
Element with locator 'id=ueditor_0' not found.
------------------------------------------------------------------------------
------------------------------------------------------------------------------
帖子内容                                                              | FAIL |
InvalidElementStateException: Message: invalid element state
(Session info: chrome=83.0.4103.61)
------------------------------------------------------------------------------
帖子内容                                                              | FAIL |
InvalidSelectorException: Message: invalid selector: Unable to locate an element with the xpath expression /html/body'] because of the following error:
SyntaxError: Failed to execute 'evaluate' on 'Document': The string '/html/body']' is not a valid XPath expression.
(Session info: chrome=83.0.4103.61)
------------------------------------------------------------------------------
03.解决
  • 我是用谷歌插件Xpath Helper定位iFrameid="ueditor_0",图中黄色区域是定位的范围。

RobotFramework做自动化中,能定位到iFrame里面,怎么在iFrame里面输入文字?第2张

    def create_variables(self):
        variables = {
            '''此处部分省略,和iFrame没有关系'''
            "${selectFrame}":"Xpath=/html/body",    # 先进入iFrame中
            "${content}": "id:ueditor_0",           # 在找到iFrame中的id
        }
    def teststeps(self):
        '''此处部分省略,和iFrame没有关系'''
        test_05 = self.suite.tests.create("帖子内容")
        # 进入iFrame中
        test_05.keywords.create("Select Frame", args=["${content}"])
        # 找到iFrame的id,录入文字
        test_05.keywords.create("Input Text", args=["${selectFrame}","帖子"])
04.反思
  • 历时8个小时,我感觉我又行了,哈哈哈哈哈。

在我绝望之际,参考了:https://testerhome.com/topics/12766这个博客,给了我很大启发,如下图:
RobotFramework做自动化中,能定位到iFrame里面,怎么在iFrame里面输入文字?第3张

  • 期间查阅的其它资料,虽然没能解决我的问题,还是贴出来,避免遇坑。
  1. stackoverflow:https://stackoverflow.com/questions/51436532/how-to-automate-iframe-text-flied-using-robotframework
    RobotFramework做自动化中,能定位到iFrame里面,怎么在iFrame里面输入文字?第4张

RobotFramework做自动化中,能定位到iFrame里面,怎么在iFrame里面输入文字?第5张

2.CSDN:https://blog.csdn.net/spanthrive12/article/details/52025469

RobotFramework做自动化中,能定位到iFrame里面,怎么在iFrame里面输入文字?第6张

免责声明:文章转载自《RobotFramework做自动化中,能定位到iFrame里面,怎么在iFrame里面输入文字?》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇Spring(七)Spring中的四种增强和顾问CentOS 6.9配置网卡IP/网关/DNS命令详细介绍及一些常用网络配置命令(转)下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

MyBatis/Ibatis中#和$的区别

MyBatis/Ibatis中#和$的区别 1. #将传入的数据都当成一个字符串,会对自动传入的数据加一个双引号。如:order by #user_id#,如果传入的值是111,那么解析成sql时的值为order by "111", 如果传入的值是id,则解析成的sql为order by "id". 2. $将传入的数据直接显示生成在sql中。如:orde...

Mybatis中的association用法

这篇文章我们将来学习一些 association 用法 表结构 DROP TABLE IF EXISTS `student`; CREATE TABLE `student` (  `id` int(11) NOT NULL auto_increment,  `name` varchar(10) NOT NULL,  `gender` cha...

微信小程序:小程序中使用Less

   配置: 首选项 -> 设置 -> 用户 -> 扩展 (找到EasyLess插件,编辑setting.json文件进行配置) 点击vscode左下角的à设置à点击右上角的à添加以上代码(将less文件编译成.wxss文件) 新建index.less文件,内容如下: 编译之后生成index.wxss文件,内容如下: Less语法...

Python爬虫利器二之Beautiful Soup的用法

上一节我们介绍了正则表达式,它的内容其实还是蛮多的,如果一个正则匹配稍有差池,那可能程序就处在永久的循环之中,而且有的小伙伴们也对写正则表达式的写法用得不熟练,没关系,我们还有一个更强大的工具,叫Beautiful Soup,有了它我们可以很方便地提取出HTML或XML标签中的内容,实在是方便,这一节就让我们一起来感受一下Beautiful Soup的强大...

.net 类库如何为类库添加两个框架依赖

需求:为满足一个类库被不同框架的程序调用,需要类库支持多框架 1.新建一个 .netstandard2.0类库项目,名为:TCM.SuperX.YM.Contracts 2.右键点击类库名称,选择“编辑TCM.SuperX.YM.Contracts.csproj” 3.修改TragetFramework标签内容,加入其它框架名称及版本号 原始: 修改后:...

09mybatis属性和数据库字段不匹配处理

Book.java id name price book 表 book_id book_name book_price create table book( book_id int unsigned auto_increment, book_name varchar(20), book_price decimal(8,2), primary key(bo...