【问题标题】:Testing Copying/Pasting with RobotFramework使用 RobotFramework 测试复制/粘贴
【发布时间】:2016-07-16 06:01:40
【问题描述】:

我为我想要测试的 Web 应用程序创建了一些自定义复制功能。我找不到任何用于复制或粘贴 in the documentation 的关键字。有这样的东西吗?

【问题讨论】:

  • 我不确定我是否理解这个问题 - RobotFramework 只会管理您的测试,它不会测试您的网站?如果您问如何使用 selenium 和 python 复制和粘贴 - 我已经提供了答案。否则,请编辑您的问题以更清楚,谢谢!
  • 不幸的是,此功能不可用,并且该问题已开放 2 年以上。 github.com/robotframework/SeleniumLibrary/issues/498

标签: selenium robotframework


【解决方案1】:
You can use the following code for copy paste in Robot Framework
1.Install clipboard library using command in CMD : pip install clipboard
2.use code:  
          Copy To Clipboard     ${TextToCopy}       
          Click Element         ${TargetLocator}    
          Press Key             ${TargetLocator}       \\22

【讨论】:

    【解决方案2】:

    您可以使用 Selenium2Library 关键字名称为 Press Key,然后我们可以从 ascii 表中获取值,例如 ASCII Table

    我们可以看到 ctrl+A 十六进制值是 01 - 我们需要点击它来突出显示文本。

    你可以试试这样的

    Copy Text and Paste Text
        [Documentation] 
        ...    CTRL-A -> 1
        ...    Copy-> 03
        ...    Paste -> 16
        Press Key    ${seleniumLocator}    \1    #Highlight the text Ctrl+ A
        Press Key    ${seleniumLocator}    \03    #Copy Text Ctrl + c
        Press Key    ${Some_Other_Locator}   \16  # Paste Text Ctrl+ v
    

    【讨论】:

      【解决方案3】:

      使用 Selenium + python 进行复制和粘贴(使用键盘快捷键):

      Performing-a-copy-and-paste-with-selenium-2

      您还可以创建一个方法来重复使用(例如使用 RobotFramework):

      Paste command using Selenium

      您需要先导入selenium2 library for RobotFramework

      【讨论】:

      • 您正在 Python 本身中混合使用 Robot Framework 和 Selenium 库。你能更具体地解释一下这个例子吗?我不明白,你怎么能直接从 Robot Framework 调用 Selenium 函数。
      • 对不起,我的回答是指出您可以在 Selenium+Python 中编写复制/粘贴脚本(例如)。我不知道 RobotFramework 在实现它方面有限制。从您粘贴的链接中我可以看到,有一个仍然有效的 hack - github.com/robotframework/SeleniumLibrary/issues/…
      【解决方案4】:

      我已经使用 RFW 有一段时间了。我从未听说过您提到的复制/粘贴。

      因此,唯一的方法是根据 python 库自定义您自己的关键字。

      【讨论】:

        【解决方案5】:

        【讨论】:

          猜你喜欢
          • 2021-10-03
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多