Configuration Web

MyITest4U can be fine tuned for your application.
A run and a spider configuration can be defined. The run configuration can be used in tests runs. There is not default run configuration.
The spider configuration will be used in the spider run. The spider configuration can contain global and local values.
Global configuration values are the same for all AUTs. Local configuration values belong to a certain AUT release. There can be more than one local spider configuration for the same release. Local spider configurations can be saved. Thereby the same name is used for a certain AUT. The configuration values can be set for each AUT release. This allows you to extend a local configuration for a release, while keeping the configuration name.

Post Proc Actions

MyITest4U allows you to perform certain tasks after an action like comparing the current page source against a reference. Post Proc Actions are the actions after which these tasks are done. The global default Post Proc Action is "Click". Local Post Proc Actions can be defined in the spider configuration. Post Proc Actions are used in a spider and in a test run.

Global Post Proc Action can be set by selecting Config / General from the MyITest4U menu.
Local Post Proc Action can be set by selecting Config / Local or Config / Spider / Summary from the MyITest4U menu.
A stored Local Spider Configuration can be selected in the Run Test Configuration dialog and Spider Configuration dialog.

Display Value

The Display Value is shown in the Element column of the editor. The Speaking Name is used if it is set. Otherwise the following HTML tag attribute values are used to determine the display value:

  • speakingName
  • id
  • name
  • text
  • value
  • xPath

The above values are used in the given order. The first value which is set is used.

You can change this behavior by implementing a different behavior using the method getElementDisplayValue of the class MyConfig.

       
    /**
     * Use this method to determine the HtmlTag display value. This string is shown
     * in the editor table in the Element column.
     * 
     * The parameters are the values of the corresponding htmlTag attributes if they
     * are set otherwise null.
     * 
     * @param name
     * @param id
     * @param text
     * @param xPath
     * @param speakingName a user defined name or null if it is not given.
     * @param value
     * @return displayValue
     */

    @Override
    public String getElementDisplayValue(String name, String id, String text, String xPath, String speakingName,
            String value) {

        if (speakingName != null && speakingName.length() > 0) {
            return speakingName;
        }

        return super.getElementDisplayValue(name, id, text, xPath, speakingName, value);
    }
    
      

The method super.getElementDisplayValue.

       
    /**
     * Use this method to determine the HtmlTag display value. This string is shown
     * in the editor table in the Element column.
     * 
     * The parameters are the values of the corresponding htmlTag attributes if they
     * are set otherwise null.
     * 
     * @param name
     * @param id
     * @param text
     * @param xPath
     * @param speakingName a user defined name or null if it is not given.
     * @param value
     * @return displayValue
     */

    public String getElementDisplayValue(String name, String id, String text, String xPath, String speakingName,
            String value) {

        if (id != null && id.length() > 0) {
            return id;
        }

        if (name != null && name.length() > 0) {
            return name;
        }

        if (text != null) {
            text = text.replace("\n", "");
            if (text.length() > 25) {
                return text.substring(0, 24) + "...";
            } else if (text.length() > 0) {
                return text;
            }
        }

        if (value != null) {
            value = value.replace("\n", "");
            if (value.length() > 25) {
                return value.substring(0, 24) + "...";
            } else if (value.length() > 0) {
                return value;
            }
        }

        return xPath;
    }
    
      

Analysis Of Browser Logs

Selenium can obtain the browser logs (see Selenium documentation for details).
MyITest4U can collect the browser logs and show an error in the test log. The default configuration will not collect any browser logs. You can change this behavior by implementing the method analyzeBrowserLog of the class MyConfig.

