【问题标题】:How to handle youtube ads with robot framework? to skip when theres an ad, wait when i cant skip or just pause if theres none?如何使用机器人框架处理 youtube 广告?在有广告时跳过,在我无法跳过时等待或在没有广告时暂停?
【发布时间】:2022-01-17 14:29:52
【问题描述】:

我想暂停一个 youtube 视频,但有时有一个广告,有时可能没有广告(或者有时有 2 个广告),那么我该如何识别和编码呢?

我目前的代码是这样的

 click video
    Sleep  8s
    Click Button  ${SKIP_ADS_BUTTON}
    Press keys  none  SPACE

但是当没有 id 时它会失败,我不知道如何让它继续或只是等待......有人吗?

ps:我正在使用 SeleniumLibary!

【问题讨论】:

标签: python selenium-webdriver robotframework


【解决方案1】:

我自己找到了答案,我就是这样做的:

  click video
    sleep  12s
    ${isElementExist}     Run Keyword And Return Status    Element Should Be Visible   ${SKIP_ADS_BUTTON}
    Run Keyword If        ${isElementExist}    Run Keyword    click button    ${SKIP_ADS_BUTTON}    
    ...                   ELSE               sleep   15s

【讨论】:

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