首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在码头集装箱中运行时,与获取时间和比较相关的测试失败

在码头集装箱中运行时,与获取时间和比较相关的测试失败
EN

Stack Overflow用户
提问于 2022-06-02 02:16:13
回答 1查看 47关注 0票数 0

我有一个脚本,它使用GET时间并在后面进行比较。

测试在我的本地机器上通过,打印的时间与我的机器时间相同,例如: 09:37:57是在我的机器显示上午9点时打印的。

但是,当我在码头容器中运行测试时,测试失败了,打印的时间是01:37:57。

我是否应该在docker中设置一些东西,使其使用与我的服务器/应用程序时区相同的时区?

如何解决这样的问题,由于码头集装箱的格式不同,比较测试失败。

代码语言:javascript
复制
Get Current Audio Upload Time
    ${time}=      Get Current Date
    ${current-time}=      Convert Date      ${time}      result_format=%H:%M:%S
    Log To Console     time when uploading audio is ${current-time}
    Set Global Variable    ${current-time}

使用上面的时间来比较在网页上显示的时间。

代码语言:javascript
复制
Verify Audio Time
    ${time-elem}    Get Table Cell Element   .ant-table-content > table   "Time"    "Dual-Channel-Audio-${RandomNumber}"
    ${UI-time}     Get Text    ${time-elem}
    Log To Console   time displayed at UI is ${UI-time}

    ${time-substract-result}=  Subtract Time From Time     ${UI-time}    ${current-time}
    Log To Console    subtract time is ${time-substract-result}
    Run Keyword And Continue On Failure    Should Be True   ${time-substract-result} <= 300    time displayed at UI is more than 5 seconds than expected time
EN

回答 1

Stack Overflow用户

发布于 2022-06-02 03:02:52

我刚刚尝试在Dockerfile中设置它,并解决了问题。

代码语言:javascript
复制
ENV TZ 'Asia/Singapore'
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72469928

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档