List of usage examples for java.lang Error toString
public String toString()
From source file:de.nmichael.efa.Daten.java
private static void iniEnvironmentSettings() { if (Logger.isTraceOn(Logger.TT_CORE, 9) || Logger.isDebugLoggingActivatedByCommandLine()) { Logger.log(Logger.DEBUG, Logger.MSG_CORE_STARTUPINITIALIZATION, "iniEnvironmentSettings()"); }/*from w ww .j av a 2 s. com*/ String s; try { if (applID == APPL_EFABH) { Daten.efa_java_arguments = System.getenv(Daten.EFA_JAVA_ARGUMENTS); if (Logger.isTraceOn(Logger.TT_CORE)) { Logger.log(Logger.DEBUG, Logger.MSG_DEBUG_GENERIC, Daten.EFA_JAVA_ARGUMENTS + "=" + Daten.efa_java_arguments); } } } catch (Error e) { Logger.log(Logger.WARNING, Logger.MSG_WARN_CANTGETEFAJAVAARGS, "Cannot get Environment Variable " + Daten.EFA_JAVA_ARGUMENTS + ": " + e.toString()); } try { s = System.getenv(EFACREDENVVAR); if (s != null && s.length() > 0) { EFACREDFILE = s; } else { EFACREDFILE = Daten.userHomeDir + EFACREDFILE; } } catch (Exception e) { Logger.logdebug(e); } try { if ((new File(EFALIVE_VERSIONFILE).exists())) { EFALIVE_VERSION = ""; BufferedReader f = new BufferedReader(new FileReader(EFALIVE_VERSIONFILE)); s = f.readLine(); if (s != null) { EFALIVE_VERSION = s.trim(); } f.close(); } } catch (Exception e) { Logger.logdebug(e); } }
From source file:com.zentri.otademo.ZentriOSBLEService.java
private void onBLEError(Error error) { mFinishOnClose = true;/* w ww . ja v a 2 s. com*/ Log.d(TAG, "BLE Error - " + error.toString()); switch (error) { case CONNECT_WITHOUT_REQUEST: //reconnect, no need for error mFinishOnClose = false; break; case DISCONNECT_WITHOUT_REQUEST: //connection lost mError = R.string.error_connection_lost_message; break; case INVALID_MODE: //internal error - invalid connection mode mError = R.string.error_invalid_con_mode; break; case NO_TX_CHARACTERISTIC: case NO_RX_CHARACTERISTIC: case NO_MODE_CHARACTERISTIC: //cant communicate with device mError = R.string.device_error_message; break; case NO_CONNECTION_FOUND: //Connected to service, but device not connected mError = R.string.error_connection_lost_message; break; case NULL_GATT_ON_CALLBACK: mError = R.string.error_null_gatt_on_callback; break; case NULL_CHAR_ON_CALLBACK: mError = R.string.error_null_gatt_on_callback; break; case DATA_READ_FAILED: mError = R.string.error_data_read_failed; mFinishOnClose = false; break; case DATA_WRITE_FAILED: mError = R.string.error_data_write_failed; mFinishOnClose = false; break; case MODE_READ_FAILED: mError = R.string.error_mode_set_read_failed; mFinishOnClose = false; break; case MODE_WRITE_FAILED: mError = R.string.error_mode_set_write_failed; mFinishOnClose = false; break; case SET_TX_NOTIFY_FAILED: mError = R.string.error_set_tx_notify_failed; mFinishOnClose = false; break; case SET_OTA_CONTROL_NOTIFY_FAILED: mError = R.string.error_set_ota_control_notify_failed; break; case SERVICE_DISCOVERY_FAILED: mError = R.string.error_service_disc; break; case VERSION_READ_FAILED: mError = R.string.error_version_read_failed; mFinishOnClose = false; break; default: mError = R.string.error_unexpected; mFinishOnClose = false; break; } if (mError != ERROR_MSG_NONE) { sendError(mError, mFinishOnClose); } }
From source file:com.samsung.trailmix.multiscreen.MultiscreenManager.java
/** * Makes connection to the TV and start the application on the TV * if the current service is available./*from www. j a v a 2 s . c o m*/ */ public void launchApplication() { if (service == null) { return; } // Parse Application Url. Uri url = Uri.parse(APP_URL); // Get an instance of Application. multiscreenApp = service.createApplication(url, CHANNEL_ID); // Set the connection timeout to 20 seconds. // When the TV is unavailable after 20 seconds, onDisconnect event is called. multiscreenApp.setConnectionTimeout(20000); // Listen for the disconnect event. multiscreenApp.setOnDisconnectListener(new Channel.OnDisconnectListener() { @Override public void onDisconnect(Client client) { if (client != null) { // Notify service change listeners. EventBus.getDefault().post(new ConnectionChangedEvent(null)); } } }); // Listen for the connect event multiscreenApp.setOnConnectListener(new Channel.OnConnectListener() { @Override public void onConnect(Client client) { // Notify to update UI. EventBus.getDefault().post(new ConnectionChangedEvent(null)); } }); // Listen for the errors. multiscreenApp.setOnErrorListener(new Channel.OnErrorListener() { @Override public void onError(com.samsung.multiscreen.Error error) { Util.e("setOnErrorListener: " + error.toString()); EventBus.getDefault().post(new ConnectionChangedEvent(error.getMessage())); } }); // Add message listeners. multiscreenApp.addOnMessageListener(EVENT_APP_STATE, onAppStateListener); multiscreenApp.addOnMessageListener(EVENT_VIDEO_STATUS, onVideoStatusListener); multiscreenApp.addOnMessageListener(EVENT_VIDEO_START, onVideoStartListener); multiscreenApp.addOnMessageListener(EVENT_VIDEO_END, onVideoEndListener); // Connect and launch the TV application. // The timeout is 30 seconds. multiscreenApp.connect(null, 30000, new Result<Client>() { @Override public void onSuccess(Client client) { } @Override public void onError(com.samsung.multiscreen.Error error) { Util.e("connect onError: " + error.toString()); // failed to launch TV application. Notify TV service changes. EventBus.getDefault().post(new ConnectionChangedEvent(error.getMessage())); } }); }
From source file:com.samsung.soundscape.util.ConnectivityManager.java
/** * Makes connection to the TV and start the application on the TV * if the current service is available./*from w w w . j ava 2 s .c o m*/ */ public void launchApplication() { if (service == null) { return; } //Parse Application Url. Uri url = Uri.parse(App.getInstance().getString(R.string.app_url)); // Get an instance of Application. mMultiscreenApp = service.createApplication(url, App.getInstance().getString(R.string.channel_id)); //Set the connection timeout to 20 seconds. //When the TV is unavailable after 20 seconds, onDisconnect event is called. mMultiscreenApp.setConnectionTimeout(20000); //Listen for the disconnect event. mMultiscreenApp.setOnDisconnectListener(new Channel.OnDisconnectListener() { @Override public void onDisconnect(Client client) { if (client != null) { //Notify service change listeners. EventBus.getDefault().post(new ConnectionChangedEvent(null)); //restart to discovery if service is disconnected and // this application is not closing. if (!isExisting) startDiscovery(); } } }); // Listen for the connect event mMultiscreenApp.setOnConnectListener(new Channel.OnConnectListener() { @Override public void onConnect(Client client) { //stop discovery to save battery when a service is selected. stopDiscovery(); //Notify to update UI. EventBus.getDefault().post(new ConnectionChangedEvent(null)); } }); // Listen for the errors. mMultiscreenApp.setOnErrorListener(new Channel.OnErrorListener() { @Override public void onError(com.samsung.multiscreen.Error error) { Util.e("setOnErrorListener: " + error.toString()); EventBus.getDefault().post(new ConnectionChangedEvent(error.getMessage())); if (!isExisting) startDiscovery(); } }); mMultiscreenApp.addOnMessageListener(EVENT_APP_STATE, onAppStateListener); mMultiscreenApp.addOnMessageListener(EVENT_TRACK_STATUS, onTrackStatusListener); mMultiscreenApp.addOnMessageListener(EVENT_ADD_TRACK, onAddTrackListener); mMultiscreenApp.addOnMessageListener(EVENT_TRACK_START, onTrackStartListener); mMultiscreenApp.addOnMessageListener(EVENT_TRACK_END, onTrackEndListener); mMultiscreenApp.addOnMessageListener(EVENT_ASSIGN_COLOR, onAssignColorListener); mMultiscreenApp.addOnMessageListener(EVENT_REMOVE_TRACK, onRemoveTrackColorListener); //Connect and launch the TV application. mMultiscreenApp.connect(null, 30000, new Result<Client>() { @Override public void onSuccess(Client client) { } @Override public void onError(com.samsung.multiscreen.Error error) { Util.e("connect onError: " + error.toString()); //failed to launch TV application. Notify TV service changes. EventBus.getDefault().post(new ConnectionChangedEvent(error.getMessage())); } }); }
From source file:org.apache.jmeter.testbeans.gui.TestBeanGUI.java
public TestBeanGUI(Class<?> testBeanClass) { super();//w w w . ja v a 2s . c om log.debug("testing class: " + testBeanClass.getName()); // A quick verification, just in case: if (!TestBean.class.isAssignableFrom(testBeanClass)) { Error e = new Error(); log.error("This should never happen!", e); throw e; // Programming error: bail out. } this.testBeanClass = testBeanClass; // Get the beanInfo: try { beanInfo = Introspector.getBeanInfo(testBeanClass); } catch (IntrospectionException e) { log.error("Can't get beanInfo for " + testBeanClass.getName(), e); throw new Error(e.toString()); // Programming error. Don't // continue. } customizerClass = beanInfo.getBeanDescriptor().getCustomizerClass(); // Creation of the customizer and GUI initialization is delayed until // the // first // configure call. We don't need all that just to find out the static // label, menu // categories, etc! initialized = false; JMeterUtils.addLocaleChangeListener(this); }
From source file:de.unigoettingen.sub.commons.contentlib.imagelib.JpegInterpreter.java
private IIOMetadata getImageMetadata(ImageReader ir) throws ImageInterpreterException { IIOMetadata md = null;/*from w w w . ja va2 s . c o m*/ Node treeNode = null; try { md = ir.getImageMetadata(0); String formatName = md.getNativeMetadataFormatName(); treeNode = md.getAsTree(formatName); } catch (Error e) { throw new ImageInterpreterException("Error when attempting to parse image metadata: " + e.toString()); } catch (Exception e) { throw new ImageInterpreterException("Error when attempting to parse image metadata: " + e.toString()); } if ((treeNode == null) || (treeNode.getChildNodes() == null)) { throw new ImageInterpreterException("Image metadata Node is null or empty"); } return md; }
From source file:com.here.android.example.venue.Venue3dActivity.java
private void initialize() { setContentView(R.layout.venues3d);//w ww. ja v a2s . c om m_activity = this; // Search for the map fragment in order to finish setup by calling init(). m_mapFragment = (VenueMapFragment) getFragmentManager().findFragmentById(R.id.map_fragment); m_venueIdEditText = (EditText) findViewById(R.id.venueIdEditText); m_mainControlLayout = (LinearLayout) findViewById(R.id.venueOpeningLayout); m_routeInfoLayout = (LinearLayout) findViewById(R.id.routeInfoLayout); m_routingOptionType = (Spinner) findViewById(R.id.routeOptionType); m_routingOptionMode = (Spinner) findViewById(R.id.routeOptionMode); m_routeStartGuideText = (TextView) findViewById(R.id.startLocationGuideText); m_routeEndGuideText = (TextView) findViewById(R.id.endLocationGuideText); m_routingFromText = (TextView) findViewById(R.id.startLocationText); m_routingToText = (TextView) findViewById(R.id.endLocationText); m_showRouteButton = (Button) findViewById(R.id.buttonShowRoute); // Fill dropDownList with routing type names. String[] type_values = new String[] { "Fastest", "Shortest" }; configureSpinner(m_routingOptionType, type_values); // Fill dropDownList with routing mode names. String[] mode_values = new String[] { "Car", "Pedestrian", "Public Transport" }; configureSpinner(m_routingOptionMode, mode_values); // Set default values to: Fastest and Pedestrian. m_routingOptionType.setSelection(0); m_routingOptionMode.setSelection(1); // initialise the Map Fragment to have a map created and attached to // the fragment m_mapFragment.init(new OnEngineInitListener() { @Override public void onEngineInitializationCompleted(Error error) { if (error == Error.NONE) { // retrieve a reference of the map from the map fragment m_map = m_mapFragment.getMap(); // Set the map center, zoom level, orientation and tilt m_map.setCenter(new GeoCoordinate(49.196261, -123.004773, 0.0), Map.Animation.NONE); } else { System.out.println("ERROR: Cannot initialize Map Fragment" + error.toString()); } } }, new VenueServiceListener() { @Override public void onInitializationCompleted(InitStatus result) { if (result == InitStatus.ONLINE_SUCCESS || result == InitStatus.OFFLINE_SUCCESS) { // Register the activity class as VenueMapFragment.VenueListener m_mapFragment.addListener(m_activity); // Set animations on for floor change and venue entering m_mapFragment.setFloorChangingAnimation(true); m_mapFragment.setVenueEnteringAnimation(true); // Ask notification when venue visible; this notification is // part of VenueMapFragment.VenueListener m_mapFragment.setVenuesInViewportCallback(true); // Add listener for onCombinedRouteCompleted. m_mapFragment.getRoutingController().addListener(m_activity); // Add listener for map gesture. m_mapFragment.getMapGesture().addOnGestureListener(m_activity); // Create floor change widget m_floorsController = new VenueFloorsController(m_activity, m_mapFragment, (ListView) findViewById(R.id.floorListView), R.layout.floor_item, R.id.floorName, R.id.floorGroundSep); m_initCompleted.set(true); // Start position tracking PositioningManager positioningManager = PositioningManager.getInstance(); positioningManager.start(PositioningManager.LocationMethod.GPS_NETWORK_INDOOR); // Set positioning indicator visible PositionIndicator positionIndicator = m_mapFragment.getPositionIndicator(); positionIndicator.setVisible(true); } } @Override public void onGetVenueCompleted(Venue venue) { } }); }
From source file:com.virtusa.isq.vtaf.runtime.SeleniumTestBase.java
/** * Checks the contents of a pie chart against the expected values. * /*from w w w . j ava 2 s . c om*/ * @param chartElementXpath */ private StringBuffer insightPieChartContentCheck(String chartName, ArrayList<String> chartnames, ArrayList<String> chartvalues, ArrayList<String> chartpercentages, int startingele, String chartElementXpath) { // Portlet content variables WebDriver driver = getDriver(); ArrayList<String> chartelementnames = chartnames; ArrayList<String> chartelementvalues = chartvalues; ArrayList<String> chartpercentage = chartpercentages; ArrayList<String> chartelementnamesAct = new ArrayList<String>(); ArrayList<String> chartelementvaluesAct = new ArrayList<String>(); int startingelement = startingele; int arraycounter = 0; StringBuffer verificationErrors = new StringBuffer(); int elementCount = 0; JavascriptExecutor jsExecutor = (JavascriptExecutor) driver; // Checking chart structure // The first loop of the pie chart check // Accessing the elements in the pie chart // ELEMENT ELEMENT ELEMENT ELEMENT ELEMENT ELEMENT ELEMENT ELEMENT // ELEMENT ELEMENT ELEMENT try { int countA = 0; List<WebElement> locateElements = driver .findElements(By.xpath("" + chartName + "//*[name()='svg']/child::*[name()='g']")); countA = locateElements.size(); int categories = countA - 2; for (int j = startingelement; j < categories + startingelement; j++) { System.out.println("" + chartName + "//*[name()='svg']/child::*[position()=" + (j) + "]"); WebElement chartElement = driver.findElement(By.xpath(chartElementXpath)); jsExecutor.executeScript("var evObj = document.createEvent('MouseEvents');" + "evObj.initMouseEvent(\"mouseover\",true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);" + "arguments[0].dispatchEvent(evObj);", chartElement); Thread.sleep(1000); WebElement element = driver.findElement( By.xpath("" + chartName + "//*[name()='svg']/child::*[position()=" + (j) + "]")); jsExecutor.executeScript("var evObj = document.createEvent('MouseEvents');" + "evObj.initMouseEvent(\"mouseover\",true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);" + "arguments[0].dispatchEvent(evObj);", element); try { driver.findElements(By.xpath("" + chartName + "//*[name()='svg']/child::*[position()=" + (chartelementnames.size() + startingelement) + "]")); } catch (Error e) { verificationErrors.append("\n" + e.toString()); } Thread.sleep(500); int countB = 0; List<WebElement> locateElementsTwo = driver .findElements(By.xpath("" + chartName + "//*[name()='svg']/child::*[name()='g']")); countB = locateElementsTwo.size(); elementCount = countB; if (elementChartElementPresent("" + chartName + "//*[name()='svg']/child::*[position()=" + (categories + 4) + "]/child::*[position()=1]/child::*[position()=4]")) { String xpath = "" + chartName + "//*[name()='svg']/child::*[position()=" + (categories + 4) + "]/child::*[position()=1]/child::*[position()=4]"; System.out.println("XPATH :" + xpath); chartelementnamesAct.add(driver .findElement(By.xpath("" + chartName + "//*[name()='svg']/child::*[position()=" + (categories + 4) + "]/child::*[position()=1]/child::*[position()=4]")) .getText()); } System.out.println("chartelementnamesAct : " + chartelementnamesAct); if (elementChartElementPresent("" + chartName + "//*[name()='svg']/child::*[position()=" + (categories + 4) + "]/child::*[position()=1]/child::*[position()=5]")) { chartelementvaluesAct.add(driver .findElement(By.xpath("" + chartName + "//*[name()='svg']/child::*[position()=" + (categories + 4) + "]/child::*[position()=1]/child::*[position()=5]")) .getText()); System.out.println("chartelementvaluesAct:" + chartelementvaluesAct); } } for (int i = 0; i < chartelementnames.size(); i++) { String expectedname = "" + chartelementnames.get(i) + ""; String expectedPers = "" + chartelementvalues.get(i) + " (" + chartpercentage.get(i) + "%)"; if (chartelementnamesAct.contains(expectedname)) { if (chartelementvaluesAct.contains(expectedPers)) { } else { verificationErrors .append("\n Chart comparison mismatch : percentage " + expectedPers + " is not present in the actual percentage values " + expectedname) .append(chartelementvaluesAct); } } else { verificationErrors .append("\n Chart comparison mismatch : category name " + expectedname + " is not present in the actual percentage values ") .append(chartelementnamesAct); } } } catch (Exception e) { verificationErrors.append("\n" + e.toString()); } return verificationErrors; }
From source file:com.virtusa.isq.vtaf.runtime.SeleniumTestBase.java
/** * Checks the contents of a bar chart against the expected values. *///from ww w . ja v a 2s . c o m private StringBuffer insightBarChartContentCheck(String chartName, ArrayList<String> chartnames, ArrayList<String> chartvalues, ArrayList<String> chartpercentages, int startingele, String chartElementXpath) { // Portlet content variables WebDriver driver = getDriver(); ArrayList<String> chartelementnames = chartnames; ArrayList<String> chartelementvalues = chartvalues; ArrayList<String> chartpercentage = chartpercentages; int startingelement = startingele; int arraycounter = 0; StringBuffer verificationErrors = new StringBuffer(); int actCategoryCount = 0; int actElementCnt = 0; int elementOffset = 0; int firstChild = 0; ArrayList<String> htmlElementNames = new ArrayList<String>(); ArrayList<String> htmlElementValues = new ArrayList<String>(); Actions action = new Actions(driver); jsExecutor = (JavascriptExecutor) driver; // Checking chart structure // The first loop of the pie chart check if (chartName.contains("text")) { elementOffset = 3; firstChild = 4; } else if (chartName.contains("img")) { elementOffset = 2; firstChild = 3; } List<WebElement> locateElementsThree = driver.findElements(By .xpath(chartName + "//child::*[position()=" + firstChild + " and name()='g']/child::*[position()=2 " + "and name()='g']/child::*[position()=2 " + "and name()='g']/child::*[name()='rect']")); System.out.println("### :" + locateElementsThree); actCategoryCount = locateElementsThree.size(); List<WebElement> locateElementsFour = driver .findElements(By.xpath(chartName + "//child::*[position()=2 and name()='g']")); actElementCnt = locateElementsFour.size(); for (int i = startingelement; i < actCategoryCount + startingelement; i++) { // Accessing the elements in the pie chart // ELEMENT ELEMENT ELEMENT ELEMENT ELEMENT ELEMENT ELEMENT ELEMENT // ELEMENT ELEMENT ELEMENT try { try { action = new Actions(driver); action = new Actions(driver); WebElement chartHeaderEle = driver.findElement(By.xpath(chartElementXpath)); jsExecutor.executeScript("var evObj = document.createEvent('MouseEvents');" + "evObj.initMouseEvent(\"mouseover\",true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);" + "arguments[0].dispatchEvent(evObj);", chartHeaderEle); Thread.sleep(1000); WebElement elementTwo = driver.findElement(By.xpath(chartName + "//child::*[position()=" + firstChild + " and name()='g']/child::*[position()=2 and name()='g']/child::*[position()=2 " + "and name()='g']/child::*[position()=" + i + " and name()='rect']")); Thread.sleep(1000); jsExecutor.executeScript("var evObj = document.createEvent('MouseEvents');" + "evObj.initMouseEvent(\"mouseover\",true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);" + "arguments[0].dispatchEvent(evObj);", elementTwo); Thread.sleep(1000); } catch (Exception ex) { if (ex.getMessage().contains("Alert")) { action = new Actions(driver); action.moveToElement(driver.findElement(By.xpath(chartName + "//child::*[position()=" + firstChild + " and name()='g']/child::*[position()=2 and name()='g']/child::*[position()=2 and name()='g']/child::*[position()=" + i + " and name()='rect']"))).build().perform(); } } try { driver.findElements(By.xpath(chartName + "/child::*[name()='g' and position()=" + (actElementCnt + elementOffset) + "]")); } catch (Error e) { verificationErrors.append("\n" + e.toString()); } try { String chartstr12 = driver.findElement(By.xpath( chartName + "/child::*[name()='g' and position()=" + (actElementCnt + elementOffset) + "]//*[name()='text' and position()=" + 1 + "]")) .getText(); htmlElementNames.add(chartstr12); } catch (Error e) { verificationErrors.append("\n" + e.toString()); } try { String chartstr22 = driver.findElement(By.xpath( chartName + "/child::*[name()='g' and position()=" + (actElementCnt + elementOffset) + "]//*[name()='text' and position()=" + 2 + "]")) .getText(); htmlElementValues.add(chartstr22); } catch (Error e) { verificationErrors.append("\n" + e.toString()); } arraycounter = arraycounter + 1; } catch (Error e) { verificationErrors.append("\n" + e.toString()); } catch (Exception e1) { verificationErrors.append("\n" + e1.toString()); } } for (int i = 0; i < chartelementnames.size(); i++) { boolean isElementNameMatched = false; if (htmlElementValues.contains(chartelementvalues.get(i))) { // Get the indexes of duplicate entries ArrayList<Integer> indexes = new ArrayList<Integer>(); for (int j = 0; j < htmlElementValues.size(); j++) { if (htmlElementValues.get(j).equals(chartelementvalues.get(i))) { indexes.add(j); for (int k = 0; k < indexes.size(); k++) { if (htmlElementNames.get(indexes.get(k)).equals(chartelementnames.get(i))) { isElementNameMatched = true; break; } else { continue; } } } } } else { verificationErrors.append("\n Element :" + i + " Element value = " + chartelementvalues.get(i) + " is not present. Actual Value :- " + htmlElementValues.get(i) + "\n"); } if (htmlElementNames.contains(chartelementnames.get(i))) { isElementNameMatched = true; continue; } if (!isElementNameMatched) { verificationErrors .append("\n Element :" + i + " Expected element name = " + chartelementnames.get(i) + " is different from the " + "actual names :- " + htmlElementNames); } } return verificationErrors; }
From source file:com.virtusa.isq.vtaf.runtime.SeleniumTestBase.java
/** * Checks the contents of a multi color bar chart against the expected * values.//from w ww. j av a2 s . c om * * @param userColumns * @param chartElementXpath * @param */ @SuppressWarnings("rawtypes") private StringBuffer insightColorBarChartContentCheck(String chartName, String chartLocator, ArrayList<String> chartnames, ArrayList<String> chartvalues, ArrayList<String> chartpercentages, int startingele, int checkingColCount, HashMap<Integer, ArrayList> userColumns, String chartElementCapture, String chartElementXpath) { // Portlet content variables WebDriver driver = getDriver(); ArrayList<String> chartelementnames = chartnames; ArrayList<String> chartelementvalues = chartvalues; // ArrayList<String> chartpercentage = chartpercentages; int startingelement = startingele; int arraycounter = 0; StringBuffer verificationErrors = new StringBuffer(); int actCategoryCount = 0; int actElementCnt = 0; int elementOffset = 0; ArrayList<String> htmlElementNames = new ArrayList<String>(); ArrayList<String> htmlElementValues = new ArrayList<String>(); // chathura HashMap<Integer, ArrayList> htmlColumns = new HashMap<Integer, ArrayList>(); ArrayList htmlColumnValues = new ArrayList(); JavascriptExecutor jsExecutor = (JavascriptExecutor) driver; Actions action = new Actions(driver); if (chartName.contains("text")) { elementOffset = 3; } else if (chartName.contains("img")) { elementOffset = 2; } List<WebElement> locateElementsThree = driver .findElements(By.xpath(chartName + "//child::*[position()=2 and name()='g']/child::*[position()=2 " + "and name()='g']/child::*[name()='rect']")); actCategoryCount = locateElementsThree.size(); List<WebElement> locateElementsFour = driver .findElements(By.xpath(chartName + "//child::*[position()=2 and name()='g']")); actElementCnt = locateElementsFour.size(); int rectFormat = actCategoryCount / actElementCnt; // The first loop of the pie chart check for (int i = startingelement; i <= rectFormat; i++) { // Accessing the different colored elements in a bar // ELEMENT ELEMENT ELEMENT ELEMENT ELEMENT ELEMENT ELEMENT ELEMENT // ELEMENT ELEMENT ELEMENT htmlElementNames = new ArrayList<String>(); htmlElementValues = new ArrayList<String>(); htmlColumnValues = new ArrayList<>(); for (int colorFieldRect = i; colorFieldRect <= actCategoryCount; colorFieldRect += rectFormat) { try { try { WebElement chartHeaderEle = driver.findElement(By.xpath(chartElementXpath)); jsExecutor.executeScript("var evObj = document.createEvent('MouseEvents');" + "evObj.initMouseEvent(\"mouseover\",true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);" + "arguments[0].dispatchEvent(evObj);", chartHeaderEle); WebElement element = driver.findElement(By.xpath(chartName + "//child::*[position()=2 and name()='g']/child::*[position()=2 and name()='g']")); jsExecutor.executeScript("var evObj = document.createEvent('MouseEvents');" + "evObj.initMouseEvent(\"mouseover\",true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);" + "arguments[0].dispatchEvent(evObj);", element); System.out.println(element); Thread.sleep(500); WebElement element2 = driver.findElement(By.xpath(chartName + "//child::*[position()=2 and name()='g']/child::*[position()=2 and name()='g']/child::*[position()=" + colorFieldRect + " and name()='rect']")); jsExecutor.executeScript("var evObj = document.createEvent('MouseEvents');" + "evObj.initMouseEvent(\"mouseover\",true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);" + "arguments[0].dispatchEvent(evObj);", element2); System.out.println(element2); Thread.sleep(500); } catch (Exception ex) { if (ex.getMessage().contains("Alert")) { if (ex.getMessage().contains("Alert")) { WebElement element3 = driver.findElement(By.xpath(chartName + "//child::*[position()=2 and name()='g']/child::*[position()=2 and name()='g']/child::*[position()=" + colorFieldRect + " and name()='rect']")); jsExecutor.executeScript("var evObj = document.createEvent('MouseEvents');" + "evObj.initMouseEvent(\"mouseover\",true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);" + "arguments[0].dispatchEvent(evObj);", element3); } } } try { driver.findElements(By.xpath(chartName + "//child::*[name()='g' and position()=" + (actElementCnt + elementOffset) + "]")); } catch (Error e) { verificationErrors.append("\n" + e.toString()); } try { String chartstr12 = driver.findElement(By.xpath(chartName + "/..//child::*[position()=1 and name()='svg']/child::*[name()='g' and position()=" + (actElementCnt + elementOffset) + "]//*[name()='text' and position()=" + 1 + "]")).getText(); System.out.println("chartstr12 : " + chartstr12); htmlElementNames.add(chartstr12); } catch (Error e) { verificationErrors.append("\n" + e.toString()); } try { String chartstr22 = driver.findElement(By.xpath(chartName + "/..//child::*[position()=1 and name()='svg']/child::*[name()='g' and position()=" + (actElementCnt + elementOffset) + "]//*[name()='text' and position()=" + 2 + "]")).getText(); System.out.println("chartstr22 : " + chartstr22); htmlElementValues.add(chartstr22); } catch (Error e) { verificationErrors.append("\n" + e.toString()); } arraycounter = arraycounter + 1; } catch (Error e) { verificationErrors.append("\n" + e.toString()); } catch (Exception e1) { verificationErrors.append("\n" + e1.toString()); } } // end of second for loop htmlColumnValues.add(htmlElementNames); htmlColumnValues.add(htmlElementValues); htmlColumns.put(i, htmlColumnValues); } // end of first for loop for (int i = 1; i <= userColumns.size(); i++) { int checkingHtmlColumn = -1; for (int j = 1; j <= htmlColumns.size(); j++) { if (((ArrayList) userColumns.get(i).get(0)).get(0) .equals(((ArrayList) htmlColumns.get(j).get(0)).get(0))) { checkingHtmlColumn = j; break; } } // check if the if (checkingHtmlColumn < 0) { verificationErrors.append("\n Element :" + i + " Input column name : " + ((ArrayList) userColumns.get(i).get(0)).get(0) + " cannot be found in the chart"); continue; } else { ArrayList currUserColumnNames = ((ArrayList) userColumns.get(i).get(0)); ArrayList currUserColumnValues = ((ArrayList) userColumns.get(i).get(1)); ArrayList currHtmlColumnNames = ((ArrayList) htmlColumns.get(checkingHtmlColumn).get(0)); ArrayList currHtmlColumnValues = ((ArrayList) htmlColumns.get(checkingHtmlColumn).get(1)); for (int k = 0; k < currHtmlColumnValues.size(); k++) { if (currHtmlColumnValues.get(k).equals("0") || currHtmlColumnValues.get(k) == null) { currHtmlColumnNames.remove(k); currHtmlColumnValues.remove(k); k--; } } // Checking the column names if (currHtmlColumnNames.equals(currUserColumnNames)) { } else { verificationErrors.append("\n Element :" + i + " Expected element names = " + userColumns.get(i).get(0) + " are different from the " + "actual names : " + htmlColumns.get(checkingHtmlColumn).get(0) + " | "); } // Checking the column values if (currHtmlColumnValues.equals(currUserColumnValues)) { } else { verificationErrors.append("\n Element :" + i + " Expected element values = " + userColumns.get(i).get(1) + " are different from the " + "actual values : " + htmlColumns.get(checkingHtmlColumn).get(1) + " | "); } } } return verificationErrors; }