Professional Documents
Culture Documents
checkbox;
import java.io.UnsupportedEncodingException;
import org.testng.Assert;
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.ThingworxRESTUtils;
/***
* This is the functional test for Checkbox widget. It includes testing three main
scenarios- 1)Checkbox click triggers event
* i.e.hides/unhides textbox 2)Checkbox click triggers event i.e. resets Textbox
value to default 3)Checks whether DisabledCheckbox can be
* clicked to check it
*
* @author pbiswas
*
*/
public class CheckboxTests extends BaseTest {
@BeforeClass(alwaysRun = true)
public void beforeClass() throws UnsupportedEncodingException {
// Import Test specific entity
getThingworxRESTUtils().importXmlEntities(TEST_SPECIFIC_ENTITY, true,
ThingworxRESTUtils.HTTP_OK);
}
@AfterClass(alwaysRun = true)
public void afterClass() throws Exception {
getThingworxRESTUtils()
.deleteEntitiesByModelTags("{\"tags\":
[{\"vocabulary\": \"Applications\", \"vocabularyTerm\": \"VisualTest_Checkbox\"}]}"
);
}
getPages().mashupRuntimePage().pointerToCheckbox(STATECHECKED_CHECKBOX_WIDGET_ID_NU
MBER).waitForVisibilityOfElement();
}
@Requirements(reqs = { "TW-23059" })
@Test(
description = "This test verifies another widget hides and unhides based on
checkbox click",
groups = { "FUNCTIONAL_TESTING", "CHECKBOX" })
public void checkboxClickHideShowAnotherWidgetTest() throws Exception {
Assert.assertEquals(getPages().mashupRuntimePage().textboxInputforMashupWithCheckbo
x(TRUE_TEXTBOX_WIDGET_ID_NUMBER).isDisplayed(),
true, "The TextBox with 'true' value in it is not displayed.");
getPages().mashupRuntimePage().pointerToCheckbox(STATECHECKED_CHECKBOX_WIDGET_ID_NU
MBER).click();
Assert.assertEquals(getPages().mashupRuntimePage().textboxInputforMashupWithCheckbo
x(TRUE_TEXTBOX_WIDGET_ID_NUMBER).isDisplayed(),
false, "The TextBox with 'true' value in it is not invisible.");
getPages().mashupRuntimePage().pointerToCheckbox(STATECHECKED_CHECKBOX_WIDGET_ID_NU
MBER).click();
}
getPages().mashupRuntimePage().textboxInputforMashupWithCheckbox(INPUTIN_TEXTBOX_WI
DGET_ID_NUMBER).getAttribute("value"),
"This is the default text.", "The TextBox does not have default value
in it.");
getPages().mashupRuntimePage().textboxInputforMashupWithCheckbox(INPUTIN_TEXTBOX_WI
DGET_ID_NUMBER).click();
getPages().mashupRuntimePage().textboxInputforMashupWithCheckbox(INPUTIN_TEXTBOX_WI
DGET_ID_NUMBER).clear();
getPages().mashupRuntimePage().textboxInputforMashupWithCheckbox(INPUTIN_TEXTBOX_WI
DGET_ID_NUMBER).sendKeys(TEXT_TO_ADD);
getPages().mashupRuntimePage().textboxInputforMashupWithCheckbox(INPUTIN_TEXTBOX_WI
DGET_ID_NUMBER).getAttribute("value"),
TEXT_TO_ADD, "The TextBox is not set to desired value.");
getPages().mashupRuntimePage().pointerToCheckbox(STATECHECKED_CHECKBOX_WIDGET_ID_NU
MBER).click();
getPages().mashupRuntimePage().textboxInputforMashupWithCheckbox(INPUTIN_TEXTBOX_WI
DGET_ID_NUMBER).getAttribute("value"),
"This is the default text.", "TextBox has not being reset to default
value");
}
@Requirements(reqs = { "TW-23059" })
@Test(
description = "This test verifies whether Disabled attribute checkbox can
be checked/selected.",
groups = { "FUNCTIONAL_TESTING", "CHECKBOX" })
public void disabledAttributeTest() throws Exception {
getPages().mashupRuntimePage().pointerToCheckbox(DISABLED_CHECKBOX_WIDGET_ID_NUMBER
).mouseOver();
getPages().mashupRuntimePage().pointerToCheckbox(DISABLED_CHECKBOX_WIDGET_ID_NUMBER
).click();
Assert.assertEquals(getPages().mashupRuntimePage().pointerToCheckbox(DISABLED_CHECK
BOX_WIDGET_ID_NUMBER).isSelected(), false,
"Disabled Checkbox does not have disabled tag in it");
}
}