zoukankan      html  css  js  c++  java
  • RobotFramework做自动化中,能定位到iFrame里面,怎么在iFrame里面输入文字?

    01.描述
    • RobotFramework中,能定位到iFrame里面,怎么在iFrame里面输入文字。

    如下图:

    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",图中黄色区域是定位的范围。

        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这个博客,给了我很大启发,如下图:

    • 期间查阅的其它资料,虽然没能解决我的问题,还是贴出来,避免遇坑。
    1. stackoverflow:https://stackoverflow.com/questions/51436532/how-to-automate-iframe-text-flied-using-robotframework

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

  • 相关阅读:
    Tenserflow学习日记(13)
    Tenserflow学习日记(12)
    Tenserflow学习日记(10)
    利用file_get_contents();抓取网络上需要的信息
    laravel5.4自定义验证规则
    getimagesize();获取图片的长度与宽度
    php得到程序的执行时间
    laravel 处理图片
    siege 压力测试工具的安装与使用
    laravel 实现点赞功能
  • 原文地址:https://www.cnblogs.com/by-eleven/p/13329436.html
Copyright © 2011-2022 走看看