I'm testing a webpage with Selenium WebDrive and want to make an assertion on a JavaScript file but not sure how.
I want to assert that servers (an array) is of length 2.
My JavaScript file config.js contains the following array I wish to assert is present:
var location = location || {};
location.Config = {
servers: [
{name: "a"},
{name: "b"}
]
}
My first attempt was to use className but didn't do the trick:
Assert.assertThat(webDriver
.findElement(className("config.js"))
.getAttribute("servers")
.length(),
Matchers.is(2));