Selenium 如何使用Opentok API执行集成测试?

Selenium 如何使用Opentok API执行集成测试?,selenium,testing,cucumber,capybara,integration-testing,Selenium,Testing,Cucumber,Capybara,Integration Testing,我们正在为P2P视频使用OpenTok API,并希望自动化测试——最好使用capybara/cucumber 是否有命令来观察发布者/订阅者div以查看其是否发布/接收视频?您可以使用getAttribute方法获取html元素的Id,如下所述: // use any locator to find the element you are targeting, for e.g. xpath WebElement element = driver.findElement(By.XPath("Y

我们正在为P2P视频使用OpenTok API,并希望自动化测试——最好使用capybara/cucumber


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

您可以使用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添加到问题中,使用selenium您可以获取html元素的属性,并验证它是否正在发布或接收视频。您不能使用示例ID回答吗?在本例中,假设publisher div的ID为“publisher”。问题涉及发现div是否正在发送/接收视频。首先,我对捕获div没有问题。如果要查看视频是否为流媒体/发布/订阅,selenium没有配备。通常,这些类型测试将基于应用程序设置的html属性或javascript值进行,并根据这些条件进行断言,我已编译为答案。我从未使用过OpenTok,但您可能会在查看测试报告时得到帮助