Академический Документы
Профессиональный Документы
Культура Документы
bubblechart;
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.ThingworxRESTUtils;
/***
* This is the functional test for Bubble Chart Widget.It consists of 5 main
scenarios as follows: 1)Visibility of the existing data point
* tooltip on mouse hover, 2)Creating a new data point, 3)Updating the bubble size,
4)Changed event- DoubleClicked when 'AllowSelection'
* property is enabled, 5)AllowSelection property is disabled.
*
* Story ID : TW-23116.
*
* @author snkulkarni
*
*/
public class BubbleChartTests extends BaseTest {
@BeforeClass(alwaysRun = true)
public void beforeClass() throws UnsupportedEncodingException {
getThingworxRESTUtils().importXmlEntities(TEST_SPECIFIC_ENTITY, true,
ThingworxRESTUtils.HTTP_OK);
navigateToMashupInRuntime(TEST_MASHUP_NAME);
}
@AfterClass(alwaysRun = true)
public void afterClass() throws Exception {
getThingworxRESTUtils().deleteEntitiesByApplicationModelTag(WIDGET_BUBBLE_CHART_MOD
EL_TAG);
}
@BeforeMethod(alwaysRun = true)
public void beforeMethod() throws UnsupportedEncodingException {
getWebdriver().navigate().refresh();
try {
// Wait for the Bubble Chart's numeric entry widget named 'X' to gain
focus automatically.
getPages().mashupRuntimePage().waitForFocusOfWidget(BUBBLE_CHART_NUMERICENTRY_TITLE
D_X_WIDGET_ID);
} catch (Exception e) {
// Safeguard in case the timeout above fails. Just click on the above
numeric entry widget to get the focus explicitly.
getPages().mashupRuntimePage().numericEntryWidget(BUBBLE_CHART_NUMERICENTRY_TITLED_
X_WIDGET_ID).click();
}
}
@Requirements(reqs = { "TW-23116" })
@Test(
description = "6)This test verifies that tooltip is displayed" +
"after hovering the mouse on the existing data point of the
Bubble Chart Widget.",
groups = { "FUNCTIONAL_TESTING", "BUBBLE_CHART" })
public void bubbleChartMouseOverOnExistingDataPointTest() throws Exception {
@Requirements(reqs = { "TW-23116" })
@Test(
description = "This test verifies below scenarios :" +
"7)The tooltip is displayed after hovering the mouse on
newly created data point of the Bubble Chart Widget." +
"8)Updated bubble size gets displayed after hovering the
mouse on above created data point.",
groups = { "FUNCTIONAL_TESTING", "BUBBLE_CHART" })
public void bubbleChartMouseOverOnNewDataPointTest() throws Exception {
// Enter the values for X/Y co-ordinates to get the new Bubble.
for (int coordinateIterator = 0; coordinateIterator < 2;
coordinateIterator++) {
getPages().mashupRuntimePage().numericEntryInput(numericEntryWidgetIds[coordinateIt
erator], "90");
}
getAndVerifyDataPointToolTipValues(BUBBLE_CHART_WITH_ALLOWSELECTION_ENABLED_WIDGET_
ID, EXPECTED_VALUES_FOR_NEW_DATA_POINT,
bubbleRowNumber);
getPages().mashupRuntimePage().numericEntryInput(BUBBLE_CHART_NUMERICENTRY_BUBBLE_S
IZE_WIDGET_ID, "50");
// Fetch and verify tooltip of the above data point with updated bubble
size.
getAndVerifyDataPointToolTipValues(BUBBLE_CHART_WITH_ALLOWSELECTION_ENABLED_WIDGET_
ID, EXPECTED_VALUES_FOR_UPDATED_DATA_POINT,
bubbleRowNumber);
}
@Requirements(reqs = { "TW-23116" })
@Test(
description = "9a)This test verifies that the updated value for the text
box with label 'Test DoubleClicked Event'" +
"gets reset to the 'Default Value' when any bubble is
double clicked." +
"This is applicable when 'AllowSelection' propety is set to
true.",
groups = { "FUNCTIONAL_TESTING", "BUBBLE_CHART" })
public void bubbleChartDoubleClickedEventTest() throws Exception {
// Update and verify the value for textBox widget with label 'Test
DoubleClicked Event'.
updateAndVerifyTextboxWidgetValue(BUBBLE_CHART_WITH_ALLOWSELECTION_ENABLED_WIDGET_I
D,
BUBBLE_CHART_TEXTBOX_FOR_ALLOWSELECTION_ENABLED_WIDGET_ID);
getPages().mashupRuntimePage().textboxWidget(BUBBLE_CHART_TEXTBOX_FOR_ALLOWSELECTIO
N_ENABLED_WIDGET_ID)
.waitForElementAttributeValueToBeEqualTo(VALUE, DEFAULT_VALUE);
// Verify that the textBox with label 'Test DoubleClicked Event' displays
"Default Value" text.
assertEquals(
getPages().mashupRuntimePage().textboxWidget(BUBBLE_CHART_TEXTBOX_FOR_ALLOWSELECTIO
N_ENABLED_WIDGET_ID).getAttribute(VALUE),
DEFAULT_VALUE, "Default value for the textbox widget is not as
expected.");
}
@Requirements(reqs = { "TW-23116" })
@Test(
description = "9b)This test verifies that the updated value for the text
box with label 'Test DoubleClicked Event'" +
"does not get reset to the 'Default Value' when any bubble
is double clicked." +
"This is applicable when 'AllowSelection' propety is set to
false.",
groups = { "FUNCTIONAL_TESTING", "BUBBLE_CHART" })
public void bubbleChartDoubleClickedEventAllowSelectionDisabledTest() throws
Exception {
// Update and verify the value for textBox widget with label 'Not returning
to Default Value'.
updateAndVerifyTextboxWidgetValue(BUBBLE_CHART_WITH_ALLOWSELECTION_DISABLED_WIDGET_
ID,
BUBBLE_CHART_TEXTBOX_FOR_ALLOWSELECTION_DISABLED_WIDGET_ID);
// Verify that the textBox with label 'Test DoubleClicked Event' still
displays the updated text.
assertEquals(
getPages().mashupRuntimePage().textboxWidget(BUBBLE_CHART_TEXTBOX_FOR_ALLOWSELECTIO
N_DISABLED_WIDGET_ID).getAttribute(VALUE),
NOT_A_DEFAULT_VALUE, "Default value for the textbox widget is not
reset.");
}
// This is a private method to fetch and verify the data point values of the
Bubble Chart Widget.
private void getAndVerifyDataPointToolTipValues(String widgetId, String
expectedValue, int bubbleNumber) throws InterruptedException {
getPages().mashupRuntimePage().bubbleChartWidgetToolTip(widgetId).waitForElementToB
ePresent();
// Verify that the tooltip provides the expected Bubble Size, X and Y co-
ordinates.
// TODO : This is a workaround added to get tooltip values through
JavaScript since tooltip is not displaying in some charts. Need
// to revisit and revert after selenium 3.x is deployed
assertEquals(getPages().mashupRuntimePage().getChartTooltipValuesJS(widgetId),
expectedValue,
"Values for Bubble Size , X and Y are not as expected");
}
// This is a private method to update and verify the textBox widget value.
private void updateAndVerifyTextboxWidgetValue(String widgetId, String
textBoxWidgetId) {
// Verify that the textBox with label 'Test DoubleClicked Event' displays
'Default Value' text initially.
assertEquals(getPages().mashupRuntimePage().textboxWidget(textBoxWidgetId).getAttri
bute(VALUE), DEFAULT_VALUE,
"Default value for the textbox widget is not as expected.");
// Update the value in the text-box from 'Default Value' to 'Not a Default
Value'.
getPages().mashupRuntimePage().textBoxInput(textBoxWidgetId,
NOT_A_DEFAULT_VALUE);
assertEquals(getPages().mashupRuntimePage().textboxWidget(textBoxWidgetId).getAttri
bute(VALUE), NOT_A_DEFAULT_VALUE,
"The textbox value is not updated succesfully.");