An example implementation is given in the commented section below (It was tested with ChromeDriver 107.0.5304.62. It might not work using other WebDrivers. See also https://stackoverflow.com/questions/70787924/how-to-capture-java-script-errors-using-selenium-java-webdriver ... So, unfortunately, driver.manage().logs() is not implemented by Firefox. ...).

       
    /**
     * Use this method to set which browser logs are checked for entries.
* An entry in the browser log will result in an error in the test.
* Return true and do nothing in the method if no browser logs should be * checked.
* "Post Proc Action" defines after which action the browser logs are * checked.
* The default is "Click".
* The checking of browser logs can be ignored using an "a" as * additional parameter in the parameter file.
* The code in the commented section is an example implementation found on the Internet. * It might not work anymore. * * @param driver * @param errorStart used for proper logging * @return false if an error should be shown in the test log.
* true no error will be shown. * @throws Exception */ public boolean analyzeBrowserLog(WebDriver driver, String action, String errorStart, ArrayList postProcActions) throws Exception { return true; /*if (postProcActions == null) { return true; } boolean doAnalyis = false; try { for (String pAction : postProcActions) { if (pAction.equals(action)) { doAnalyis = true; } } } catch (Exception e) { throw new Exception("Use of post proc action did not work.", e); } if (doAnalyis == false) { return true; } try { LogEntries logs = driver.manage().logs().get(LogType.BROWSER); StringBuffer bu = new StringBuffer(); for (LogEntry entry : logs) { bu.append(entry.getLevel() + " " + entry.getMessage()).append("\n"); } if (bu.length() > 0) { // keep this format to see the browser log entries in the test log as errors. Log.LOGGER.log(MyLevel.TESTLOG, errorStart + bu.toString()); // used by the spider to write the log entries to the spider foundBugs file. setBrowserLogText(errorStart + bu.toString()); return false; } else { return true; } } catch (Exception e) { // keep this format to see the browser log entries in the test log as errors. Log.LOGGER.log(MyLevel.TESTLOG, errorStart + "Browser logs could not be obtained.", e); // used by the spider to write the log entries to the spider foundBugs file. setBrowserLogText(errorStart + "Browser logs could not be obtained.\n" + ExceptionUtils.getStackTrace(e.fillInStackTrace())); return false; }finally { if (devTools != null) { devTools.close(); } } */ }

Analysis of JavaScript exception

Selenium can collect javascript exceptions (see Selenium documentation for details).
MyTItest4U can show them in the test error log (see Analysis Of Browser Logs).
An example implementation is given in the commented section below.

       
        /**
     * Use this method to get JavaScript exceptions.
* Return true and do nothing in the method if no JavaScript exceptions should * be logged.
* "Post Proc Action" defines after which action the browser logs are * checked.
* The default is "Click".
* JavaScript exceptions logging can be ignored using an "j" as * additional parameter in the parameter file.
* * The code in the commented section is an example implementation found on the Internet. * It might not work anymore. * * @param driver * @param errorStart used for proper logging * @return false if an error should be shown in the test log.
* true no error will be shown. * @throws Exception */ public boolean analyzeJSExceptions(WebDriver driver, String action, String errorStart, ArrayList postProcActions) throws Exception { return true; /*if (postProcActions == null) { return true; } boolean doAnalyis = false; try { for (String pAction : postProcActions) { if (pAction.equals(action)) { doAnalyis = true; } } } catch (Exception e) { throw new Exception("Use of post proc action did not work.", e); } if (doAnalyis == false) { return true; } DevTools devTools = null; try { if (driver instanceof ChromeDriver) { devTools = ((ChromeDriver) driver).getDevTools(); } else if (driver instanceof FirefoxDriver) { devTools = ((FirefoxDriver) driver).getDevTools(); } else if (driver instanceof EdgeDriver) { devTools = ((EdgeDriver) driver).getDevTools(); } if (devTools == null) { return true; } devTools.createSession(); List jsExceptionsList = new ArrayList<>(); Consumer addEntry = jsExceptionsList::add; devTools.getDomains().events().addJavascriptExceptionListener(addEntry); StringBuffer bu = new StringBuffer(); for (JavascriptException jsException : jsExceptionsList) { bu.append("JS exception message: " + jsException.getMessage()).append("\n"); bu.append("JS exception system information: " + jsException.getSystemInformation()).append("\n"); StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); jsException.printStackTrace(pw); bu.append(sw.toString()); } if (bu.length() > 0) { // keep this format to see the browser log entries in the test log as errors. Log.LOGGER.log(MyLevel.TESTLOG, errorStart + bu.toString()); // used by the spider to write the log entries to the spider foundBugs file. setBrowserLogText(errorStart + bu.toString()); return false; } else { return true; } } catch (Exception e) { Log.LOGGER.log(MyLevel.TESTLOG, errorStart + "JS exceptions not be obtained.", e); // used by the spider to write the log entries to the spider foundBugs file. setBrowserLogText(errorStart + "JavaScript exceptions could not be obtained.\n" + ExceptionUtils.getStackTrace(e.fillInStackTrace())); return false; } finally { if (devTools != null) { devTools.close(); } }*/ }