我想检查我的页面样式是在特定的格式或不像照片为中心,缩略图和示例如果我选择了我的页面显示为缩略图format.First,我已经选择了模板样式,然后我需要断言页面是缩略图样式或not.It动态生成的id和classname.How我可以得到动态生成的className.My代码如下
//Click Thumbnails
pubDriver.findElement(By.cssSelector("img[alt=Template-option-thumbnails]")).click();
pubDriver.findElement(By.id("saveForm")).click();
//Check if the Page has been in thumbnail style template
WebElement thumbnailStyle = wait.until(ExpectedConditions.presenceOfElementLocated(By.className("thumbnails")));
Assert.assertTrue(thumbnailStyle.isDisplayed());
sleep(1000);如果我给出了上面的断言代码,它会抛出以下错误消息。因为我之前应用了样式模板格式,然后我从那里获取了className。
在等待元素存在的10秒后超时: By.className: thumbnails
在应用模板样式格式之后,我得到了以下内容,所以我不知道如何从这里动态获取className
<div ng-class="layout" ng-switch-default="" class="ng-scope thumbnails">
<div ng-switch="" on="layout">
<!-- thumbnails template -->发布于 2015-01-19 15:57:11
您是否有任何其他常量参数的项目,您试图获取?
我将使用另一个选择器来获取项目,并使用类似于
WebElement item = By(//some selector);
String itemClass = item.getAttribute("class");
//assert that class contains thumbnailshttps://stackoverflow.com/questions/28019917
复制相似问题