2

I want to check my page style is in particular format or not like photocentric,thumbnails etc...For example if I have choosen my page to be displayed as in the thumbnail format.First, i have choosen the template style and then i need to assert the page is in thumbnail style or not.It dynamically generates the id and classname.How can i get the dynamically generated className.My code is like below

//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);

If I give above coding for assertion,it throws the following error message. Because I have applied style template format earlier and then I took className from there.

Timed out after 10 seconds waiting for presence of element located by: By.className: thumbnails

I am getting the following things after applying the template style format,so I don't know how to grab className dynamically from here

    <div ng-class="layout" ng-switch-default="" class="ng-scope thumbnails">
<div ng-switch="" on="layout"> 

 <!-- thumbnails template -->
selvi
  • 1,271
  • 2
  • 21
  • 41

1 Answers1

0

Do you have any other, constant parameters of the item you are trying to fetch?

I would use another selector to get the item and them using something like

WebElement item = By(//some selector);
String itemClass = item.getAttribute("class");
//assert that class contains thumbnails
vlady
  • 477
  • 1
  • 7
  • 14
  • I don't have any constant parameters .The problem is i don't know how to get the locator to point that particular class. – selvi Jan 19 '15 at 08:58
  • then add some constant parameter in the code of the app. that would be the cleaner and most readable solution I know – vlady Jan 19 '15 at 09:16