Sunteți pe pagina 1din 2

package com.twx.ux.composer.classic.mashup.widgets.

containedmashup;

import java.io.UnsupportedEncodingException;

import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import com.twx.base.BaseTest;
import com.twx.common.requirements.Requirements;
import com.twx.common.utilities.ScreenCapture;
import com.twx.common.utilities.ThingworxRESTUtils;

/**
* This class verifies the Contained Mashup Widget by capturing screenshots for
different testing scenarios for visual comparisons.
* Scenarios include: 1> Checkbox widget enabled, contained mashup visibility test
2> Checkbox widget disabled, contained mashup
* invisibility test & Contained mashup responsive layout test
*
* Support Story TW-23085.
*
* @author rraj
*
*/

public class VisualContainedMashupTests extends BaseTest {

public static final String TEST_ENTITIES_FILE_NAME =


"Widgets_ContainedMashup_Entities.xml";

public static final String AUTOMATION_CONTAINED_MASHUP =


"Widgets_ContainedMashup_VisualTests";

public static final String CHECKBOX_VISIBLE_WIDGET = "checkbox-16";

public static final String CONTAINED_TOP_TEXTBOX_WIDGET = "mashupcontainer-


13_textbox-2";

public static final String CONTAINED_BOTTOM_TEXTBOX_WIDGET = "mashupcontainer-


17_textbox-2";

public static final String ENTITY_APPLICATION_MODEL_TAG_NAME =


"Widgets_ContainedMashup";

@BeforeClass(alwaysRun = true)
public void beforeClass() throws Exception {
// Import entities
getThingworxRESTUtils().importXmlEntities(TEST_ENTITIES_FILE_NAME, true,
ThingworxRESTUtils.HTTP_OK);
navigateToMashupInRuntime(AUTOMATION_CONTAINED_MASHUP);

getPages().mashupRuntimePage().waitForFocusOfWidget(CONTAINED_TOP_TEXTBOX_WIDGET);
// We are taking an AS-IS Screenshot here
ScreenCapture.captureScreenshot(webdriver.getWebDriver(),
getScreenshotDestination(1, "ContainedStaticMashupResponsiveLayoutTest"));
}
@BeforeMethod(alwaysRun = true)
public void beforeMethod() throws UnsupportedEncodingException {
getWebdriver().navigate().refresh();
// Wrapping in a try catch in case of a timeout failure and clicking on the
Widget if the wait fails
try {
// Inspect the Numeric Entry and determine which attribute name and its
full value become when the Widget has focus

getPages().mashupRuntimePage().waitForFocusOfWidget(CONTAINED_TOP_TEXTBOX_WIDGET);
} catch (Exception ex) {

getPages().mashupRuntimePage().numericEntryWidget(CONTAINED_TOP_TEXTBOX_WIDGET).cli
ck();
}
}

@Requirements(reqs = { "TW-25365" })
@Test(
description = "Verify contained mashup invisibility on checkbox widget
disable test",
groups = { "VISUAL_TESTING", "CONTAINED_MASHUP" })
public void verifyContainedMashupNonVisibleOnCheckboxDisableTest() throws
Exception {

getPages().mashupRuntimePage().checkBoxWidget(CHECKBOX_VISIBLE_WIDGET).click();

getPages().mashupRuntimePage().numericEntryWidget(CONTAINED_BOTTOM_TEXTBOX_WIDGET).
waitForInvisibilityOfElement();
ScreenCapture.captureScreenshot(webdriver.getWebDriver(),
getScreenshotDestination(1, "Invisible"));
}

@AfterClass(alwaysRun = true)
public void afterClass() throws Exception {
// Delete entities created for test class

getThingworxRESTUtils().deleteEntitiesByApplicationModelTag(ENTITY_APPLICATION_MODE
L_TAG_NAME);
}
}

S-ar putea să vă placă și