Search code examples
seleniumautomationtestngtest-suite

Random TestNG exception while Executing Webdriver Scripts


I have an Automation Framework for a Web Application where a Java class contains all the test Methods(TestNG annotation @Test).The execution can be started either by clicking RUN in eclipse or by Selecting Run as->TestNG test on Project.The data source is set of excel files accessed via Apache POI.

Lately I am encountering an unusual error, the moment i launch the suite i get following exception but its random say 6 out of 10 times and all this time i don't do any changes with the framework except executing it.I have gone through posts related to similar exceptions but can't figure out why it will occur sometime and not at others and how to fix it.

org.testng.testngexception: com.sun.org.apache.xerces.internal.impl.io.malformedbytesequenceexception invalid Byte 2 of 4 byte UTF-8 sequence.

Solution

  • seems the encoding of the excel file is causing issues.

    Open the excel file and re-save it with utf-8 encoding.

    Doing that by:

    • Open excel file.
    • From toolbar click 'file' and then 'save as'
    • near the save button have 'tools' drop down menu select web options
    • new window should have open, click on the tab encoding and select 'utf-8'