【问题标题】:How to perform an integration test with the Opentok API?如何使用 Opentok API 执行集成测试?
【发布时间】:2015-12-30 00:09:46
【问题描述】:

我们将 OpenTok API 用于 P2P 视频,并希望自动化测试 - 最好使用 capybara/cucumber。

是否有命令观察发布者/订阅者 div 以查看其发布/接收视频?

【问题讨论】:

  • 请将引用的div添加到问题中,使用selenium可以获取html元素的属性并验证它是发布还是接收视频。
  • 您不能只使用示例 ID 来回答吗?假设在这种情况下,发布者 div 的 ID 为“发布者”。

标签: selenium testing cucumber capybara integration-testing


【解决方案1】:

您可以使用 getAttribute 方法获取 html 元素的 Id,如下所述:

// use any locator to find the element you are targeting, for e.g. xpath 
WebElement element = driver.findElement(By.XPath("Your Element Xpath"));
String value = element.getAttribute("id");

if (value.equals("publisher")){
    // actions to be done when the status is publisher
} else if(value.equals("subscriber")) {
    // actions to be done when the status is subscriber
} else {
    // unknown state
}

【讨论】:

  • 这个问题与发现 div 是否正在发送/接收视频有关。我首先捕获 div 没有问题。
  • 如果要查看视频是否正在流式传输/发布/订阅,则未配备硒。通常,这些类型测试将基于应用程序设置的 html 属性或 javascript 值完成,并在这些条件下断言,我已将其编译为答案。我从未使用过 OpenTok,但您可能会在查看测试 repo github.com/aullman/opentok-test-scripts 时得到帮助
猜你喜欢
  • 2017-01-24
  • 2017-12-21
  • 1970-01-01
  • 1970-01-01
  • 2011-09-24
  • 1970-01-01
  • 2019-09-24
  • 1970-01-01
  • 2019-05-21
相关资源
最近更新 更多