【问题标题】:How to get IP address for test in Robot Framework?如何在 Robot Framework 中获取用于测试的 IP 地址?
【发布时间】:2023-02-01 17:45:55
【问题描述】:

我需要获取当前用户的 IP 地址才能在测试中使用它。验证它在应用程序表中是否相同。 如何获取IP地址?

没有找到任何相关信息

【问题讨论】:

    标签: robotframework ip-address


    【解决方案1】:

    您可以使用 Evaluate 关键字并将其视为 python 问题。使用 answer 中的解决方案,您的解决方案可能如下所示:

    *** Test Cases ***
    
    Example 
        ${config}=    Evaluate    [l for l in ([ip for ip in socket.gethostbyname_ex(socket.gethostname())[2] if not ip.startswith("127.")][:1], [[(s.connect(('8.8.8.8', 53)), s.getsockname()[0], s.close()) for s in [socket.socket(socket.AF_INET, socket.SOCK_DGRAM)]][0][1]]) if l][0][0]    socket
        Log    ${config}
    

    【讨论】:

      猜你喜欢
      • 2022-11-01
      • 2022-08-20
      • 2014-05-08
      • 2014-06-29
      • 1970-01-01
      • 2010-12-26
      • 2019-09-03
      • 2020-10-07
      相关资源
      最近更新 更多