Unable to handle the ConcurrentModificationException | Selenium Forum
P
Pravin V. Kumbhare Posted on 17/11/2020

I'm practicing the WebTables. My test URL is https://money.rediff.com/gainers/bse/daily/groupa?src=gain_lose. I've created a function which will take the name of company (hard coded in the script) and return the corresponding row number from the table.

I'm able to execute the script properly, but I'm also getting the ConcurrentModificationException, which I'm unable to handle.

Below is the output on the console:

[TestNG] Time taken by org.testng.reporters.jq.Main@17c68925: 96 ms
[TestNG] Time taken by org.testng.reporters.XMLReporter@96532d6: 6 ms
[TestNG] Time taken by org.testng.reporters.EmailableReporter2@6442b0a6: 7 ms
[TestNG] Reporter org.testng.reporters.JUnitReportReporter@7f690630 failed
java.util.ConcurrentModificationException
at java.util.ArrayList$Itr.checkForComodification(ArrayList.java:909)
at java.util.ArrayList$Itr.next(ArrayList.java:859)
at org.testng.reporters.JUnitReportReporter.getNextConfiguration(JUnitReportReporter.java:220)
at org.testng.reporters.JUnitReportReporter.generateReport(JUnitReportReporter.java:105)
at org.testng.TestNG.generateReports(TestNG.java:1175)
at org.testng.TestNG.run(TestNG.java:1102)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:132)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:236)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:81)
[TestNG] Time taken by [FailedReporter passed=0 failed=0 skipped=0]: 1 ms
[Utils] Attempting to create C:\Kapil\Kapil B\Auto\Selenium\Workspace\WebDriverCmds_Kapil\test-output\old\Default suite\toc.html
[Utils] Directory C:\Kapil\Kapil B\Auto\Selenium\Workspace\WebDriverCmds_Kapil\test-output\old\Default suite exists: true
[Utils] Attempting to create C:\Kapil\Kapil B\Auto\Selenium\Workspace\WebDriverCmds_Kapil\test-output\old\Default suite\Default test.properties
[Utils] Directory C:\Kapil\Kapil B\Auto\Selenium\Workspace\WebDriverCmds_Kapil\test-output\old\Default suite exists: true
[Utils] Attempting to create C:\Kapil\Kapil B\Auto\Selenium\Workspace\WebDriverCmds_Kapil\test-output\old\Default suite\index.html
[Utils] Directory C:\Kapil\Kapil B\Auto\Selenium\Workspace\WebDriverCmds_Kapil\test-output\old\Default suite exists: true
[Utils] Attempting to create C:\Kapil\Kapil B\Auto\Selenium\Workspace\WebDriverCmds_Kapil\test-output\old\Default suite\main.html
[Utils] Directory C:\Kapil\Kapil B\Auto\Selenium\Workspace\WebDriverCmds_Kapil\test-output\old\Default suite exists: true
[Utils] Attempting to create C:\Kapil\Kapil B\Auto\Selenium\Workspace\WebDriverCmds_Kapil\test-output\old\Default suite\groups.html
[Utils] Directory C:\Kapil\Kapil B\Auto\Selenium\Workspace\WebDriverCmds_Kapil\test-output\old\Default suite exists: true
[Utils] Attempting to create C:\Kapil\Kapil B\Auto\Selenium\Workspace\WebDriverCmds_Kapil\test-output\old\Default suite\classes.html
[Utils] Directory C:\Kapil\Kapil B\Auto\Selenium\Workspace\WebDriverCmds_Kapil\test-output\old\Default suite exists: true
[Utils] Attempting to create C:\Kapil\Kapil B\Auto\Selenium\Workspace\WebDriverCmds_Kapil\test-output\old\Default suite\reporter-output.html
[Utils] Directory C:\Kapil\Kapil B\Auto\Selenium\Workspace\WebDriverCmds_Kapil\test-output\old\Default suite exists: true
[Utils] Attempting to create C:\Kapil\Kapil B\Auto\Selenium\Workspace\WebDriverCmds_Kapil\test-output\old\Default suite\methods-not-run.html
[Utils] Directory C:\Kapil\Kapil B\Auto\Selenium\Workspace\WebDriverCmds_Kapil\test-output\old\Default suite exists: true
[Utils] Attempting to create C:\Kapil\Kapil B\Auto\Selenium\Workspace\WebDriverCmds_Kapil\test-output\old\Default suite\testng.xml.html
[Utils] Directory C:\Kapil\Kapil B\Auto\Selenium\Workspace\WebDriverCmds_Kapil\test-output\old\Default suite exists: true
[Utils] Attempting to create C:\Kapil\Kapil B\Auto\Selenium\Workspace\WebDriverCmds_Kapil\test-output\old\index.html
[Utils] Directory C:\Kapil\Kapil B\Auto\Selenium\Workspace\WebDriverCmds_Kapil\test-output\old exists: true
[TestNG] Time taken by org.testng.reporters.SuiteHTMLReporter@5b464ce8: 81 ms
 

Attached herewith is my source code.


A
Ashish Replied on 18/11/2020

Which testng version are you using?


P
Pravin V. Kumbhare Replied on 18/11/2020

At present I'm using 6.14.3.

But I tried getting rid of this issue with different TestNG versions including 6.9.10 and couple of more (I don't remember exactly).

The issue is same every time.


P
Pravin V. Kumbhare Replied on 19/11/2020

Can you please check this? Although this is not blocking the execution, I', getting this issue EVERY TIME.


A
Ashish Replied on 20/11/2020

This is known issue in TestNG

Install TestNG 7.0

They fixed this in it


P
Pravin V. Kumbhare Replied on 20/11/2020

I tried this as well, but the issue is still there. There's some issue with the imported jars. 

As can be seen in the console output, the exception mentions JUnitReportReporter. I haven't used JUnit anywhere. This is some problem with the import.

I don't know how to get rid of this issue.

 

I copied the same pom dependencies in a new project and the issue is not there (because correct jars are imported).

 

Why and how are the wrong jars imported in first place? If this issue occurs in future, how to get rid of this? We cannot keep copying everything in a new project everytime.